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 CHANGED
@@ -1,8 +1,13 @@
1
1
  .=title: ChangeLog
2
- .?release: $Release: 0.4.0 $
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
@@ -1,7 +1,7 @@
1
1
  .=title: README
2
2
  .?version: $Rev: 18 $
3
3
  .?lastupdate: $Date: 2005-09-25 22:36:35 +0900 (Sun, 25 Sep 2005) $
4
- .?release: $Release: 0.4.0 $
4
+ .?release: $Release: 0.4.1 $
5
5
 
6
6
 
7
7
  .$ About Kwalify
data/bin/kwalify CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ###
4
4
  ### $Rev: 12 $
5
- ### $Release: 0.4.0 $
5
+ ### $Release: 0.4.1 $
6
6
  ### copyright(c) 2005 kuwata-lab all rights reserved.
7
7
  ###
8
8
 
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 &lt;kwa(at)kuwata-lab.com&gt;<br>
18
- last update: $Date: 2005-10-25 08:01:14 +0900 (Tue, 25 Oct 2005) $<br>
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 5) [/2] key 'mail:' is undefined.
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 7) [/employees/1] key 'mail:' is undefined.
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 &lt; 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 (&lt; 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 1) [/] key 'mail:' is undefined.
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.
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## Kwalify schema example for address book
3
3
  ##
4
- ## $Release: 0.4.0 $
4
+ ## $Release: 0.4.1 $
5
5
  ## copyright(c) 2005 kuwata-lab all rights reserved.
6
6
  ##
7
7
  ##
@@ -2,7 +2,7 @@
2
2
  ### Kwalify schema example for invoice
3
3
  ###
4
4
  ### $Rev: 20 $
5
- ### $Release: 0.4.0 $
5
+ ### $Release: 0.4.1 $
6
6
  ### copyright(c) 2005 kuwata-lab all rights reserved.
7
7
  ###
8
8
 
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## Kwalify schema example for TapKit
3
3
  ##
4
- ## $Release: 0.4.0 $
4
+ ## $Release: 0.4.1 $
5
5
  ## copyright(c) 2005 kuwata-lab all rights reserved.
6
6
  ##
7
7
 
data/lib/kwalify.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  ###
2
2
  ### $Rev: 26 $
3
- ### $Release: 0.4.0 $
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.0 $" =~ /[.\d]+/) && $&
10
+ RELEASE = ("$Release: 0.4.1 $" =~ /[.\d]+/) && $&
11
11
 
12
12
  end
13
13
 
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev: 27 $
3
- ### $Release: 0.4.0 $
3
+ ### $Release: 0.4.1 $
4
4
  ### copyright(c) 2005 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
- ### $Rev: 26 $
3
- ### $Release: 0.4.0 $
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 doc.is_a?(YAML::Syck::DomainType)
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 doc.is_a?(YAML::Syck::DomainType)
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
 
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev: 22 $
3
- ### $Release: 0.4.0 $
3
+ ### $Release: 0.4.1 $
4
4
  ### copyright(c) 2005 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev: 35 $
3
- ### $Release: 0.4.0 $
3
+ ### $Release: 0.4.1 $
4
4
  ### copyright(c) 2005 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev: 35 $
3
- ### $Release: 0.4.0 $
3
+ ### $Release: 0.4.1 $
4
4
  ### copyright(c) 2005 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
data/lib/kwalify/rule.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ###
2
- ### $Rev: 35 $
3
- ### $Release: 0.4.0 $
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, path, "#{key}:")
280
+ raise schema_error(:key_unknown, rule, curr_path, "#{key}:")
281
281
  end
282
282
  end
283
283
 
data/lib/kwalify/types.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev: 25 $
3
- ### $Release: 0.4.0 $
3
+ ### $Release: 0.4.1 $
4
4
  ### copyright(c) 2005 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev: 5 $
3
- ### $Release: 0.4.0 $
3
+ ### $Release: 0.4.1 $
4
4
  ### copyright(c) 2005 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev: 6 $
3
- ### $Release: 0.4.0 $
3
+ ### $Release: 0.4.1 $
4
4
  ### copyright(c) 2005 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev: 10 $
3
- ### $Release: 0.4.0 $
3
+ ### $Release: 0.4.1 $
4
4
  ### copyright(c) 2005 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
- ### $Rev: 32 $
3
- ### $Release: 0.4.0 $
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
@@ -1,6 +1,6 @@
1
1
  ###
2
- ### $Rev: 31 $
3
- ### $Release: 0.4.0 $
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
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev: 35 $
3
- ### $Release: 0.4.0 $
3
+ ### $Release: 0.4.1 $
4
4
  ### copyright(c) 2005 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
- ### $Rev: 35 $
3
- ### $Release: 0.4.0 $
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 2)[/address-book/0] key 'mail:' is undefined.
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 1)[/0] key 'last-name:' is undefined.
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
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev: 31 $
3
- ### $Release: 0.4.0 $
3
+ ### $Release: 0.4.1 $
4
4
  ### copyright(c) 2005 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
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.0
7
- date: 2005-10-25 00:00:00 +09:00
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