kwalify 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. data/CHANGES.txt +232 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.txt +16 -19
  4. data/bin/kwalify +3 -3
  5. data/contrib/inline-require +6 -4
  6. data/contrib/kwalify +3719 -2427
  7. data/doc-api/classes/CommandOptionError.html +17 -17
  8. data/doc-api/classes/CommandOptionParser.html +63 -63
  9. data/doc-api/classes/Kwalify.html +29 -7
  10. data/doc-api/classes/Kwalify/AssertionError.html +9 -9
  11. data/doc-api/classes/Kwalify/BaseError.html +72 -71
  12. data/doc-api/classes/Kwalify/BaseParser.html +461 -0
  13. data/doc-api/classes/Kwalify/CommandOptionError.html +11 -11
  14. data/doc-api/classes/Kwalify/ErrorHelper.html +51 -46
  15. data/doc-api/classes/Kwalify/HashInterface.html +13 -135
  16. data/doc-api/classes/Kwalify/Json.html +105 -0
  17. data/doc-api/classes/Kwalify/Main.html +129 -126
  18. data/doc-api/classes/Kwalify/MetaValidator.html +248 -232
  19. data/doc-api/classes/Kwalify/Parser.html +12 -12
  20. data/doc-api/classes/Kwalify/PlainYamlParser.html +166 -163
  21. data/doc-api/classes/Kwalify/PlainYamlParser/Alias.html +11 -11
  22. data/doc-api/classes/Kwalify/Rule.html +152 -130
  23. data/doc-api/classes/Kwalify/SchemaError.html +10 -10
  24. data/doc-api/classes/Kwalify/SyntaxError.html +185 -0
  25. data/doc-api/classes/Kwalify/Types.html +26 -25
  26. data/doc-api/classes/Kwalify/Util.html +389 -0
  27. data/doc-api/classes/Kwalify/Util/HashLike.html +246 -0
  28. data/doc-api/classes/Kwalify/Util/OrderedHash.html +330 -0
  29. data/doc-api/classes/Kwalify/ValidationError.html +10 -10
  30. data/doc-api/classes/Kwalify/Validator.html +153 -86
  31. data/doc-api/classes/Kwalify/Yaml.html +181 -0
  32. data/doc-api/classes/Kwalify/Yaml/Parser.html +1538 -0
  33. data/doc-api/classes/Kwalify/YamlParser.html +190 -183
  34. data/doc-api/classes/Kwalify/YamlSyntaxError.html +8 -57
  35. data/doc-api/created.rid +1 -1
  36. data/doc-api/files/__/README_txt.html +17 -22
  37. data/doc-api/files/kwalify/errors_rb.html +2 -2
  38. data/doc-api/files/kwalify/main_rb.html +4 -3
  39. data/doc-api/files/kwalify/messages_rb.html +2 -2
  40. data/doc-api/files/kwalify/meta-validator_rb.html +3 -3
  41. data/doc-api/files/kwalify/{util/yaml-helper_rb.html → parser/base_rb.html} +8 -6
  42. data/doc-api/files/kwalify/parser/yaml_rb.html +117 -0
  43. data/doc-api/files/kwalify/rule_rb.html +2 -2
  44. data/doc-api/files/kwalify/types_rb.html +2 -2
  45. data/doc-api/files/kwalify/util/assert-text-equal_rb.html +2 -2
  46. data/doc-api/files/kwalify/util/hash-interface_rb.html +9 -2
  47. data/doc-api/files/kwalify/util/hashlike_rb.html +107 -0
  48. data/doc-api/files/kwalify/util/option-parser_rb.html +2 -2
  49. data/doc-api/files/kwalify/util/ordered-hash_rb.html +107 -0
  50. data/doc-api/files/kwalify/util/testcase-helper_rb.html +2 -2
  51. data/doc-api/files/kwalify/util_rb.html +107 -0
  52. data/doc-api/files/kwalify/validator_rb.html +2 -2
  53. data/doc-api/files/kwalify/yaml-parser_rb.html +2 -2
  54. data/doc-api/files/kwalify_rb.html +3 -2
  55. data/doc-api/fr_class_index.html +8 -1
  56. data/doc-api/fr_file_index.html +5 -1
  57. data/doc-api/fr_method_index.html +128 -69
  58. data/doc/img/fig01.png +0 -0
  59. data/doc/users-guide.html +882 -717
  60. data/examples/address-book/address-book.schema.yaml +2 -2
  61. data/examples/data-binding/BABEL.data.yaml +63 -0
  62. data/examples/data-binding/BABEL.schema.yaml +31 -0
  63. data/examples/data-binding/Makefile +8 -0
  64. data/examples/data-binding/Rakefile +13 -0
  65. data/examples/data-binding/main.rb +27 -0
  66. data/examples/invoice/invoice.schema.yaml +3 -3
  67. data/examples/tapkit/tapkit.schema.yaml +2 -2
  68. data/lib/kwalify.rb +41 -4
  69. data/lib/kwalify/errors.rb +118 -96
  70. data/lib/kwalify/kwalify.schema.yaml +58 -0
  71. data/lib/kwalify/main.rb +384 -377
  72. data/lib/kwalify/messages.rb +41 -27
  73. data/lib/kwalify/meta-validator.rb +251 -331
  74. data/lib/kwalify/parser/base.rb +127 -0
  75. data/lib/kwalify/parser/yaml.rb +837 -0
  76. data/lib/kwalify/rule.rb +545 -487
  77. data/lib/kwalify/templates/genclass-java.eruby +189 -162
  78. data/lib/kwalify/templates/genclass-php.eruby +104 -0
  79. data/lib/kwalify/templates/genclass-ruby.eruby +95 -66
  80. data/lib/kwalify/types.rb +107 -106
  81. data/lib/kwalify/util.rb +157 -0
  82. data/lib/kwalify/util/assert-text-equal.rb +33 -31
  83. data/lib/kwalify/util/hash-interface.rb +11 -30
  84. data/lib/kwalify/util/hashlike.rb +51 -0
  85. data/lib/kwalify/util/option-parser.rb +144 -144
  86. data/lib/kwalify/util/ordered-hash.rb +57 -0
  87. data/lib/kwalify/util/testcase-helper.rb +3 -3
  88. data/lib/kwalify/validator.rb +267 -212
  89. data/lib/kwalify/yaml-parser.rb +822 -768
  90. data/setup.rb +861 -607
  91. data/test/Rookbook.yaml +10 -0
  92. data/test/{tmp.dir/Context.java → data/users-guide/AddressBook.java.expected} +11 -11
  93. data/test/data/users-guide/BABEL.data.yaml +24 -0
  94. data/test/data/users-guide/BABEL.schema.yaml +30 -0
  95. data/test/data/users-guide/ExampleAddressBook.java +47 -0
  96. data/test/{tmp.dir/Group.java → data/users-guide/Group.java.expected} +2 -11
  97. data/test/data/users-guide/Person.java.expected +44 -0
  98. data/test/data/users-guide/address_book.rb +52 -0
  99. data/test/data/users-guide/address_book.schema.yaml +28 -0
  100. data/test/data/users-guide/address_book.yaml +27 -0
  101. data/test/data/users-guide/answers-schema.yaml +12 -0
  102. data/test/data/users-guide/answers-validator.rb +52 -0
  103. data/test/data/users-guide/babel_genclass.result +26 -0
  104. data/test/data/users-guide/config.schema.yaml +7 -0
  105. data/test/data/users-guide/config.yaml +4 -0
  106. data/test/{tmp.dir/silent1.document → data/users-guide/document01a.yaml} +0 -0
  107. data/test/data/users-guide/document01b.yaml +3 -0
  108. data/test/data/users-guide/document02a.yaml +4 -0
  109. data/test/data/users-guide/document02b.yaml +4 -0
  110. data/test/data/users-guide/document03a.yaml +6 -0
  111. data/test/data/users-guide/document03b.yaml +6 -0
  112. data/test/data/users-guide/document04a.yaml +9 -0
  113. data/test/data/users-guide/document04b.yaml +9 -0
  114. data/test/data/users-guide/document05a.yaml +11 -0
  115. data/test/data/users-guide/document05b.yaml +12 -0
  116. data/test/data/users-guide/document06a.yaml +15 -0
  117. data/test/data/users-guide/document06b.yaml +16 -0
  118. data/test/data/users-guide/document07a.yaml +9 -0
  119. data/test/data/users-guide/document07b.yaml +7 -0
  120. data/test/data/users-guide/document12a.json +10 -0
  121. data/test/data/users-guide/document12b.json +6 -0
  122. data/test/data/users-guide/document13a.yaml +17 -0
  123. data/test/data/users-guide/document14a.yaml +3 -0
  124. data/test/data/users-guide/document14b.yaml +3 -0
  125. data/test/data/users-guide/document15a.yaml +6 -0
  126. data/test/data/users-guide/document15b.yaml +5 -0
  127. data/test/data/users-guide/example_address_book.rb +10 -0
  128. data/test/data/users-guide/example_address_book_java.result +32 -0
  129. data/test/data/users-guide/example_address_book_ruby.result +31 -0
  130. data/test/data/users-guide/genclass_java.result +4 -0
  131. data/test/data/users-guide/howto-validation-with-parsing.rb +28 -0
  132. data/test/data/users-guide/howto-validation.rb +25 -0
  133. data/test/data/users-guide/howto3.rb +6 -0
  134. data/test/data/users-guide/howto3.result +5 -0
  135. data/test/data/users-guide/howto3.yaml +8 -0
  136. data/test/data/users-guide/howto5_databinding.result +111 -0
  137. data/test/data/users-guide/invalid01.result +3 -0
  138. data/test/data/users-guide/invalid02.result +5 -0
  139. data/test/data/users-guide/invalid03.result +5 -0
  140. data/test/data/users-guide/invalid04.result +4 -0
  141. data/test/data/users-guide/invalid05.result +11 -0
  142. data/test/data/users-guide/invalid06.result +4 -0
  143. data/test/data/users-guide/invalid07.result +3 -0
  144. data/test/data/users-guide/invalid08.result +3 -0
  145. data/test/data/users-guide/invalid12.json +8 -0
  146. data/test/data/users-guide/invalid14.result +4 -0
  147. data/test/data/users-guide/invalid15.result +4 -0
  148. data/test/data/users-guide/loadbabel.rb +27 -0
  149. data/test/data/users-guide/loadconfig.rb +15 -0
  150. data/test/data/users-guide/loadconfig.result +2 -0
  151. data/test/data/users-guide/models.rb +22 -0
  152. data/test/data/users-guide/option_ha.result +6 -0
  153. data/test/data/users-guide/option_ha_genclass_java.result +7 -0
  154. data/test/{tmp.dir/meta1.schema → data/users-guide/schema01.yaml} +0 -0
  155. data/test/data/users-guide/schema02.yaml +12 -0
  156. data/test/data/users-guide/schema03.yaml +9 -0
  157. data/test/data/users-guide/schema04.yaml +20 -0
  158. data/test/data/users-guide/schema05.yaml +29 -0
  159. data/test/data/users-guide/schema06.yaml +11 -0
  160. data/test/data/users-guide/schema12.json +12 -0
  161. data/test/data/users-guide/schema13.yaml +13 -0
  162. data/test/data/users-guide/schema14.yaml +5 -0
  163. data/test/data/users-guide/schema15.yaml +21 -0
  164. data/test/data/users-guide/valid01.result +2 -0
  165. data/test/data/users-guide/valid02.result +2 -0
  166. data/test/data/users-guide/valid03.result +2 -0
  167. data/test/data/users-guide/valid04.result +2 -0
  168. data/test/data/users-guide/valid05.result +2 -0
  169. data/test/data/users-guide/valid06.result +2 -0
  170. data/test/data/users-guide/valid07.result +2 -0
  171. data/test/data/users-guide/valid08.result +2 -0
  172. data/test/data/users-guide/valid12.result +2 -0
  173. data/test/data/users-guide/valid13.result +2 -0
  174. data/test/data/users-guide/valid14.result +2 -0
  175. data/test/data/users-guide/valid15.result +2 -0
  176. data/test/data/users-guide/validate08.rb +37 -0
  177. data/test/test-action.rb +78 -0
  178. data/test/test-action.yaml +738 -0
  179. data/test/test-databinding.rb +80 -0
  180. data/test/test-databinding.yaml +301 -0
  181. data/test/test-main.rb +129 -150
  182. data/test/test-main.yaml +126 -321
  183. data/test/test-metavalidator.rb +47 -47
  184. data/test/test-metavalidator.yaml +77 -21
  185. data/test/test-parser-yaml.rb +57 -0
  186. data/test/test-parser-yaml.yaml +1749 -0
  187. data/test/test-rule.rb +14 -15
  188. data/test/test-rule.yaml +6 -3
  189. data/test/test-users-guide.rb +75 -0
  190. data/test/test-validator.rb +77 -52
  191. data/test/test-validator.yaml +168 -6
  192. data/test/test-yaml-parser.rb +47 -0
  193. data/test/{test-yamlparser.yaml → test-yaml-parser.yaml} +159 -52
  194. data/test/test.rb +37 -21
  195. metadata +136 -37
  196. data/COPYING +0 -340
  197. data/ChangeLog +0 -70
  198. data/doc-api/classes/YamlHelper.html +0 -259
  199. data/lib/kwalify/util/yaml-helper.rb +0 -82
  200. data/test/test-yamlparser.rb +0 -58
  201. data/test/tmp.dir/User.java +0 -43
  202. data/test/tmp.dir/action1.document +0 -18
  203. data/test/tmp.dir/action1.schema +0 -32
  204. data/test/tmp.dir/action2.document +0 -18
  205. data/test/tmp.dir/action2.schema +0 -32
  206. data/test/tmp.dir/emacs.document +0 -6
  207. data/test/tmp.dir/emacs.schema +0 -6
  208. data/test/tmp.dir/meta1.document +0 -0
  209. data/test/tmp.dir/meta2.document +0 -0
  210. data/test/tmp.dir/meta2.schema +0 -3
  211. data/test/tmp.dir/silent1.schema +0 -3
  212. data/test/tmp.dir/silent2.document +0 -7
  213. data/test/tmp.dir/silent2.schema +0 -3
  214. data/test/tmp.dir/stream.invalid +0 -8
  215. data/test/tmp.dir/stream.schema +0 -3
  216. data/test/tmp.dir/stream.valid +0 -8
  217. data/test/tmp.dir/untabify.document +0 -5
  218. data/test/tmp.dir/untabify.schema +0 -10
  219. data/todo.txt +0 -34
@@ -0,0 +1,7 @@
1
+ type: map
2
+ class: Config
3
+ mapping:
4
+ "host": { type: str, required: true }
5
+ "port": { type: int }
6
+ "user": { type: str, required: true }
7
+ "pass": { type: str, required: true }
@@ -0,0 +1,4 @@
1
+ host: localhost
2
+ port: 8080
3
+ user: user1
4
+ pass: password1
@@ -0,0 +1,3 @@
1
+ - foo
2
+ - 123
3
+ - baz
@@ -0,0 +1,4 @@
1
+ name: foo
2
+ email: foo@mail.com
3
+ age: 20
4
+ birth: 1985-01-01
@@ -0,0 +1,4 @@
1
+ name: foo
2
+ email: foo(at)mail.com
3
+ age: twenty
4
+ birth: Jun 01, 1985
@@ -0,0 +1,6 @@
1
+ - name: foo
2
+ email: foo@mail.com
3
+ - name: bar
4
+ email: bar@mail.net
5
+ - name: baz
6
+ email: baz@mail.org
@@ -0,0 +1,6 @@
1
+ - name: foo
2
+ email: foo@mail.com
3
+ - naem: bar
4
+ email: bar@mail.net
5
+ - name: baz
6
+ mail: baz@mail.org
@@ -0,0 +1,9 @@
1
+ company: Kuwata lab.
2
+ email: webmaster@kuwata-lab.com
3
+ employees:
4
+ - code: 101
5
+ name: foo
6
+ email: foo@kuwata-lab.com
7
+ - code: 102
8
+ name: bar
9
+ email: bar@kuwata-lab.com
@@ -0,0 +1,9 @@
1
+ company: Kuwata Lab.
2
+ email: webmaster@kuwata-lab.com
3
+ employees:
4
+ - code: A101
5
+ name: foo
6
+ email: foo@kuwata-lab.com
7
+ - code: 102
8
+ name: bar
9
+ mail: bar@kuwata-lab.com
@@ -0,0 +1,11 @@
1
+ - name: foo
2
+ email: foo@mail.com
3
+ password: xxx123456
4
+ age: 20
5
+ blood: A
6
+ birth: 1985-01-01
7
+ - name: bar
8
+ email: bar@mail.net
9
+ age: 25
10
+ blood: AB
11
+ birth: 1980-01-01
@@ -0,0 +1,12 @@
1
+ - name: foo
2
+ email: foo(at)mail.com
3
+ password: xxx123
4
+ age: twenty
5
+ blood: a
6
+ birth: 1985-01-01
7
+ - given-name: bar
8
+ family-name: Bar
9
+ email: bar@mail.net
10
+ age: 15
11
+ blood: AB
12
+ birth: 1980/01/01
@@ -0,0 +1,15 @@
1
+ - name: foo
2
+ email: admin@mail.com
3
+ groups:
4
+ - users
5
+ - foo
6
+ - admin
7
+ - name: bar
8
+ email: admin@mail.com
9
+ groups:
10
+ - users
11
+ - admin
12
+ - name: baz
13
+ email: baz@mail.com
14
+ groups:
15
+ - users
@@ -0,0 +1,16 @@
1
+ - name: foo
2
+ email: admin@mail.com
3
+ groups:
4
+ - foo
5
+ - users
6
+ - admin
7
+ - foo
8
+ - name: bar
9
+ email: admin@mail.com
10
+ groups:
11
+ - admin
12
+ - users
13
+ - name: bar
14
+ email: baz@mail.com
15
+ groups:
16
+ - users
@@ -0,0 +1,9 @@
1
+ answers:
2
+ - name: Foo
3
+ answer: good
4
+ reason: I like this style.
5
+ - name: Bar
6
+ answer: not bad
7
+ - name: Baz
8
+ answer: bad
9
+ reason: I don't like this style.
@@ -0,0 +1,7 @@
1
+ answers:
2
+ - name: Foo
3
+ answer: good
4
+ - name: Bar
5
+ answer: bad
6
+ - name: Baz
7
+ answer: not bad
@@ -0,0 +1,10 @@
1
+ { "name": "Foo",
2
+ "email": "foo@mail.com",
3
+ "age": 20,
4
+ "gender": "F",
5
+ "favorite": [
6
+ "football",
7
+ "basketball",
8
+ "baseball"
9
+ ]
10
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "mail": "foo@mail.com",
3
+ "age": twenty,
4
+ "gender": "X",
5
+ "favorite": [ 123, 456 ]
6
+ }
@@ -0,0 +1,17 @@
1
+ - &foo
2
+ given-name: foo
3
+ family-name: Foo
4
+ post: exective
5
+ - &bar
6
+ given-name: bar
7
+ family-name: Bar
8
+ post: manager
9
+ supervisor: *foo
10
+ - given-name: baz
11
+ family-name: Baz
12
+ post: clerk
13
+ supervisor: *bar
14
+ - given-name: zak
15
+ family-name: Zak
16
+ post: clerk
17
+ supervisor: *bar
@@ -0,0 +1,3 @@
1
+ value1: 0
2
+ value2: 0.5
3
+ value3: -0.9
@@ -0,0 +1,3 @@
1
+ value1: 0
2
+ value2: 1.1
3
+ value3: -2.0
@@ -0,0 +1,6 @@
1
+ group:
2
+ name: foo
3
+ email: foo@mail.com
4
+ user:
5
+ name: bar
6
+ email: bar@mail.com
@@ -0,0 +1,5 @@
1
+ group:
2
+ name: foo
3
+ email: foo@mail.com
4
+ user:
5
+ name: toooooo-looooong-name
@@ -0,0 +1,10 @@
1
+ require 'address_book'
2
+ require 'yaml'
3
+ require 'pp'
4
+
5
+ str = File.read('address_book.yaml')
6
+ ydoc = YAML.load(str)
7
+ addrbook = AddressBook.new(ydoc)
8
+
9
+ pp addrbook.groups
10
+ pp addrbook.people
@@ -0,0 +1,32 @@
1
+ $ javac -classpath '.:kwalify.jar' *.java
2
+ $ java -classpath '.:kwalify.jar' ExampleAddressBook
3
+ group name: family
4
+ group desc: my family
5
+
6
+ group name: friend
7
+ group desc: my friends
8
+
9
+ group name: business
10
+ group desc: those who works together
11
+
12
+ person name: Sumire
13
+ person group: family
14
+ person email: null
15
+ person phone: null
16
+ person blood: A
17
+ person birth: Tue Feb 01 00:00:00 JST 2000
18
+
19
+ person name: Shiina
20
+ person group: friend
21
+ person email: shiina@mail.org
22
+ person phone: null
23
+ person blood: null
24
+ person birth: Wed Feb 01 00:00:00 JST 1995
25
+
26
+ person name: Sakura
27
+ person group: business
28
+ person email: cherry@mail.net
29
+ person phone: 012-345-6789
30
+ person blood: null
31
+ person birth: null
32
+
@@ -0,0 +1,31 @@
1
+ $ ruby example_address_book.rb
2
+ [#<Group:0xddf24 @desc="my family", @name="family">,
3
+ #<Group:0xddf10 @desc="my friends", @name="friend">,
4
+ #<Group:0xdde84 @desc="those who works together", @name="business">]
5
+ [#<Person:0xdefdc
6
+ @birth=#<Date: 4903089/2,0,2299161>,
7
+ @blood="A",
8
+ @deleted=false,
9
+ @desc=nil,
10
+ @email=nil,
11
+ @group="family",
12
+ @name="Sumire",
13
+ @phone=nil>,
14
+ #<Person:0xdee9c
15
+ @birth=#<Date: 4899437/2,0,2299161>,
16
+ @blood=nil,
17
+ @deleted=false,
18
+ @desc=nil,
19
+ @email="shiina@mail.org",
20
+ @group="friend",
21
+ @name="Shiina",
22
+ @phone=nil>,
23
+ #<Person:0xde8e8
24
+ @birth=nil,
25
+ @blood=nil,
26
+ @deleted=false,
27
+ @desc=nil,
28
+ @email="cherry@mail.net",
29
+ @group="business",
30
+ @name="Sakura",
31
+ @phone="012-345-6789">]
@@ -0,0 +1,4 @@
1
+ $ kwalify -a genclass-java -tf address_book.schema.yaml
2
+ generating ./AddressBook.java...done.
3
+ generating ./Group.java...done.
4
+ generating ./Person.java...done.
@@ -0,0 +1,28 @@
1
+ require 'kwalify'
2
+ #require 'yaml'
3
+
4
+ ## load schema data
5
+ schema = Kwalify::Yaml.load_file('schema.yaml')
6
+ ## or
7
+ #schema = YAML.load_file('schema.yaml')
8
+
9
+ ## create validator
10
+ validator = Kwalify::Validator.new(schema)
11
+
12
+ ## create parser with validator
13
+ ## (if validator is ommitted, no validation executed.)
14
+ parser = Kwalify:::Yaml::Parser.new(validator)
15
+
16
+ ## parse document with validation
17
+ filename = 'document.yaml'
18
+ document = parser.parse_file(filename)
19
+ ## or
20
+ #document = parser.parse(File.read(filename), filename)
21
+
22
+ ## show errors if exist
23
+ errors = parser.errors()
24
+ if errors && !errors.empty?
25
+ for e in errors
26
+ puts "#{e.linenum}:#{e.column} [#{e.path}] #{e.message}"
27
+ end
28
+ end
@@ -0,0 +1,25 @@
1
+ require 'kwalify'
2
+ #require 'yaml'
3
+
4
+ ## load schema data
5
+ schema = Kwalify::Yaml.load_file('schema.yaml')
6
+ ## or
7
+ #schema = YAML.load_file('schema.yaml')
8
+
9
+ ## create validator
10
+ validator = Kwalify::Validator.new(schema)
11
+
12
+ ## load document
13
+ document = Kwalify::Yaml.load_file('document.yaml')
14
+ ## or
15
+ #document = YAML.load_file('document.yaml')
16
+
17
+ ## validate
18
+ errors = validator.validate(document)
19
+
20
+ ## show errors
21
+ if errors && !errors.empty?
22
+ for err in errors
23
+ puts "[#{err.path}] #{err.message}"
24
+ end
25
+ end
@@ -0,0 +1,6 @@
1
+ require 'kwalify'
2
+ parser = Kwalify::Yaml::Parser.new
3
+ parser.preceding_alias = true # enable preceding alias
4
+ ydoc = parser.parse_file('howto3.yaml')
5
+ require 'pp'
6
+ pp ydoc
@@ -0,0 +1,5 @@
1
+ $ ruby howto3.rb
2
+ [{"name"=>"Foo",
3
+ "parent"=>{"name"=>"Bar", "parent"=>{"name"=>"Baz", "parent"=>nil}}},
4
+ {"name"=>"Bar", "parent"=>{"name"=>"Baz", "parent"=>nil}},
5
+ {"name"=>"Baz", "parent"=>nil}]
@@ -0,0 +1,8 @@
1
+ - name: Foo
2
+ parent: *bar # preceding alias
3
+ - &bar
4
+ name: Bar
5
+ parent: *baz # preceding alias
6
+ - &baz
7
+ name: Baz
8
+ parent: null
@@ -0,0 +1,111 @@
1
+ $ ruby loadbabel.rb
2
+ {"teams"=>
3
+ [#<Babel::Team:0x53e0f8
4
+ @chief=
5
+ #<Babel::Member:0x53d5e0
6
+ @desc="Scientist",
7
+ @name="Kohichi Minamoto",
8
+ @team=#<Babel::Team:0x53e0f8 ...>>,
9
+ @desc="Level 7 ESPers",
10
+ @members=
11
+ [#<Babel::Member:0x53d018
12
+ @desc="Psychokino",
13
+ @name="Kaoru Akashi",
14
+ @team=#<Babel::Team:0x53e0f8 ...>>,
15
+ #<Babel::Member:0x53ca50
16
+ @desc="Teleporter",
17
+ @name="Aoi Nogami",
18
+ @team=#<Babel::Team:0x53e0f8 ...>>,
19
+ #<Babel::Member:0x53c488
20
+ @desc="Psycometrer",
21
+ @name="Shiho Sannomiya",
22
+ @team=#<Babel::Team:0x53e0f8 ...>>],
23
+ @name="The Children">],
24
+ "members"=>
25
+ [#<Babel::Member:0x53d5e0
26
+ @desc="Scientist",
27
+ @name="Kohichi Minamoto",
28
+ @team=
29
+ #<Babel::Team:0x53e0f8
30
+ @chief=#<Babel::Member:0x53d5e0 ...>,
31
+ @desc="Level 7 ESPers",
32
+ @members=
33
+ [#<Babel::Member:0x53d018
34
+ @desc="Psychokino",
35
+ @name="Kaoru Akashi",
36
+ @team=#<Babel::Team:0x53e0f8 ...>>,
37
+ #<Babel::Member:0x53ca50
38
+ @desc="Teleporter",
39
+ @name="Aoi Nogami",
40
+ @team=#<Babel::Team:0x53e0f8 ...>>,
41
+ #<Babel::Member:0x53c488
42
+ @desc="Psycometrer",
43
+ @name="Shiho Sannomiya",
44
+ @team=#<Babel::Team:0x53e0f8 ...>>],
45
+ @name="The Children">>,
46
+ #<Babel::Member:0x53d018
47
+ @desc="Psychokino",
48
+ @name="Kaoru Akashi",
49
+ @team=
50
+ #<Babel::Team:0x53e0f8
51
+ @chief=
52
+ #<Babel::Member:0x53d5e0
53
+ @desc="Scientist",
54
+ @name="Kohichi Minamoto",
55
+ @team=#<Babel::Team:0x53e0f8 ...>>,
56
+ @desc="Level 7 ESPers",
57
+ @members=
58
+ [#<Babel::Member:0x53d018 ...>,
59
+ #<Babel::Member:0x53ca50
60
+ @desc="Teleporter",
61
+ @name="Aoi Nogami",
62
+ @team=#<Babel::Team:0x53e0f8 ...>>,
63
+ #<Babel::Member:0x53c488
64
+ @desc="Psycometrer",
65
+ @name="Shiho Sannomiya",
66
+ @team=#<Babel::Team:0x53e0f8 ...>>],
67
+ @name="The Children">>,
68
+ #<Babel::Member:0x53ca50
69
+ @desc="Teleporter",
70
+ @name="Aoi Nogami",
71
+ @team=
72
+ #<Babel::Team:0x53e0f8
73
+ @chief=
74
+ #<Babel::Member:0x53d5e0
75
+ @desc="Scientist",
76
+ @name="Kohichi Minamoto",
77
+ @team=#<Babel::Team:0x53e0f8 ...>>,
78
+ @desc="Level 7 ESPers",
79
+ @members=
80
+ [#<Babel::Member:0x53d018
81
+ @desc="Psychokino",
82
+ @name="Kaoru Akashi",
83
+ @team=#<Babel::Team:0x53e0f8 ...>>,
84
+ #<Babel::Member:0x53ca50 ...>,
85
+ #<Babel::Member:0x53c488
86
+ @desc="Psycometrer",
87
+ @name="Shiho Sannomiya",
88
+ @team=#<Babel::Team:0x53e0f8 ...>>],
89
+ @name="The Children">>,
90
+ #<Babel::Member:0x53c488
91
+ @desc="Psycometrer",
92
+ @name="Shiho Sannomiya",
93
+ @team=
94
+ #<Babel::Team:0x53e0f8
95
+ @chief=
96
+ #<Babel::Member:0x53d5e0
97
+ @desc="Scientist",
98
+ @name="Kohichi Minamoto",
99
+ @team=#<Babel::Team:0x53e0f8 ...>>,
100
+ @desc="Level 7 ESPers",
101
+ @members=
102
+ [#<Babel::Member:0x53d018
103
+ @desc="Psychokino",
104
+ @name="Kaoru Akashi",
105
+ @team=#<Babel::Team:0x53e0f8 ...>>,
106
+ #<Babel::Member:0x53ca50
107
+ @desc="Teleporter",
108
+ @name="Aoi Nogami",
109
+ @team=#<Babel::Team:0x53e0f8 ...>>,
110
+ #<Babel::Member:0x53c488 ...>],
111
+ @name="The Children">>]}