Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Human Talks: N'ayez pas peur de faire du Groovy

Human Talks: N'ayez pas peur de faire du Groovy

Slides du lightning talk donné à HumanTalks Nantes.

Cédric Champeau

November 18, 2014
Tweet

More Decks by Cédric Champeau

Other Decks in Programming

Transcript

  1. log.message "Releasing Groovy $version with user: $user" def desc =

    "Release of $version" def date = new Date().format("yyyy-MM-dd'T'HH:mm:ss.SSSZ") def remoteCall = { String url, List params, Closure onFailure -> def p = ['curl', "-m", "3600", "-u", "$user:$key", *params, url].execute() int code = p.waitFor() def resp = p.text log.message "${resp}" if (code!=0 || resp.toLowerCase().contains('error') ) { onFailure(code) System.exit(code) } }
  2. remoteSession { scp { from { localDir "$buildDir/application " }

    into { remoteDir '/usr/local/myapp' } timeout 10.minutes } }
  3. @Immutable @ToString class Person { String name int age String

    greet(String them) { "Hello $them, my name is $name" } }
  4. @ToString class Person { String name int age } def

    storage = [new Person(name:'Cédric', age:35), new Person(name:'Hugues', age:44)] Person.metaClass.static.methodMissing = { String name, args -> if (name.startsWith('findBy')) { String prop = (name - 'findBy').toLowerCase() storage.findAll { it."$prop" == args[0]} } } println Person.findByAge(35)
  5. @ToString class Person { String name int age } @CompileStatic

    void erreurDeCompil() { println Person.findByAge(35) }
  6. notify(NOTIFICATION_ID) { smallIcon = R.drawable.ic_action_alarms largeIcon = cachedBitmap contentTitle =

    'Time left' contentText = "$timeLeft (Elapsed: ${rounded}%)" contentIntent = pendingActivityIntent(0, intent(WearPresentationActivity), FLAG_UPDATE_CURRENT) ongoing = true style = bigTextStyle { bigText """Time left for your presentation: $timeLeft Elapsed time: ${rounded}%) """ } }
  7. layout 'layouts/main.groovy', true, pageTitle: 'The Groovy programming language - Mailing-lists',

    mainContent: contents { div(id: 'content', class: 'page-1') { div(class: 'row') { div(class: 'row-fluid') { div(class: 'col-lg-3') { include template: 'includes/community-navbar.groovy' } div(class: 'col-lg-8 col-lg-pull-0') { include template: 'includes/contribute-button.groovy' h1 { i(class: 'fa fa-envelope-o') {} yield ' Mailing-lists' } ...