Groovy mode

 
1
//Pattern for groovy script
2
def p = ~/.*\.groovy/
3
new File( 'd:\\scripts' ).eachFileMatch(p) {f ->
4
  // imports list
5
  def imports = []
6
  f.eachLine {
7
    // condition to detect an import instruction
8
    ln -> if ( ln =~ '^import .*' ) {
9
      imports << "${ln - 'import '}"
10
    }
11
  }
12
  // print thmen
13
  if ( ! imports.empty ) {
14
    println f
15
    imports.each{ println "   $it" }
16
  }
17
}
18
19
/* Coin changer demo code from http://groovy.codehaus.org */
20
21
enum UsCoin {
22
  quarter(25), dime(10), nickel(5), penny(1)
23
  UsCoin(v) { value = v }
24
  final value
25
}
26
27
enum OzzieCoin {
28
  fifty(50), twenty(20), ten(10), five(5)
29
  OzzieCoin(v) { value = v }
30
  final value
31
}
32

MIME types defined: text/x-groovy