kwalify 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/CHANGES.txt +12 -3
  2. data/MIT-LICENSE +1 -1
  3. data/README.txt +10 -10
  4. data/bin/kwalify +3 -3
  5. data/contrib/inline-require +54 -28
  6. data/contrib/kwalify +45 -44
  7. data/doc-api/classes/CommandOptionError.html +7 -7
  8. data/doc-api/classes/CommandOptionParser.html +18 -18
  9. data/doc-api/classes/Kwalify.html +1 -1
  10. data/doc-api/classes/Kwalify/AssertionError.html +6 -6
  11. data/doc-api/classes/Kwalify/BaseParser.html +60 -60
  12. data/doc-api/classes/Kwalify/CommandOptionError.html +6 -6
  13. data/doc-api/classes/Kwalify/Main.html +30 -30
  14. data/doc-api/classes/Kwalify/MetaValidator.html +18 -18
  15. data/doc-api/classes/Kwalify/Parser.html +6 -6
  16. data/doc-api/classes/Kwalify/PlainYamlParser.html +90 -90
  17. data/doc-api/classes/Kwalify/PlainYamlParser/Alias.html +6 -6
  18. data/doc-api/classes/Kwalify/Rule.html +24 -24
  19. data/doc-api/classes/Kwalify/SchemaError.html +6 -6
  20. data/doc-api/classes/Kwalify/SyntaxError.html +12 -12
  21. data/doc-api/classes/Kwalify/Util.html +8 -7
  22. data/doc-api/classes/Kwalify/ValidationError.html +6 -6
  23. data/doc-api/classes/Kwalify/Validator.html +39 -39
  24. data/doc-api/classes/Kwalify/YamlParser.html +84 -84
  25. data/doc-api/created.rid +1 -1
  26. data/doc-api/files/__/README_txt.html +11 -11
  27. data/doc-api/files/kwalify/errors_rb.html +2 -2
  28. data/doc-api/files/kwalify/main_rb.html +2 -2
  29. data/doc-api/files/kwalify/messages_rb.html +2 -2
  30. data/doc-api/files/kwalify/meta-validator_rb.html +2 -2
  31. data/doc-api/files/kwalify/parser/base_rb.html +2 -2
  32. data/doc-api/files/kwalify/parser/yaml_rb.html +2 -2
  33. data/doc-api/files/kwalify/rule_rb.html +2 -2
  34. data/doc-api/files/kwalify/types_rb.html +2 -2
  35. data/doc-api/files/kwalify/util/assert-text-equal_rb.html +2 -2
  36. data/doc-api/files/kwalify/util/hash-interface_rb.html +2 -2
  37. data/doc-api/files/kwalify/util/hashlike_rb.html +2 -2
  38. data/doc-api/files/kwalify/util/option-parser_rb.html +2 -2
  39. data/doc-api/files/kwalify/util/ordered-hash_rb.html +2 -2
  40. data/doc-api/files/kwalify/util/testcase-helper_rb.html +2 -2
  41. data/doc-api/files/kwalify/util_rb.html +2 -2
  42. data/doc-api/files/kwalify/validator_rb.html +2 -2
  43. data/doc-api/files/kwalify/yaml-parser_rb.html +2 -2
  44. data/doc-api/files/kwalify_rb.html +2 -2
  45. data/doc-api/fr_method_index.html +70 -70
  46. data/doc/users-guide.html +1 -1
  47. data/examples/address-book/address-book.schema.yaml +2 -2
  48. data/examples/invoice/invoice.schema.yaml +3 -3
  49. data/examples/tapkit/tapkit.schema.yaml +2 -2
  50. data/lib/kwalify.rb +3 -3
  51. data/lib/kwalify/errors.rb +3 -3
  52. data/lib/kwalify/kwalify.schema.yaml +3 -3
  53. data/lib/kwalify/main.rb +4 -4
  54. data/lib/kwalify/messages.rb +3 -3
  55. data/lib/kwalify/meta-validator.rb +3 -3
  56. data/lib/kwalify/parser/base.rb +3 -3
  57. data/lib/kwalify/parser/yaml.rb +3 -3
  58. data/lib/kwalify/rule.rb +3 -3
  59. data/lib/kwalify/templates/genclass-java.eruby +3 -3
  60. data/lib/kwalify/templates/genclass-php.eruby +2 -2
  61. data/lib/kwalify/templates/genclass-ruby.eruby +3 -3
  62. data/lib/kwalify/types.rb +3 -3
  63. data/lib/kwalify/util.rb +6 -5
  64. data/lib/kwalify/util/assert-text-equal.rb +3 -3
  65. data/lib/kwalify/util/hash-interface.rb +3 -3
  66. data/lib/kwalify/util/hashlike.rb +3 -3
  67. data/lib/kwalify/util/option-parser.rb +3 -3
  68. data/lib/kwalify/util/ordered-hash.rb +2 -2
  69. data/lib/kwalify/util/testcase-helper.rb +3 -3
  70. data/lib/kwalify/validator.rb +3 -3
  71. data/lib/kwalify/yaml-parser.rb +3 -3
  72. data/test/test-action.rb +3 -3
  73. data/test/test-action.yaml +3 -3
  74. data/test/test-databinding.rb +3 -3
  75. data/test/test-databinding.yaml +2 -2
  76. data/test/test-main.rb +3 -3
  77. data/test/test-main.yaml +34 -3
  78. data/test/test-metavalidator.rb +3 -3
  79. data/test/test-metavalidator.yaml +3 -3
  80. data/test/test-parser-yaml.rb +3 -3
  81. data/test/test-parser-yaml.yaml +3 -3
  82. data/test/test-rule.rb +3 -3
  83. data/test/test-rule.yaml +3 -3
  84. data/test/test-util.rb +125 -0
  85. data/test/test-validator.rb +3 -3
  86. data/test/test-validator.yaml +3 -3
  87. data/test/test-yaml-parser.rb +3 -3
  88. data/test/test-yaml-parser.yaml +4 -4
  89. data/test/test.rb +4 -3
  90. metadata +56 -55
@@ -15,7 +15,7 @@
15
15
  <div align="left"><h1>Kwalify User's Guide (for Ruby)</h1></div>
16
16
  <div align="left">
17
17
  makoto kuwata &lt;kwa(at)kuwata-lab.com&gt;<br>
18
- last update: $Date: 2008-01-28 15:27:12 +0900 (Mon, 28 Jan 2008) $<br>
18
+ last update: $Date$<br>
19
19
  </div>
20
20
 
21
21
  <a name="preface"></a>
@@ -1,8 +1,8 @@
1
1
  ##
2
2
  ## Kwalify schema example for address book
3
3
  ##
4
- ## $Release: 0.7.1 $
5
- ## copyright(c) 2005-2008 kuwata-lab all rights reserved.
4
+ ## $Release: 0.7.2 $
5
+ ## copyright(c) 2005-2010 kuwata-lab all rights reserved.
6
6
  ##
7
7
  ##
8
8
  ## NOTE: 'type: str' is omitted in this example because 'str' is default type.
@@ -1,9 +1,9 @@
1
1
  ###
2
2
  ### Kwalify schema example for invoice
3
3
  ###
4
- ### $Rev: 83 $
5
- ### $Release: 0.7.1 $
6
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
4
+ ### $Rev$
5
+ ### $Release: 0.7.2 $
6
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
7
7
  ###
8
8
 
9
9
  type: map
@@ -1,8 +1,8 @@
1
1
  ##
2
2
  ## Kwalify schema example for TapKit
3
3
  ##
4
- ## $Release: 0.7.1 $
5
- ## copyright(c) 2005-2008 kuwata-lab all rights reserved.
4
+ ## $Release: 0.7.2 $
5
+ ## copyright(c) 2005-2010 kuwata-lab all rights reserved.
6
6
  ##
7
7
 
8
8
  type: map
@@ -1,13 +1,13 @@
1
1
  ###
2
- ### $Rev: 99 $
3
- ### $Release: 0.7.1 $
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
4
  ### copyright(c) 2006 kuwata-lab.com all rights reserved.
5
5
  ###
6
6
 
7
7
 
8
8
  module Kwalify
9
9
 
10
- RELEASE = ("$Release: 0.7.1 $" =~ /[.\d]+/) && $&
10
+ RELEASE = ("$Release: 0.7.2 $" =~ /[.\d]+/) && $&
11
11
 
12
12
  end
13
13
 
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 99 $
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  require 'kwalify/messages'
@@ -1,6 +1,6 @@
1
- ## $Rev: 95 $
2
- ## $Date: 2008-01-27 22:49:22 +0900 (Sun, 27 Jan 2008) $
3
- ## copyright(c) 2005-2008 kuwata-lab all rights reserved.
1
+ ## $Rev$
2
+ ## $Date$
3
+ ## copyright(c) 2005-2010 kuwata-lab all rights reserved.
4
4
 
5
5
  name: MAIN
6
6
  type: map
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 95 $
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  require 'yaml'
@@ -323,7 +323,7 @@ module Kwalify
323
323
  end
324
324
  elsif ydoc.nil?
325
325
  #* key=:validation_empty msg="%s#%d: empty.\n"
326
- puts kwalify.msg(:validation_empty) % [filename, i]
326
+ puts Kwalify.msg(:validation_empty) % [filename, i]
327
327
  else
328
328
  #* key=:validation_valid msg="%s#%d: valid."
329
329
  puts Kwalify.msg(:validation_valid) % [filename, i] unless @options[:quiet]
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 95 $
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  module Kwalify
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 95 $
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  require 'kwalify/errors'
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 92 $
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  require 'strscan'
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 99 $
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  require 'kwalify/validator'
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 95 $
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  require 'kwalify/messages'
@@ -1,9 +1,9 @@
1
1
  <%
2
2
 
3
3
  ###
4
- ### $Rev: 95 $
5
- ### $Release: 0.7.1 $
6
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
4
+ ### $Rev$
5
+ ### $Release: 0.7.2 $
6
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
7
7
  ###
8
8
 
9
9
  require 'fileutils'
@@ -2,8 +2,8 @@
2
2
 
3
3
  ###
4
4
  ### $Rev$
5
- ### $Release: 0.7.1 $
6
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
5
+ ### $Release: 0.7.2 $
6
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
7
7
  ###
8
8
 
9
9
  if @describe
@@ -1,9 +1,9 @@
1
1
  <%
2
2
 
3
3
  ###
4
- ### $Rev: 96 $
5
- ### $Release: 0.7.1 $
6
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
4
+ ### $Rev$
5
+ ### $Release: 0.7.2 $
6
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
7
7
  ###
8
8
 
9
9
  if @describe
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 87 $
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  require 'date'
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 88 $
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  module Kwalify
@@ -17,7 +17,8 @@ module Kwalify
17
17
  ## untabified_str = YamlHelper.untabify(tabbed_str)
18
18
  ##
19
19
  def untabify(str, width=8)
20
- list = str.split(/\t/)
20
+ return str if str.nil?
21
+ list = str.split(/\t/, -1) # if 2nd arg is negative then split() doesn't remove tailing empty strings
21
22
  last = list.pop
22
23
  sb = ''
23
24
  list.each do |s|
@@ -37,7 +38,7 @@ module Kwalify
37
38
  ## Kwalify::Util.traverse_schema(schema) do |rulehash|
38
39
  ## ## add module prefix to class name
39
40
  ## if rulehash['class']
40
- ## rulehash['class'] = "MyModule::' + rulehash['class']
41
+ ## rulehash['class'] = 'MyModule::' + rulehash['class']
41
42
  ## end
42
43
  ## end
43
44
  def traverse_schema(schema, &block) #:yield: rulehash
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 83 $
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  require 'test/unit/testcase'
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 88 $$
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  require 'kwalify/util/hashlike'
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 89 $
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  module Kwalify
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 83 $
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  class CommandOptionError < StandardError
@@ -1,6 +1,6 @@
1
1
  ###
2
- ### $Rev: 84 $
3
- ### 0.7.1
2
+ ### $Rev$
3
+ ### 0.7.2
4
4
  ### $COPYRIGHT$
5
5
  ###
6
6
 
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 83 $
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  require 'yaml'
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 99 $
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  require 'kwalify/messages'
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 81 $
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  require 'kwalify/messages'
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 90 $
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  require File.dirname(__FILE__) + '/test.rb'
@@ -1,7 +1,7 @@
1
1
  ##
2
- ## $Rev: 95 $
3
- ## $Release: 0.7.1 $
4
- ## copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ## $Rev$
3
+ ## $Release: 0.7.2 $
4
+ ## copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ##
6
6
  ---
7
7
  - name: action_genclass_ruby1
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 99 $
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  require File.dirname(__FILE__) + '/test.rb'
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 63 $
3
- ## $Release: 0.7.1 $
4
- ## copyright(c) 2005-2008 kuwata-lab all rights reserved.
3
+ ## $Release: 0.7.2 $
4
+ ## copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ##
6
6
  ---
7
7
 
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 90 $
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  require File.dirname(__FILE__) + '/test.rb'
@@ -1,7 +1,7 @@
1
1
  ##
2
- ## $Rev: 93 $
3
- ## $Release: 0.7.1 $
4
- ## copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ## $Rev$
3
+ ## $Release: 0.7.2 $
4
+ ## copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ##
6
6
  ---
7
7
  - name: parseOptions1
@@ -382,3 +382,34 @@
382
382
  #java: "*USER: anchor not found."
383
383
  expected: |
384
384
  ##
385
+ ---
386
+ - name: empty1
387
+ desc: ignore first empty document
388
+ method: execute
389
+ args: [ -f, empty1.schema, empty1.document ]
390
+ schema: |
391
+ type: map
392
+ mapping:
393
+ "name": { type: str }
394
+ document: |
395
+ ---
396
+ name: Foo
397
+ expected: |
398
+ empty1.document#0: valid.
399
+
400
+ - name: empty2
401
+ desc: report 'empty.' when document is empty
402
+ method: execute
403
+ args: [ -f, empty2.schema, empty2.document ]
404
+ schema: |
405
+ type: map
406
+ mapping:
407
+ "name": { type: str }
408
+ document: |
409
+ ---
410
+ name: Foo
411
+ ---
412
+ expected: |
413
+ empty2.document#0: valid.
414
+ empty2.document#1: empty.
415
+
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 83 $
3
- ### $Release: 0.7.1 $
4
- ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  require File.dirname(__FILE__) + '/test.rb'