kwalify 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +232 -0
- data/MIT-LICENSE +20 -0
- data/README.txt +16 -19
- data/bin/kwalify +3 -3
- data/contrib/inline-require +6 -4
- data/contrib/kwalify +3719 -2427
- data/doc-api/classes/CommandOptionError.html +17 -17
- data/doc-api/classes/CommandOptionParser.html +63 -63
- data/doc-api/classes/Kwalify.html +29 -7
- data/doc-api/classes/Kwalify/AssertionError.html +9 -9
- data/doc-api/classes/Kwalify/BaseError.html +72 -71
- data/doc-api/classes/Kwalify/BaseParser.html +461 -0
- data/doc-api/classes/Kwalify/CommandOptionError.html +11 -11
- data/doc-api/classes/Kwalify/ErrorHelper.html +51 -46
- data/doc-api/classes/Kwalify/HashInterface.html +13 -135
- data/doc-api/classes/Kwalify/Json.html +105 -0
- data/doc-api/classes/Kwalify/Main.html +129 -126
- data/doc-api/classes/Kwalify/MetaValidator.html +248 -232
- data/doc-api/classes/Kwalify/Parser.html +12 -12
- data/doc-api/classes/Kwalify/PlainYamlParser.html +166 -163
- data/doc-api/classes/Kwalify/PlainYamlParser/Alias.html +11 -11
- data/doc-api/classes/Kwalify/Rule.html +152 -130
- data/doc-api/classes/Kwalify/SchemaError.html +10 -10
- data/doc-api/classes/Kwalify/SyntaxError.html +185 -0
- data/doc-api/classes/Kwalify/Types.html +26 -25
- data/doc-api/classes/Kwalify/Util.html +389 -0
- data/doc-api/classes/Kwalify/Util/HashLike.html +246 -0
- data/doc-api/classes/Kwalify/Util/OrderedHash.html +330 -0
- data/doc-api/classes/Kwalify/ValidationError.html +10 -10
- data/doc-api/classes/Kwalify/Validator.html +153 -86
- data/doc-api/classes/Kwalify/Yaml.html +181 -0
- data/doc-api/classes/Kwalify/Yaml/Parser.html +1538 -0
- data/doc-api/classes/Kwalify/YamlParser.html +190 -183
- data/doc-api/classes/Kwalify/YamlSyntaxError.html +8 -57
- data/doc-api/created.rid +1 -1
- data/doc-api/files/__/README_txt.html +17 -22
- data/doc-api/files/kwalify/errors_rb.html +2 -2
- data/doc-api/files/kwalify/main_rb.html +4 -3
- data/doc-api/files/kwalify/messages_rb.html +2 -2
- data/doc-api/files/kwalify/meta-validator_rb.html +3 -3
- data/doc-api/files/kwalify/{util/yaml-helper_rb.html → parser/base_rb.html} +8 -6
- data/doc-api/files/kwalify/parser/yaml_rb.html +117 -0
- data/doc-api/files/kwalify/rule_rb.html +2 -2
- data/doc-api/files/kwalify/types_rb.html +2 -2
- data/doc-api/files/kwalify/util/assert-text-equal_rb.html +2 -2
- data/doc-api/files/kwalify/util/hash-interface_rb.html +9 -2
- data/doc-api/files/kwalify/util/hashlike_rb.html +107 -0
- data/doc-api/files/kwalify/util/option-parser_rb.html +2 -2
- data/doc-api/files/kwalify/util/ordered-hash_rb.html +107 -0
- data/doc-api/files/kwalify/util/testcase-helper_rb.html +2 -2
- data/doc-api/files/kwalify/util_rb.html +107 -0
- data/doc-api/files/kwalify/validator_rb.html +2 -2
- data/doc-api/files/kwalify/yaml-parser_rb.html +2 -2
- data/doc-api/files/kwalify_rb.html +3 -2
- data/doc-api/fr_class_index.html +8 -1
- data/doc-api/fr_file_index.html +5 -1
- data/doc-api/fr_method_index.html +128 -69
- data/doc/img/fig01.png +0 -0
- data/doc/users-guide.html +882 -717
- data/examples/address-book/address-book.schema.yaml +2 -2
- data/examples/data-binding/BABEL.data.yaml +63 -0
- data/examples/data-binding/BABEL.schema.yaml +31 -0
- data/examples/data-binding/Makefile +8 -0
- data/examples/data-binding/Rakefile +13 -0
- data/examples/data-binding/main.rb +27 -0
- data/examples/invoice/invoice.schema.yaml +3 -3
- data/examples/tapkit/tapkit.schema.yaml +2 -2
- data/lib/kwalify.rb +41 -4
- data/lib/kwalify/errors.rb +118 -96
- data/lib/kwalify/kwalify.schema.yaml +58 -0
- data/lib/kwalify/main.rb +384 -377
- data/lib/kwalify/messages.rb +41 -27
- data/lib/kwalify/meta-validator.rb +251 -331
- data/lib/kwalify/parser/base.rb +127 -0
- data/lib/kwalify/parser/yaml.rb +837 -0
- data/lib/kwalify/rule.rb +545 -487
- data/lib/kwalify/templates/genclass-java.eruby +189 -162
- data/lib/kwalify/templates/genclass-php.eruby +104 -0
- data/lib/kwalify/templates/genclass-ruby.eruby +95 -66
- data/lib/kwalify/types.rb +107 -106
- data/lib/kwalify/util.rb +157 -0
- data/lib/kwalify/util/assert-text-equal.rb +33 -31
- data/lib/kwalify/util/hash-interface.rb +11 -30
- data/lib/kwalify/util/hashlike.rb +51 -0
- data/lib/kwalify/util/option-parser.rb +144 -144
- data/lib/kwalify/util/ordered-hash.rb +57 -0
- data/lib/kwalify/util/testcase-helper.rb +3 -3
- data/lib/kwalify/validator.rb +267 -212
- data/lib/kwalify/yaml-parser.rb +822 -768
- data/setup.rb +861 -607
- data/test/Rookbook.yaml +10 -0
- data/test/{tmp.dir/Context.java → data/users-guide/AddressBook.java.expected} +11 -11
- data/test/data/users-guide/BABEL.data.yaml +24 -0
- data/test/data/users-guide/BABEL.schema.yaml +30 -0
- data/test/data/users-guide/ExampleAddressBook.java +47 -0
- data/test/{tmp.dir/Group.java → data/users-guide/Group.java.expected} +2 -11
- data/test/data/users-guide/Person.java.expected +44 -0
- data/test/data/users-guide/address_book.rb +52 -0
- data/test/data/users-guide/address_book.schema.yaml +28 -0
- data/test/data/users-guide/address_book.yaml +27 -0
- data/test/data/users-guide/answers-schema.yaml +12 -0
- data/test/data/users-guide/answers-validator.rb +52 -0
- data/test/data/users-guide/babel_genclass.result +26 -0
- data/test/data/users-guide/config.schema.yaml +7 -0
- data/test/data/users-guide/config.yaml +4 -0
- data/test/{tmp.dir/silent1.document → data/users-guide/document01a.yaml} +0 -0
- data/test/data/users-guide/document01b.yaml +3 -0
- data/test/data/users-guide/document02a.yaml +4 -0
- data/test/data/users-guide/document02b.yaml +4 -0
- data/test/data/users-guide/document03a.yaml +6 -0
- data/test/data/users-guide/document03b.yaml +6 -0
- data/test/data/users-guide/document04a.yaml +9 -0
- data/test/data/users-guide/document04b.yaml +9 -0
- data/test/data/users-guide/document05a.yaml +11 -0
- data/test/data/users-guide/document05b.yaml +12 -0
- data/test/data/users-guide/document06a.yaml +15 -0
- data/test/data/users-guide/document06b.yaml +16 -0
- data/test/data/users-guide/document07a.yaml +9 -0
- data/test/data/users-guide/document07b.yaml +7 -0
- data/test/data/users-guide/document12a.json +10 -0
- data/test/data/users-guide/document12b.json +6 -0
- data/test/data/users-guide/document13a.yaml +17 -0
- data/test/data/users-guide/document14a.yaml +3 -0
- data/test/data/users-guide/document14b.yaml +3 -0
- data/test/data/users-guide/document15a.yaml +6 -0
- data/test/data/users-guide/document15b.yaml +5 -0
- data/test/data/users-guide/example_address_book.rb +10 -0
- data/test/data/users-guide/example_address_book_java.result +32 -0
- data/test/data/users-guide/example_address_book_ruby.result +31 -0
- data/test/data/users-guide/genclass_java.result +4 -0
- data/test/data/users-guide/howto-validation-with-parsing.rb +28 -0
- data/test/data/users-guide/howto-validation.rb +25 -0
- data/test/data/users-guide/howto3.rb +6 -0
- data/test/data/users-guide/howto3.result +5 -0
- data/test/data/users-guide/howto3.yaml +8 -0
- data/test/data/users-guide/howto5_databinding.result +111 -0
- data/test/data/users-guide/invalid01.result +3 -0
- data/test/data/users-guide/invalid02.result +5 -0
- data/test/data/users-guide/invalid03.result +5 -0
- data/test/data/users-guide/invalid04.result +4 -0
- data/test/data/users-guide/invalid05.result +11 -0
- data/test/data/users-guide/invalid06.result +4 -0
- data/test/data/users-guide/invalid07.result +3 -0
- data/test/data/users-guide/invalid08.result +3 -0
- data/test/data/users-guide/invalid12.json +8 -0
- data/test/data/users-guide/invalid14.result +4 -0
- data/test/data/users-guide/invalid15.result +4 -0
- data/test/data/users-guide/loadbabel.rb +27 -0
- data/test/data/users-guide/loadconfig.rb +15 -0
- data/test/data/users-guide/loadconfig.result +2 -0
- data/test/data/users-guide/models.rb +22 -0
- data/test/data/users-guide/option_ha.result +6 -0
- data/test/data/users-guide/option_ha_genclass_java.result +7 -0
- data/test/{tmp.dir/meta1.schema → data/users-guide/schema01.yaml} +0 -0
- data/test/data/users-guide/schema02.yaml +12 -0
- data/test/data/users-guide/schema03.yaml +9 -0
- data/test/data/users-guide/schema04.yaml +20 -0
- data/test/data/users-guide/schema05.yaml +29 -0
- data/test/data/users-guide/schema06.yaml +11 -0
- data/test/data/users-guide/schema12.json +12 -0
- data/test/data/users-guide/schema13.yaml +13 -0
- data/test/data/users-guide/schema14.yaml +5 -0
- data/test/data/users-guide/schema15.yaml +21 -0
- data/test/data/users-guide/valid01.result +2 -0
- data/test/data/users-guide/valid02.result +2 -0
- data/test/data/users-guide/valid03.result +2 -0
- data/test/data/users-guide/valid04.result +2 -0
- data/test/data/users-guide/valid05.result +2 -0
- data/test/data/users-guide/valid06.result +2 -0
- data/test/data/users-guide/valid07.result +2 -0
- data/test/data/users-guide/valid08.result +2 -0
- data/test/data/users-guide/valid12.result +2 -0
- data/test/data/users-guide/valid13.result +2 -0
- data/test/data/users-guide/valid14.result +2 -0
- data/test/data/users-guide/valid15.result +2 -0
- data/test/data/users-guide/validate08.rb +37 -0
- data/test/test-action.rb +78 -0
- data/test/test-action.yaml +738 -0
- data/test/test-databinding.rb +80 -0
- data/test/test-databinding.yaml +301 -0
- data/test/test-main.rb +129 -150
- data/test/test-main.yaml +126 -321
- data/test/test-metavalidator.rb +47 -47
- data/test/test-metavalidator.yaml +77 -21
- data/test/test-parser-yaml.rb +57 -0
- data/test/test-parser-yaml.yaml +1749 -0
- data/test/test-rule.rb +14 -15
- data/test/test-rule.yaml +6 -3
- data/test/test-users-guide.rb +75 -0
- data/test/test-validator.rb +77 -52
- data/test/test-validator.yaml +168 -6
- data/test/test-yaml-parser.rb +47 -0
- data/test/{test-yamlparser.yaml → test-yaml-parser.yaml} +159 -52
- data/test/test.rb +37 -21
- metadata +136 -37
- data/COPYING +0 -340
- data/ChangeLog +0 -70
- data/doc-api/classes/YamlHelper.html +0 -259
- data/lib/kwalify/util/yaml-helper.rb +0 -82
- data/test/test-yamlparser.rb +0 -58
- data/test/tmp.dir/User.java +0 -43
- data/test/tmp.dir/action1.document +0 -18
- data/test/tmp.dir/action1.schema +0 -32
- data/test/tmp.dir/action2.document +0 -18
- data/test/tmp.dir/action2.schema +0 -32
- data/test/tmp.dir/emacs.document +0 -6
- data/test/tmp.dir/emacs.schema +0 -6
- data/test/tmp.dir/meta1.document +0 -0
- data/test/tmp.dir/meta2.document +0 -0
- data/test/tmp.dir/meta2.schema +0 -3
- data/test/tmp.dir/silent1.schema +0 -3
- data/test/tmp.dir/silent2.document +0 -7
- data/test/tmp.dir/silent2.schema +0 -3
- data/test/tmp.dir/stream.invalid +0 -8
- data/test/tmp.dir/stream.schema +0 -3
- data/test/tmp.dir/stream.valid +0 -8
- data/test/tmp.dir/untabify.document +0 -5
- data/test/tmp.dir/untabify.schema +0 -10
- data/todo.txt +0 -34
@@ -88,7 +88,7 @@
|
|
88
88
|
<h3 class="section-bar">Methods</h3>
|
89
89
|
|
90
90
|
<div class="name-list">
|
91
|
-
<a href="#
|
91
|
+
<a href="#M000126">new</a>
|
92
92
|
</div>
|
93
93
|
</div>
|
94
94
|
|
@@ -110,24 +110,24 @@
|
|
110
110
|
<div id="methods">
|
111
111
|
<h3 class="section-bar">Public Class methods</h3>
|
112
112
|
|
113
|
-
<div id="method-
|
114
|
-
<a name="
|
113
|
+
<div id="method-M000126" class="method-detail">
|
114
|
+
<a name="M000126"></a>
|
115
115
|
|
116
116
|
<div class="method-heading">
|
117
|
-
<a href="#
|
117
|
+
<a href="#M000126" class="method-signature">
|
118
118
|
<span class="method-name">new</span><span class="method-args">(message="", path=nil, rule=nil, value=nil, error_symbol=nil)</span>
|
119
119
|
</a>
|
120
120
|
</div>
|
121
121
|
|
122
122
|
<div class="method-description">
|
123
123
|
<p><a class="source-toggle" href="#"
|
124
|
-
onclick="toggleCode('
|
125
|
-
<div class="method-source-code" id="
|
124
|
+
onclick="toggleCode('M000126-source');return false;">[Source]</a></p>
|
125
|
+
<div class="method-source-code" id="M000126-source">
|
126
126
|
<pre>
|
127
|
-
<span class="ruby-comment cmt"># File kwalify/errors.rb, line
|
128
|
-
|
129
|
-
|
130
|
-
|
127
|
+
<span class="ruby-comment cmt"># File kwalify/errors.rb, line 68</span>
|
128
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">message</span>=<span class="ruby-value str">""</span>, <span class="ruby-identifier">path</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">rule</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">value</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">error_symbol</span>=<span class="ruby-keyword kw">nil</span>)
|
129
|
+
<span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">message</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">error_symbol</span>)
|
130
|
+
<span class="ruby-keyword kw">end</span>
|
131
131
|
</pre>
|
132
132
|
</div>
|
133
133
|
</div>
|
@@ -80,16 +80,34 @@
|
|
80
80
|
|
81
81
|
<div id="description">
|
82
82
|
<p>
|
83
|
-
|
83
|
+
<a href="Validator.html#M000076">validate</a> YAML document
|
84
|
+
</p>
|
85
|
+
<p>
|
86
|
+
ex1. <a href="Validator.html#M000076">validate</a> yaml document
|
84
87
|
</p>
|
85
88
|
<pre>
|
86
89
|
schema = YAML.load_file('schema.yaml')
|
87
90
|
validator = Kwalify::Validator.new(schema)
|
88
91
|
document = YAML.load_file('document.yaml')
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
puts "- [#{
|
92
|
+
erros = validator.validate(document)
|
93
|
+
if errors && !errors.empty?
|
94
|
+
errors.each do |err|
|
95
|
+
puts "- [#{err.path}] #{err.message}"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
</pre>
|
99
|
+
<p>
|
100
|
+
ex2. <a href="Validator.html#M000076">validate</a> with parsing
|
101
|
+
</p>
|
102
|
+
<pre>
|
103
|
+
schema = YAML.load_file('schema.yaml')
|
104
|
+
validator = Kwalify::Validator.new(schema)
|
105
|
+
parser = Kwalify::Yaml::Parser.new(validator)
|
106
|
+
document = parser.parse(File.read('document.yaml'))
|
107
|
+
errors = parser.errors
|
108
|
+
if errors && errors.empty?
|
109
|
+
errors.each do |e|
|
110
|
+
puts "#{e.linenum}:#{e.column} [#{e.path}] #{e.message}"
|
93
111
|
end
|
94
112
|
end
|
95
113
|
</pre>
|
@@ -103,11 +121,12 @@ ex.
|
|
103
121
|
<h3 class="section-bar">Methods</h3>
|
104
122
|
|
105
123
|
<div class="name-list">
|
106
|
-
<a href="#
|
107
|
-
<a href="#
|
108
|
-
<a href="#
|
109
|
-
<a href="#
|
110
|
-
<a href="#
|
124
|
+
<a href="#M000075">_inspect</a>
|
125
|
+
<a href="#M000078">_validate</a>
|
126
|
+
<a href="#M000079">_validate_unique</a>
|
127
|
+
<a href="#M000074">new</a>
|
128
|
+
<a href="#M000076">validate</a>
|
129
|
+
<a href="#M000077">validate_hook</a>
|
111
130
|
</div>
|
112
131
|
</div>
|
113
132
|
|
@@ -149,25 +168,26 @@ ex.
|
|
149
168
|
<div id="methods">
|
150
169
|
<h3 class="section-bar">Public Class methods</h3>
|
151
170
|
|
152
|
-
<div id="method-
|
153
|
-
<a name="
|
171
|
+
<div id="method-M000074" class="method-detail">
|
172
|
+
<a name="M000074"></a>
|
154
173
|
|
155
174
|
<div class="method-heading">
|
156
|
-
<a href="#
|
157
|
-
<span class="method-name">new</span><span class="method-args">(
|
175
|
+
<a href="#M000074" class="method-signature">
|
176
|
+
<span class="method-name">new</span><span class="method-args">(hash_or_rule, &block)</span>
|
158
177
|
</a>
|
159
178
|
</div>
|
160
179
|
|
161
180
|
<div class="method-description">
|
162
181
|
<p><a class="source-toggle" href="#"
|
163
|
-
onclick="toggleCode('
|
164
|
-
<div class="method-source-code" id="
|
182
|
+
onclick="toggleCode('M000074-source');return false;">[Source]</a></p>
|
183
|
+
<div class="method-source-code" id="M000074-source">
|
165
184
|
<pre>
|
166
|
-
<span class="ruby-comment cmt"># File kwalify/validator.rb, line
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
<span class="ruby-
|
185
|
+
<span class="ruby-comment cmt"># File kwalify/validator.rb, line 44</span>
|
186
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">hash_or_rule</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
187
|
+
<span class="ruby-identifier">obj</span> = <span class="ruby-identifier">hash_or_rule</span>
|
188
|
+
<span class="ruby-ivar">@rule</span> = (<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Rule</span>)) <span class="ruby-operator">?</span> <span class="ruby-identifier">obj</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Rule</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">obj</span>)
|
189
|
+
<span class="ruby-ivar">@block</span> = <span class="ruby-identifier">block</span>
|
190
|
+
<span class="ruby-keyword kw">end</span>
|
171
191
|
</pre>
|
172
192
|
</div>
|
173
193
|
</div>
|
@@ -175,122 +195,169 @@ ex.
|
|
175
195
|
|
176
196
|
<h3 class="section-bar">Public Instance methods</h3>
|
177
197
|
|
178
|
-
<div id="method-
|
179
|
-
<a name="
|
198
|
+
<div id="method-M000075" class="method-detail">
|
199
|
+
<a name="M000075"></a>
|
180
200
|
|
181
201
|
<div class="method-heading">
|
182
|
-
<a href="#
|
202
|
+
<a href="#M000075" class="method-signature">
|
183
203
|
<span class="method-name">_inspect</span><span class="method-args">()</span>
|
184
204
|
</a>
|
185
205
|
</div>
|
186
206
|
|
187
207
|
<div class="method-description">
|
188
208
|
<p><a class="source-toggle" href="#"
|
189
|
-
onclick="toggleCode('
|
190
|
-
<div class="method-source-code" id="
|
209
|
+
onclick="toggleCode('M000075-source');return false;">[Source]</a></p>
|
210
|
+
<div class="method-source-code" id="M000075-source">
|
191
211
|
<pre>
|
192
|
-
<span class="ruby-comment cmt"># File kwalify/validator.rb, line
|
193
|
-
|
194
|
-
|
195
|
-
|
212
|
+
<span class="ruby-comment cmt"># File kwalify/validator.rb, line 52</span>
|
213
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_inspect</span>
|
214
|
+
<span class="ruby-ivar">@rule</span>.<span class="ruby-identifier">_inspect</span>
|
215
|
+
<span class="ruby-keyword kw">end</span>
|
196
216
|
</pre>
|
197
217
|
</div>
|
198
218
|
</div>
|
199
219
|
</div>
|
200
220
|
|
201
|
-
<div id="method-
|
202
|
-
<a name="
|
221
|
+
<div id="method-M000078" class="method-detail">
|
222
|
+
<a name="M000078"></a>
|
203
223
|
|
204
224
|
<div class="method-heading">
|
205
|
-
<a href="#
|
206
|
-
<span class="method-name">
|
225
|
+
<a href="#M000078" class="method-signature">
|
226
|
+
<span class="method-name">_validate</span><span class="method-args">(value, rule, path, errors, done, uniq_table, recursive=true)</span>
|
207
227
|
</a>
|
208
228
|
</div>
|
209
229
|
|
210
230
|
<div class="method-description">
|
211
231
|
<p><a class="source-toggle" href="#"
|
212
|
-
onclick="toggleCode('
|
213
|
-
<div class="method-source-code" id="
|
232
|
+
onclick="toggleCode('M000078-source');return false;">[Source]</a></p>
|
233
|
+
<div class="method-source-code" id="M000078-source">
|
214
234
|
<pre>
|
215
|
-
<span class="ruby-comment cmt"># File kwalify/validator.rb, line
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
235
|
+
<span class="ruby-comment cmt"># File kwalify/validator.rb, line 75</span>
|
236
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_validate</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">errors</span>, <span class="ruby-identifier">done</span>, <span class="ruby-identifier">uniq_table</span>, <span class="ruby-identifier">recursive</span>=<span class="ruby-keyword kw">true</span>)
|
237
|
+
<span class="ruby-comment cmt">#if Types.collection?(value)</span>
|
238
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-constant">Types</span>.<span class="ruby-identifier">scalar?</span>(<span class="ruby-identifier">value</span>)
|
239
|
+
<span class="ruby-comment cmt">#if done[value.__id__]</span>
|
240
|
+
<span class="ruby-comment cmt"># rule2 = done[value.__id__]</span>
|
241
|
+
<span class="ruby-comment cmt"># if rule2.is_a?(Rule)</span>
|
242
|
+
<span class="ruby-comment cmt"># return if rule.equal?(rule2)</span>
|
243
|
+
<span class="ruby-comment cmt"># done[value.__id__] = [rule2, rule]</span>
|
244
|
+
<span class="ruby-comment cmt"># elsif rule2.is_a?(Array)</span>
|
245
|
+
<span class="ruby-comment cmt"># return if rule2.any? {|r| r.equal?(rule)}</span>
|
246
|
+
<span class="ruby-comment cmt"># done[value.__id__] << rule</span>
|
247
|
+
<span class="ruby-comment cmt"># else</span>
|
248
|
+
<span class="ruby-comment cmt"># raise "unreachable"</span>
|
249
|
+
<span class="ruby-comment cmt"># end</span>
|
250
|
+
<span class="ruby-comment cmt">#end</span>
|
251
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">done</span>[<span class="ruby-identifier">value</span>.<span class="ruby-identifier">__id__</span>] <span class="ruby-comment cmt"># avoid infinite loop</span>
|
252
|
+
<span class="ruby-identifier">done</span>[<span class="ruby-identifier">value</span>.<span class="ruby-identifier">__id__</span>] = <span class="ruby-identifier">rule</span>
|
253
|
+
<span class="ruby-keyword kw">end</span>
|
254
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rule</span>.<span class="ruby-identifier">required</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">nil?</span>
|
255
|
+
<span class="ruby-comment cmt">#* key=:required_novalue msg="value required but none."</span>
|
256
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:required_novalue</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">value</span>)
|
257
|
+
<span class="ruby-keyword kw">return</span>
|
258
|
+
<span class="ruby-keyword kw">end</span>
|
259
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rule</span>.<span class="ruby-identifier">type_class</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">value</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-identifier">rule</span>.<span class="ruby-identifier">type_class</span>)
|
260
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">rule</span>.<span class="ruby-identifier">classobj</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-identifier">rule</span>.<span class="ruby-identifier">classobj</span>)
|
261
|
+
<span class="ruby-comment cmt">#* key=:type_unmatch msg="not a %s."</span>
|
262
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:type_unmatch</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">value</span>, [<span class="ruby-constant">Kwalify</span>.<span class="ruby-identifier">word</span>(<span class="ruby-identifier">rule</span>.<span class="ruby-identifier">type</span>)])
|
263
|
+
<span class="ruby-keyword kw">return</span>
|
264
|
+
<span class="ruby-keyword kw">end</span>
|
220
265
|
<span class="ruby-keyword kw">end</span>
|
266
|
+
<span class="ruby-comment cmt">#</span>
|
267
|
+
<span class="ruby-identifier">n</span> = <span class="ruby-identifier">errors</span>.<span class="ruby-identifier">length</span>
|
268
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rule</span>.<span class="ruby-identifier">sequence</span>
|
269
|
+
<span class="ruby-identifier">_validate_sequence</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">errors</span>, <span class="ruby-identifier">done</span>, <span class="ruby-identifier">uniq_table</span>, <span class="ruby-identifier">recursive</span>)
|
270
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">rule</span>.<span class="ruby-identifier">mapping</span>
|
271
|
+
<span class="ruby-identifier">_validate_mapping</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">errors</span>, <span class="ruby-identifier">done</span>, <span class="ruby-identifier">uniq_table</span>, <span class="ruby-identifier">recursive</span>)
|
272
|
+
<span class="ruby-keyword kw">else</span>
|
273
|
+
<span class="ruby-identifier">_validate_scalar</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">errors</span>, <span class="ruby-identifier">done</span>, <span class="ruby-identifier">uniq_table</span>)
|
274
|
+
<span class="ruby-keyword kw">end</span>
|
275
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">errors</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">n</span>
|
276
|
+
<span class="ruby-comment cmt">#</span>
|
277
|
+
<span class="ruby-identifier">validate_hook</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">errors</span>)
|
278
|
+
<span class="ruby-ivar">@block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">errors</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@block</span>
|
279
|
+
<span class="ruby-keyword kw">end</span>
|
221
280
|
</pre>
|
222
281
|
</div>
|
223
282
|
</div>
|
224
283
|
</div>
|
225
284
|
|
226
|
-
<
|
227
|
-
|
228
|
-
<div id="method-M000028" class="method-detail">
|
229
|
-
<a name="M000028"></a>
|
285
|
+
<div id="method-M000079" class="method-detail">
|
286
|
+
<a name="M000079"></a>
|
230
287
|
|
231
288
|
<div class="method-heading">
|
232
|
-
<a href="#
|
233
|
-
<span class="method-name">
|
289
|
+
<a href="#M000079" class="method-signature">
|
290
|
+
<span class="method-name">_validate_unique</span><span class="method-args">(value, rule, path, errors, uniq_table)</span>
|
234
291
|
</a>
|
235
292
|
</div>
|
236
293
|
|
237
294
|
<div class="method-description">
|
238
295
|
<p><a class="source-toggle" href="#"
|
239
|
-
onclick="toggleCode('
|
240
|
-
<div class="method-source-code" id="
|
296
|
+
onclick="toggleCode('M000079-source');return false;">[Source]</a></p>
|
297
|
+
<div class="method-source-code" id="M000079-source">
|
241
298
|
<pre>
|
242
|
-
<span class="ruby-comment cmt"># File kwalify/validator.rb, line
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
<span class="ruby-keyword kw">end</span>
|
253
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rule</span>.<span class="ruby-identifier">type_class</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">value</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-identifier">rule</span>.<span class="ruby-identifier">type_class</span>)
|
254
|
-
<span class="ruby-comment cmt">#* key=:type_unmatch msg="not a %s."</span>
|
255
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:type_unmatch</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">value</span>, [<span class="ruby-constant">Kwalify</span>.<span class="ruby-identifier">word</span>(<span class="ruby-identifier">rule</span>.<span class="ruby-identifier">type</span>)])
|
256
|
-
<span class="ruby-keyword kw">return</span>
|
257
|
-
<span class="ruby-keyword kw">end</span>
|
258
|
-
<span class="ruby-comment cmt">#</span>
|
259
|
-
<span class="ruby-identifier">n</span> = <span class="ruby-identifier">errors</span>.<span class="ruby-identifier">length</span>
|
260
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rule</span>.<span class="ruby-identifier">sequence</span>
|
261
|
-
<span class="ruby-identifier">_validate_sequence</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">errors</span>, <span class="ruby-identifier">done</span>)
|
262
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">rule</span>.<span class="ruby-identifier">mapping</span>
|
263
|
-
<span class="ruby-identifier">_validate_mapping</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">errors</span>, <span class="ruby-identifier">done</span>)
|
264
|
-
<span class="ruby-keyword kw">else</span>
|
265
|
-
<span class="ruby-identifier">_validate_scalar</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">errors</span>, <span class="ruby-identifier">done</span>)
|
266
|
-
<span class="ruby-keyword kw">end</span>
|
267
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">errors</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">n</span>
|
268
|
-
<span class="ruby-comment cmt">#</span>
|
269
|
-
<span class="ruby-identifier">validate_hook</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">errors</span>)
|
270
|
-
<span class="ruby-ivar">@block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">errors</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@block</span>
|
299
|
+
<span class="ruby-comment cmt"># File kwalify/validator.rb, line 185</span>
|
300
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_validate_unique</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">errors</span>, <span class="ruby-identifier">uniq_table</span>)
|
301
|
+
<span class="ruby-identifier">assert_error</span> <span class="ruby-node">"uniq_table=#{uniq_table.inspect}"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">rule</span>.<span class="ruby-identifier">unique</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">rule</span>.<span class="ruby-identifier">ident</span>
|
302
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uniq_table</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">value</span>)
|
303
|
+
<span class="ruby-identifier">exist_at</span> = <span class="ruby-identifier">uniq_table</span>[<span class="ruby-identifier">value</span>]
|
304
|
+
<span class="ruby-identifier">exist_at</span> = <span class="ruby-node">"/#{exist_at.join('/')}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">exist_at</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
|
305
|
+
<span class="ruby-comment cmt">#* key=:value_notunique msg="is already used at '%s'."</span>
|
306
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:value_notunique</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">exist_at</span>)
|
307
|
+
<span class="ruby-keyword kw">else</span>
|
308
|
+
<span class="ruby-identifier">uniq_table</span>[<span class="ruby-identifier">value</span>] = <span class="ruby-identifier">path</span>.<span class="ruby-identifier">dup</span>
|
271
309
|
<span class="ruby-keyword kw">end</span>
|
310
|
+
<span class="ruby-keyword kw">end</span>
|
272
311
|
</pre>
|
273
312
|
</div>
|
274
313
|
</div>
|
275
314
|
</div>
|
276
315
|
|
277
|
-
<div id="method-
|
278
|
-
<a name="
|
316
|
+
<div id="method-M000076" class="method-detail">
|
317
|
+
<a name="M000076"></a>
|
279
318
|
|
280
319
|
<div class="method-heading">
|
281
|
-
<a href="#
|
320
|
+
<a href="#M000076" class="method-signature">
|
321
|
+
<span class="method-name">validate</span><span class="method-args">(value)</span>
|
322
|
+
</a>
|
323
|
+
</div>
|
324
|
+
|
325
|
+
<div class="method-description">
|
326
|
+
<p><a class="source-toggle" href="#"
|
327
|
+
onclick="toggleCode('M000076-source');return false;">[Source]</a></p>
|
328
|
+
<div class="method-source-code" id="M000076-source">
|
329
|
+
<pre>
|
330
|
+
<span class="ruby-comment cmt"># File kwalify/validator.rb, line 57</span>
|
331
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">validate</span>(<span class="ruby-identifier">value</span>)
|
332
|
+
<span class="ruby-identifier">path</span> = <span class="ruby-value str">''</span>; <span class="ruby-identifier">errors</span> = []; <span class="ruby-identifier">done</span> = {}; <span class="ruby-identifier">uniq_table</span> = <span class="ruby-keyword kw">nil</span>
|
333
|
+
<span class="ruby-identifier">_validate</span>(<span class="ruby-identifier">value</span>, <span class="ruby-ivar">@rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">errors</span>, <span class="ruby-identifier">done</span>, <span class="ruby-identifier">uniq_table</span>)
|
334
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">errors</span>
|
335
|
+
<span class="ruby-keyword kw">end</span>
|
336
|
+
</pre>
|
337
|
+
</div>
|
338
|
+
</div>
|
339
|
+
</div>
|
340
|
+
|
341
|
+
<h3 class="section-bar">Protected Instance methods</h3>
|
342
|
+
|
343
|
+
<div id="method-M000077" class="method-detail">
|
344
|
+
<a name="M000077"></a>
|
345
|
+
|
346
|
+
<div class="method-heading">
|
347
|
+
<a href="#M000077" class="method-signature">
|
282
348
|
<span class="method-name">validate_hook</span><span class="method-args">(value, rule, path, errors)</span>
|
283
349
|
</a>
|
284
350
|
</div>
|
285
351
|
|
286
352
|
<div class="method-description">
|
287
353
|
<p><a class="source-toggle" href="#"
|
288
|
-
onclick="toggleCode('
|
289
|
-
<div class="method-source-code" id="
|
354
|
+
onclick="toggleCode('M000077-source');return false;">[Source]</a></p>
|
355
|
+
<div class="method-source-code" id="M000077-source">
|
290
356
|
<pre>
|
291
|
-
<span class="ruby-comment cmt"># File kwalify/validator.rb, line
|
292
|
-
|
293
|
-
<span class="ruby-
|
357
|
+
<span class="ruby-comment cmt"># File kwalify/validator.rb, line 67</span>
|
358
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">validate_hook</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">errors</span>)
|
359
|
+
<span class="ruby-comment cmt">## may be overrided by subclass</span>
|
360
|
+
<span class="ruby-keyword kw">end</span>
|
294
361
|
</pre>
|
295
362
|
</div>
|
296
363
|
</div>
|
@@ -0,0 +1,181 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Module: Kwalify::Yaml</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Module</strong></td>
|
53
|
+
<td class="class-name-in-header">Kwalify::Yaml</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/kwalify/parser/yaml_rb.html">
|
59
|
+
kwalify/parser/yaml.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
<a href="../../files/kwalify_rb.html">
|
63
|
+
kwalify.rb
|
64
|
+
</a>
|
65
|
+
<br />
|
66
|
+
</td>
|
67
|
+
</tr>
|
68
|
+
|
69
|
+
</table>
|
70
|
+
</div>
|
71
|
+
<!-- banner header -->
|
72
|
+
|
73
|
+
<div id="bodyContent">
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
<div id="contextContent">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
</div>
|
82
|
+
|
83
|
+
<div id="method-list">
|
84
|
+
<h3 class="section-bar">Methods</h3>
|
85
|
+
|
86
|
+
<div class="name-list">
|
87
|
+
<a href="#M000038">load</a>
|
88
|
+
<a href="#M000039">load_file</a>
|
89
|
+
</div>
|
90
|
+
</div>
|
91
|
+
|
92
|
+
</div>
|
93
|
+
|
94
|
+
|
95
|
+
<!-- if includes -->
|
96
|
+
|
97
|
+
<div id="section">
|
98
|
+
|
99
|
+
<div id="class-list">
|
100
|
+
<h3 class="section-bar">Classes and Modules</h3>
|
101
|
+
|
102
|
+
Class <a href="Yaml/Parser.html" class="link">Kwalify::Yaml::Parser</a><br />
|
103
|
+
|
104
|
+
</div>
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
<!-- if method_list -->
|
113
|
+
<div id="methods">
|
114
|
+
<h3 class="section-bar">Public Class methods</h3>
|
115
|
+
|
116
|
+
<div id="method-M000038" class="method-detail">
|
117
|
+
<a name="M000038"></a>
|
118
|
+
|
119
|
+
<div class="method-heading">
|
120
|
+
<a href="#M000038" class="method-signature">
|
121
|
+
<span class="method-name">load</span><span class="method-args">(yaml_str, options={})</span>
|
122
|
+
</a>
|
123
|
+
</div>
|
124
|
+
|
125
|
+
<div class="method-description">
|
126
|
+
<p><a class="source-toggle" href="#"
|
127
|
+
onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
|
128
|
+
<div class="method-source-code" id="M000038-source">
|
129
|
+
<pre>
|
130
|
+
<span class="ruby-comment cmt"># File kwalify.rb, line 37</span>
|
131
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">load</span>(<span class="ruby-identifier">yaml_str</span>, <span class="ruby-identifier">options</span>={})
|
132
|
+
<span class="ruby-comment cmt">#require 'kwalify/parser/yaml'</span>
|
133
|
+
<span class="ruby-identifier">parser</span> = <span class="ruby-constant">Kwalify</span><span class="ruby-operator">::</span><span class="ruby-constant">Yaml</span><span class="ruby-operator">::</span><span class="ruby-constant">Parser</span>.<span class="ruby-identifier">new</span>
|
134
|
+
<span class="ruby-identifier">parser</span>.<span class="ruby-identifier">preceding_alias</span> = <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:preceding_alias</span>]
|
135
|
+
<span class="ruby-identifier">parser</span>.<span class="ruby-identifier">data_binding</span> = <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:data_binding</span>]
|
136
|
+
<span class="ruby-identifier">yaml_str</span> = <span class="ruby-constant">Kwalify</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">untabify</span>(<span class="ruby-identifier">yaml_str</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:untabify</span>]
|
137
|
+
<span class="ruby-identifier">ydoc</span> = <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">yaml_str</span>, <span class="ruby-identifier">:filename=</span><span class="ruby-operator">></span><span class="ruby-identifier">options</span>[<span class="ruby-identifier">:filename</span>])
|
138
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">ydoc</span>
|
139
|
+
<span class="ruby-keyword kw">end</span>
|
140
|
+
</pre>
|
141
|
+
</div>
|
142
|
+
</div>
|
143
|
+
</div>
|
144
|
+
|
145
|
+
<div id="method-M000039" class="method-detail">
|
146
|
+
<a name="M000039"></a>
|
147
|
+
|
148
|
+
<div class="method-heading">
|
149
|
+
<a href="#M000039" class="method-signature">
|
150
|
+
<span class="method-name">load_file</span><span class="method-args">(filename, options={})</span>
|
151
|
+
</a>
|
152
|
+
</div>
|
153
|
+
|
154
|
+
<div class="method-description">
|
155
|
+
<p><a class="source-toggle" href="#"
|
156
|
+
onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
|
157
|
+
<div class="method-source-code" id="M000039-source">
|
158
|
+
<pre>
|
159
|
+
<span class="ruby-comment cmt"># File kwalify.rb, line 47</span>
|
160
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">load_file</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">options</span>={})
|
161
|
+
<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:filename</span>] = <span class="ruby-identifier">filename</span>
|
162
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">load</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">filename</span>), <span class="ruby-identifier">options</span>)
|
163
|
+
<span class="ruby-keyword kw">end</span>
|
164
|
+
</pre>
|
165
|
+
</div>
|
166
|
+
</div>
|
167
|
+
</div>
|
168
|
+
|
169
|
+
|
170
|
+
</div>
|
171
|
+
|
172
|
+
|
173
|
+
</div>
|
174
|
+
|
175
|
+
|
176
|
+
<div id="validator-badges">
|
177
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
178
|
+
</div>
|
179
|
+
|
180
|
+
</body>
|
181
|
+
</html>
|