Tuesday, April 24, 2012

self-referenced tree, in one line!

//source: https://gist.github.com/2478499

def tree = { [:].withDefault{ owner.call() } } // ta-da!

users = tree()

users.harold.username = 'hrldcpr'
users.yates.username = 'tim'

users.with {
    al.username = 'al1'
    derek.username = 'skinnyk1d'
    
    frier.with {
        username = 'great1'
        password = 'changeme1'
        updatedOn = '4/26/2012'
    }
    
    bob.with {
        age = 4
        isOld = false
    }
}

println new groovy.json.JsonBuilder( users ).toPrettyString()

CodeNarc bundle

Simple starter zip file for running CodeNarc (groovy static analysis) 0.17 inside a local groovy source code folder. (Windows .bat file) Generates html report page.