Skip to content

Instantly share code, notes, and snippets.

@masanobuimai
Created October 10, 2010 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masanobuimai/619292 to your computer and use it in GitHub Desktop.
Save masanobuimai/619292 to your computer and use it in GitHub Desktop.
// g100pon #87 YAML
//
@Grab(group='net.java.dev', module='jvyaml', version='0.2.1')
import org.jvyaml.YAML
def yamlData = """
- title: なんとかのテストをする
node:
- title: ほげほげ
node:
- title: なんとかがなんとかでなんとかする
cond: これこれ,こうゆう条件だ。
expect: こうなってくれ。
- title: あれがこれでこうなる
cond: こうゆう条件だ。
expect: こうなるに違いない
- title: Foo Bar Boo
node:
- title: なんとかがなんとかでなんとかする
cond: これこれ,こうゆう条件だ。
expect: こうなってくれ。
- title: これもテストしないと
"""
// どうゆうワケか,File.newReader()だとYAMLがパースに失敗する
YAML.load(yamlData).eachWithIndex {
it, index ->
println "$index : $it.title"
it.node.eachWithIndex { n1, idx1 ->
println "$index-$idx1 : $n1.title"
n1.node.eachWithIndex { n2, idx2 ->
println "$index-$idx1-$idx2 : $n2.title"
println "$n2.cond"
println "$n2.expect"
println "----"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment