kwalify 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +6 -1
- data/README.txt +1 -1
- data/bin/kwalify +1 -1
- data/doc/users-guide.html +7 -7
- data/examples/address-book/address-book.schema.yaml +1 -1
- data/examples/invoice/invoice.schema.yaml +1 -1
- data/examples/tapkit/tapkit.schema.yaml +1 -1
- data/lib/kwalify.rb +2 -2
- data/lib/kwalify/errors.rb +1 -1
- data/lib/kwalify/main-program.rb +9 -4
- data/lib/kwalify/messages.rb +1 -1
- data/lib/kwalify/meta-validator.rb +1 -1
- data/lib/kwalify/parser.rb +1 -1
- data/lib/kwalify/rule.rb +5 -5
- data/lib/kwalify/types.rb +1 -1
- data/lib/kwalify/util/assert-diff.rb +1 -1
- data/lib/kwalify/util/option-parser.rb +1 -1
- data/lib/kwalify/util/yaml-helper.rb +1 -1
- data/lib/kwalify/validator.rb +4 -4
- data/test/test-metavalidator.rb +14 -14
- data/test/test-parser.rb +1 -1
- data/test/test-validator.rb +6 -6
- data/test/test.rb +1 -1
- metadata +2 -2
data/ChangeLog
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
.=title: ChangeLog
|
2
|
-
.?release: $Release: 0.4.
|
2
|
+
.?release: $Release: 0.4.1 $
|
3
3
|
.?lastupdate: $Date$
|
4
4
|
.?version: $Rev$
|
5
5
|
|
6
|
+
.: 2005-10-26 (release 0.4.1)
|
7
|
+
.* Bugfix:
|
8
|
+
.- Support Ruby 1.8.3 (around YAML::Syck::DomainType)
|
9
|
+
.- Show correct error line number when key is undefined or unknown.
|
10
|
+
|
6
11
|
.: 2005-10-25 (release 0.4.0)
|
7
12
|
.* Enhances:
|
8
13
|
.- New command-line option '-l' prints error line numbers.
|
data/README.txt
CHANGED
data/bin/kwalify
CHANGED
data/doc/users-guide.html
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
<div align="left"><h1>Kwalify Users' Guide</h1></div>
|
16
16
|
<div align="left">
|
17
17
|
makoto kuwata <kwa(at)kuwata-lab.com><br>
|
18
|
-
last update: $Date: 2005-10-
|
18
|
+
last update: $Date: 2005-10-26 11:38:26 +0900 (Wed, 26 Oct 2005) $<br>
|
19
19
|
</div>
|
20
20
|
|
21
21
|
<a name="preface"></a>
|
@@ -356,8 +356,8 @@ validate</div>
|
|
356
356
|
<pre class="terminal">$ kwalify -lf schema03.yaml document03b.yaml
|
357
357
|
document03b.yaml#0: INVALID
|
358
358
|
- (line 3) [/1] key 'name:' is required.
|
359
|
-
- (line 3) [/1] key 'naem:' is undefined.
|
360
|
-
- (line
|
359
|
+
- (line 3) [/1/naem] key 'naem:' is undefined.
|
360
|
+
- (line 6) [/2/mail] key 'mail:' is undefined.
|
361
361
|
</pre>
|
362
362
|
<br>
|
363
363
|
|
@@ -424,7 +424,7 @@ validate</div>
|
|
424
424
|
<pre class="terminal">$ kwalify -lf schema04.yaml document04b.yaml
|
425
425
|
document04b.yaml#0: INVALID
|
426
426
|
- (line 4) [/employees/0/code] 'A101': not a integer.
|
427
|
-
- (line
|
427
|
+
- (line 9) [/employees/1/mail] key 'mail:' is undefined.
|
428
428
|
</pre>
|
429
429
|
<br>
|
430
430
|
|
@@ -604,9 +604,9 @@ document05b.yaml#0: INVALID
|
|
604
604
|
- (line 3) [/0/password] 'xxx123': too short (length 6 < min 8).
|
605
605
|
- (line 4) [/0/age] 'twenty': not a integer.
|
606
606
|
- (line 5) [/0/blood] 'a': invalid blood value.
|
607
|
-
- (line 7) [/1] key 'given-name:' is undefined.
|
608
|
-
- (line 7) [/1] key 'family-name:' is undefined.
|
607
|
+
- (line 7) [/1/given-name] key 'given-name:' is undefined.
|
609
608
|
- (line 7) [/1] key 'name:' is required.
|
609
|
+
- (line 8) [/1/family-name] key 'family-name:' is undefined.
|
610
610
|
- (line 10) [/1/age] '15': too small (< min 18).
|
611
611
|
- (line 12) [/1/birth] '1980/01/01': not a date.
|
612
612
|
</pre>
|
@@ -986,7 +986,7 @@ validate</div>
|
|
986
986
|
<pre class="terminal">$ kwalify -lf schema12.yaml document12b.yaml
|
987
987
|
document12b.yaml#0: INVALID
|
988
988
|
- (line 1) [/] key 'name:' is required.
|
989
|
-
- (line
|
989
|
+
- (line 2) [/mail] key 'mail:' is undefined.
|
990
990
|
- (line 3) [/age] 'twenty': not a integer.
|
991
991
|
- (line 4) [/gender] 'X': invalid gender value.
|
992
992
|
- (line 5) [/favorite/0] '123': not a string.
|
data/lib/kwalify.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
###
|
2
2
|
### $Rev: 26 $
|
3
|
-
### $Release: 0.4.
|
3
|
+
### $Release: 0.4.1 $
|
4
4
|
### copyright(c) 2005 kuwata-lab all rights reserved.
|
5
5
|
###
|
6
6
|
|
7
7
|
|
8
8
|
module Kwalify
|
9
9
|
|
10
|
-
RELEASE = ("$Release: 0.4.
|
10
|
+
RELEASE = ("$Release: 0.4.1 $" =~ /[.\d]+/) && $&
|
11
11
|
|
12
12
|
end
|
13
13
|
|
data/lib/kwalify/errors.rb
CHANGED
data/lib/kwalify/main-program.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
###
|
2
|
-
### $Rev:
|
3
|
-
### $Release: 0.4.
|
2
|
+
### $Rev: 39 $
|
3
|
+
### $Release: 0.4.1 $
|
4
4
|
### copyright(c) 2005 kuwata-lab all rights reserved.
|
5
5
|
###
|
6
6
|
|
@@ -69,7 +69,7 @@ module Kwalify
|
|
69
69
|
doc = @parser.parse()
|
70
70
|
else
|
71
71
|
doc = YAML.load(str)
|
72
|
-
doc = doc.value if
|
72
|
+
doc = doc.value if _domain_type?(doc)
|
73
73
|
end
|
74
74
|
return doc
|
75
75
|
end
|
@@ -185,7 +185,7 @@ module Kwalify
|
|
185
185
|
yield(doc)
|
186
186
|
else
|
187
187
|
YAML::load_documents(str) do |doc|
|
188
|
-
doc = doc.value if
|
188
|
+
doc = doc.value if _domain_type?(doc)
|
189
189
|
yield(doc)
|
190
190
|
end
|
191
191
|
end
|
@@ -247,6 +247,11 @@ module Kwalify
|
|
247
247
|
options[:debug] = opts[?D]
|
248
248
|
return options, properties
|
249
249
|
end
|
250
|
+
|
251
|
+
def _domain_type?(doc)
|
252
|
+
klass = defined?(YAML::DomainType) ? YAML::DomainType : YAML::Syck::DomainType
|
253
|
+
return doc.is_a?(klass)
|
254
|
+
end
|
250
255
|
|
251
256
|
end
|
252
257
|
|
data/lib/kwalify/messages.rb
CHANGED
data/lib/kwalify/parser.rb
CHANGED
data/lib/kwalify/rule.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
###
|
2
|
-
### $Rev:
|
3
|
-
### $Release: 0.4.
|
2
|
+
### $Rev: 39 $
|
3
|
+
### $Release: 0.4.1 $
|
4
4
|
### copyright(c) 2005 kuwata-lab all rights reserved.
|
5
5
|
###
|
6
6
|
|
@@ -145,7 +145,7 @@ module Kwalify
|
|
145
145
|
end
|
146
146
|
else
|
147
147
|
#* key=:range_undefined msg="undefined key."
|
148
|
-
raise schema_error(:range_undefined, rule, curr_path, "#{rkey}:")
|
148
|
+
raise schema_error(:range_undefined, rule, "#{curr_path}/#{rkey}", "#{rkey}:")
|
149
149
|
end
|
150
150
|
end
|
151
151
|
if val.key?('max') && val.key?('max-ex')
|
@@ -176,7 +176,7 @@ module Kwalify
|
|
176
176
|
end
|
177
177
|
else
|
178
178
|
#* key=:length_undefined msg="undefined key."
|
179
|
-
raise schema_error(:length_undefined, rule, curr_path, "#{lkey}:")
|
179
|
+
raise schema_error(:length_undefined, rule, "#{curr_path}/#{lkey}", "#{lkey}:")
|
180
180
|
end
|
181
181
|
end
|
182
182
|
if val.key?('max') && val.key?('max-ex')
|
@@ -277,7 +277,7 @@ module Kwalify
|
|
277
277
|
|
278
278
|
else
|
279
279
|
#* key=:key_unknown msg="unknown key."
|
280
|
-
raise schema_error(:key_unknown, rule,
|
280
|
+
raise schema_error(:key_unknown, rule, curr_path, "#{key}:")
|
281
281
|
end
|
282
282
|
end
|
283
283
|
|
data/lib/kwalify/types.rb
CHANGED
data/lib/kwalify/validator.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
###
|
2
|
-
### $Rev:
|
3
|
-
### $Release: 0.4.
|
2
|
+
### $Rev: 39 $
|
3
|
+
### $Release: 0.4.1 $
|
4
4
|
### copyright(c) 2005 kuwata-lab all rights reserved.
|
5
5
|
###
|
6
6
|
|
@@ -211,9 +211,9 @@ module Kwalify
|
|
211
211
|
rule = map_rule.mapping[key]
|
212
212
|
unless rule
|
213
213
|
#* key=:key_undefined msg="key '%s' is undefined."
|
214
|
-
errors << validate_error(:key_undefined, rule, path, hash, ["#{key}:"])
|
214
|
+
errors << validate_error(:key_undefined, rule, "#{path}/#{key}", hash, ["#{key}:"])
|
215
215
|
##* key=:key_undefined msg="undefined key."
|
216
|
-
#errors << validate_error(:key_undefined, rule, path, "#{key}:")
|
216
|
+
#errors << validate_error(:key_undefined, rule, "#{path}/#{key}", "#{key}:")
|
217
217
|
else
|
218
218
|
_validate(val, rule, "#{path}/#{key}", errors, done) ## validate recursively
|
219
219
|
end
|
data/test/test-metavalidator.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
###
|
2
|
-
### $Rev:
|
3
|
-
### $Release: 0.4.
|
2
|
+
### $Rev: 39 $
|
3
|
+
### $Release: 0.4.1 $
|
4
4
|
### copyright(c) 2005 kuwata-lab all rights reserved.
|
5
5
|
###
|
6
6
|
|
@@ -335,12 +335,12 @@ schema: |
|
|
335
335
|
range: { max: 10, mim: 1 }
|
336
336
|
#
|
337
337
|
meta-msg: |
|
338
|
-
:key_undefined : [/range] key 'mim:' is undefined.
|
339
|
-
# :key_undefined : [/range] 'mim:': undefined key.
|
338
|
+
:key_undefined : [/range/mim] key 'mim:' is undefined.
|
339
|
+
# :key_undefined : [/range/mim] 'mim:': undefined key.
|
340
340
|
#
|
341
341
|
rule-msg: |
|
342
|
-
:range_undefined : [/range] 'mim:': undefined key.
|
343
|
-
# :range_undefined : [/range] key 'mim:' undefined key.
|
342
|
+
:range_undefined : [/range/mim] 'mim:': undefined key.
|
343
|
+
# :range_undefined : [/range/mim] key 'mim:' undefined key.
|
344
344
|
#
|
345
345
|
---
|
346
346
|
name: range_twomax
|
@@ -407,12 +407,12 @@ schema: |
|
|
407
407
|
length: { maximum: 10 }
|
408
408
|
#
|
409
409
|
meta-msg: |
|
410
|
-
:key_undefined : [/length] key 'maximum:' is undefined.
|
411
|
-
# :key_undefined : [/length] 'maximum:': undefined key.
|
410
|
+
:key_undefined : [/length/maximum] key 'maximum:' is undefined.
|
411
|
+
# :key_undefined : [/length/maximum] 'maximum:': undefined key.
|
412
412
|
#
|
413
413
|
rule-msg: |
|
414
|
-
:length_undefined : [/length] 'maximum:': undefined key.
|
415
|
-
# :length_undefined : [/length] key 'maximum:' is undefined.
|
414
|
+
:length_undefined : [/length/maximum] 'maximum:': undefined key.
|
415
|
+
# :length_undefined : [/length/maximum] key 'maximum:' is undefined.
|
416
416
|
#
|
417
417
|
---
|
418
418
|
name: length_twomax
|
@@ -515,12 +515,12 @@ schema: |
|
|
515
515
|
- two
|
516
516
|
#
|
517
517
|
meta-msg: |
|
518
|
-
:key_undefined : [/] key 'values:' is undefined.
|
519
|
-
# :key_undefined : [/] 'values:': undefined key.
|
518
|
+
:key_undefined : [/values] key 'values:' is undefined.
|
519
|
+
# :key_undefined : [/values] 'values:': undefined key.
|
520
520
|
#
|
521
521
|
rule-msg: |
|
522
|
-
:key_unknown : [/] 'values:': unknown key.
|
523
|
-
# :key_unknown : [/] key 'values:' is unknown.
|
522
|
+
:key_unknown : [/values] 'values:': unknown key.
|
523
|
+
# :key_unknown : [/values] key 'values:' is unknown.
|
524
524
|
#
|
525
525
|
---
|
526
526
|
name: seq_nosequence
|
data/test/test-parser.rb
CHANGED
data/test/test-validator.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
###
|
2
|
-
### $Rev:
|
3
|
-
### $Release: 0.4.
|
2
|
+
### $Rev: 39 $
|
3
|
+
### $Release: 0.4.1 $
|
4
4
|
### copyright(c) 2005 kuwata-lab all rights reserved.
|
5
5
|
###
|
6
6
|
|
@@ -132,7 +132,7 @@ invalid: |
|
|
132
132
|
#
|
133
133
|
error: |
|
134
134
|
:required_nokey : (line 1)[/] key 'name:' is required.
|
135
|
-
:key_undefined : (line 1)[/] key 'nam:' is undefined.
|
135
|
+
:key_undefined : (line 1)[/nam] key 'nam:' is undefined.
|
136
136
|
:enum_notexist : (line 4)[/blood] 'ab': invalid blood value.
|
137
137
|
:type_unmatch : (line 5)[/birth] 'Jul 01, 1985': not a date.
|
138
138
|
:type_unmatch : (line 3)[/age] 'twenty': not a integer.
|
@@ -220,7 +220,7 @@ invalid: |
|
|
220
220
|
#
|
221
221
|
error: |
|
222
222
|
:required_nokey : (line 2)[/address-book/0] key 'email:' is required.
|
223
|
-
:key_undefined : (line
|
223
|
+
:key_undefined : (line 3)[/address-book/0/mail] key 'mail:' is undefined.
|
224
224
|
:enum_notexist : (line 5)[/address-book/0/blood] 'ab': invalid blood value.
|
225
225
|
:type_unmatch : (line 6)[/address-book/0/birth] '1985/01/01': not a date.
|
226
226
|
:type_unmatch : (line 4)[/address-book/0/age] 'twenty': not a integer.
|
@@ -256,7 +256,7 @@ invalid: |
|
|
256
256
|
#
|
257
257
|
error: |
|
258
258
|
:required_nokey : (line 1)[/0] key 'family-name:' is required.
|
259
|
-
:key_undefined : (line
|
259
|
+
:key_undefined : (line 2)[/0/last-name] key 'last-name:' is undefined.
|
260
260
|
:type_unmatch : (line 4)[/1/family-name] '100': not a string.
|
261
261
|
#
|
262
262
|
---
|
@@ -300,7 +300,7 @@ invalid: |
|
|
300
300
|
error: |
|
301
301
|
:type_unmatch : (line 3)[/address-book/0/name] '100': not a string.
|
302
302
|
:required_nokey : (line 5)[/address-book/1] key 'name:' is required.
|
303
|
-
:key_undefined : (line 5)[/address-book/1] key 'first-name:' is undefined.
|
303
|
+
:key_undefined : (line 5)[/address-book/1/first-name] key 'first-name:' is undefined.
|
304
304
|
#
|
305
305
|
---
|
306
306
|
name: anchor3
|
data/test/test.rb
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: kwalify
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.4.
|
7
|
-
date: 2005-10-
|
6
|
+
version: 0.4.1
|
7
|
+
date: 2005-10-26 00:00:00 +09:00
|
8
8
|
summary: a tiny schema validator for YAML document.
|
9
9
|
require_paths:
|
10
10
|
- lib
|