-
-
Save masanobuimai/619292 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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