kwalify 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +12 -3
- data/MIT-LICENSE +1 -1
- data/README.txt +10 -10
- data/bin/kwalify +3 -3
- data/contrib/inline-require +54 -28
- data/contrib/kwalify +45 -44
- data/doc-api/classes/CommandOptionError.html +7 -7
- data/doc-api/classes/CommandOptionParser.html +18 -18
- data/doc-api/classes/Kwalify.html +1 -1
- data/doc-api/classes/Kwalify/AssertionError.html +6 -6
- data/doc-api/classes/Kwalify/BaseParser.html +60 -60
- data/doc-api/classes/Kwalify/CommandOptionError.html +6 -6
- data/doc-api/classes/Kwalify/Main.html +30 -30
- data/doc-api/classes/Kwalify/MetaValidator.html +18 -18
- data/doc-api/classes/Kwalify/Parser.html +6 -6
- data/doc-api/classes/Kwalify/PlainYamlParser.html +90 -90
- data/doc-api/classes/Kwalify/PlainYamlParser/Alias.html +6 -6
- data/doc-api/classes/Kwalify/Rule.html +24 -24
- data/doc-api/classes/Kwalify/SchemaError.html +6 -6
- data/doc-api/classes/Kwalify/SyntaxError.html +12 -12
- data/doc-api/classes/Kwalify/Util.html +8 -7
- data/doc-api/classes/Kwalify/ValidationError.html +6 -6
- data/doc-api/classes/Kwalify/Validator.html +39 -39
- data/doc-api/classes/Kwalify/YamlParser.html +84 -84
- data/doc-api/created.rid +1 -1
- data/doc-api/files/__/README_txt.html +11 -11
- data/doc-api/files/kwalify/errors_rb.html +2 -2
- data/doc-api/files/kwalify/main_rb.html +2 -2
- data/doc-api/files/kwalify/messages_rb.html +2 -2
- data/doc-api/files/kwalify/meta-validator_rb.html +2 -2
- data/doc-api/files/kwalify/parser/base_rb.html +2 -2
- data/doc-api/files/kwalify/parser/yaml_rb.html +2 -2
- 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 +2 -2
- data/doc-api/files/kwalify/util/hashlike_rb.html +2 -2
- data/doc-api/files/kwalify/util/option-parser_rb.html +2 -2
- data/doc-api/files/kwalify/util/ordered-hash_rb.html +2 -2
- data/doc-api/files/kwalify/util/testcase-helper_rb.html +2 -2
- data/doc-api/files/kwalify/util_rb.html +2 -2
- 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 +2 -2
- data/doc-api/fr_method_index.html +70 -70
- data/doc/users-guide.html +1 -1
- data/examples/address-book/address-book.schema.yaml +2 -2
- data/examples/invoice/invoice.schema.yaml +3 -3
- data/examples/tapkit/tapkit.schema.yaml +2 -2
- data/lib/kwalify.rb +3 -3
- data/lib/kwalify/errors.rb +3 -3
- data/lib/kwalify/kwalify.schema.yaml +3 -3
- data/lib/kwalify/main.rb +4 -4
- data/lib/kwalify/messages.rb +3 -3
- data/lib/kwalify/meta-validator.rb +3 -3
- data/lib/kwalify/parser/base.rb +3 -3
- data/lib/kwalify/parser/yaml.rb +3 -3
- data/lib/kwalify/rule.rb +3 -3
- data/lib/kwalify/templates/genclass-java.eruby +3 -3
- data/lib/kwalify/templates/genclass-php.eruby +2 -2
- data/lib/kwalify/templates/genclass-ruby.eruby +3 -3
- data/lib/kwalify/types.rb +3 -3
- data/lib/kwalify/util.rb +6 -5
- data/lib/kwalify/util/assert-text-equal.rb +3 -3
- data/lib/kwalify/util/hash-interface.rb +3 -3
- data/lib/kwalify/util/hashlike.rb +3 -3
- data/lib/kwalify/util/option-parser.rb +3 -3
- data/lib/kwalify/util/ordered-hash.rb +2 -2
- data/lib/kwalify/util/testcase-helper.rb +3 -3
- data/lib/kwalify/validator.rb +3 -3
- data/lib/kwalify/yaml-parser.rb +3 -3
- data/test/test-action.rb +3 -3
- data/test/test-action.yaml +3 -3
- data/test/test-databinding.rb +3 -3
- data/test/test-databinding.yaml +2 -2
- data/test/test-main.rb +3 -3
- data/test/test-main.yaml +34 -3
- data/test/test-metavalidator.rb +3 -3
- data/test/test-metavalidator.yaml +3 -3
- data/test/test-parser-yaml.rb +3 -3
- data/test/test-parser-yaml.yaml +3 -3
- data/test/test-rule.rb +3 -3
- data/test/test-rule.yaml +3 -3
- data/test/test-util.rb +125 -0
- data/test/test-validator.rb +3 -3
- data/test/test-validator.yaml +3 -3
- data/test/test-yaml-parser.rb +3 -3
- data/test/test-yaml-parser.yaml +4 -4
- data/test/test.rb +4 -3
- metadata +56 -55
data/test/test-parser-yaml.rb
CHANGED
data/test/test-parser-yaml.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
##
|
2
2
|
## $Rev: 59 $
|
3
|
-
## $Release: 0.7.
|
4
|
-
## copyright(c) 2005-
|
3
|
+
## $Release: 0.7.2 $
|
4
|
+
## copyright(c) 2005-2010 kuwata-lab all rights reserved.
|
5
5
|
##
|
6
6
|
---
|
7
7
|
name: sequence1
|
@@ -1248,7 +1248,7 @@ expected*:
|
|
1248
1248
|
[{"type"=>"map",
|
1249
1249
|
"mapping"=>
|
1250
1250
|
{"name"=>{"type"=>"str"},
|
1251
|
-
"post"=>{"
|
1251
|
+
"post"=>{"enum"=>["exective", "manager", "clerk"], "type"=>"str"},
|
1252
1252
|
"supervisor"=>{...}}}],
|
1253
1253
|
"type"=>"seq"}
|
1254
1254
|
java: |
|
data/test/test-rule.rb
CHANGED
data/test/test-rule.yaml
CHANGED
data/test/test-util.rb
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
###
|
2
|
+
### $Rev$
|
3
|
+
### $Release: 0.7.2 $
|
4
|
+
### copyright(c) 2005-2010 kuwata-lab all rights reserved.
|
5
|
+
###
|
6
|
+
|
7
|
+
require File.dirname(__FILE__) + '/test.rb'
|
8
|
+
|
9
|
+
require 'kwalify/util'
|
10
|
+
|
11
|
+
|
12
|
+
class UtilTest < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def spec(detail)
|
15
|
+
yield
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_untabify
|
19
|
+
spec "converts tab characters to spaces" do
|
20
|
+
input = "123\t999"
|
21
|
+
expected = "123 999"
|
22
|
+
assert_text_equal expected, Kwalify::Util.untabify(input)
|
23
|
+
end
|
24
|
+
spec "able to specify column width" do
|
25
|
+
input = "12\t999"
|
26
|
+
expected = "12 999"
|
27
|
+
assert_text_equal expected, Kwalify::Util.untabify(input, 4)
|
28
|
+
end
|
29
|
+
spec "able to handle multiline string" do
|
30
|
+
input = "123\n\t456\n789\t0"
|
31
|
+
expected = "123\n 456\n789 0"
|
32
|
+
assert_text_equal expected, Kwalify::Util.untabify(input)
|
33
|
+
end
|
34
|
+
spec "returns nil if argument is nil" do
|
35
|
+
assert_nil Kwalify::Util.untabify(nil)
|
36
|
+
end
|
37
|
+
spec "don't remove tailing spaces" do # bugfix
|
38
|
+
input = "abc\t\t"
|
39
|
+
expected = "abc "
|
40
|
+
assert_text_equal expected, Kwalify::Util.untabify(input)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
SCHEMA1 = <<END
|
45
|
+
type: seq
|
46
|
+
sequence:
|
47
|
+
- type: map
|
48
|
+
class: Member
|
49
|
+
mapping:
|
50
|
+
"name": { type: str, required: true }
|
51
|
+
"age": { type: int, required: false }
|
52
|
+
END
|
53
|
+
|
54
|
+
def test_traverse
|
55
|
+
spec "traverse schema structure" do
|
56
|
+
schema = YAML.load(SCHEMA1)
|
57
|
+
assert_equal "Member", schema["sequence"][0]["class"]
|
58
|
+
Kwalify::Util.traverse_schema(schema) do |rulehash|
|
59
|
+
## add module prefix to class name
|
60
|
+
if rulehash['class']
|
61
|
+
rulehash['class'] = 'MyModule::' + rulehash['class']
|
62
|
+
end
|
63
|
+
end
|
64
|
+
assert_equal "MyModule::Member", schema["sequence"][0]["class"]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_traverse_rule
|
69
|
+
spec "traverse rule" do
|
70
|
+
schema = YAML.load(SCHEMA1)
|
71
|
+
validator = Kwalify::Validator.new(schema)
|
72
|
+
rules = []
|
73
|
+
Kwalify::Util.traverse_rule(validator) do |rule|
|
74
|
+
rules << rule
|
75
|
+
end
|
76
|
+
assert_equal 4, rules.length
|
77
|
+
assert_text_equal <<'END', rules[0].send(:_inspect)
|
78
|
+
type: seq
|
79
|
+
klass: Array
|
80
|
+
-
|
81
|
+
type: map
|
82
|
+
klass: Hash
|
83
|
+
"name":
|
84
|
+
type: str
|
85
|
+
klass: String
|
86
|
+
required: true
|
87
|
+
"age":
|
88
|
+
type: int
|
89
|
+
klass: Integer
|
90
|
+
required: false
|
91
|
+
END
|
92
|
+
assert_text_equal <<'END', rules[1].send(:_inspect)
|
93
|
+
type: map
|
94
|
+
klass: Hash
|
95
|
+
"name":
|
96
|
+
type: str
|
97
|
+
klass: String
|
98
|
+
required: true
|
99
|
+
"age":
|
100
|
+
type: int
|
101
|
+
klass: Integer
|
102
|
+
required: false
|
103
|
+
END
|
104
|
+
assert_text_equal <<'END', rules[2].send(:_inspect)
|
105
|
+
type: str
|
106
|
+
klass: String
|
107
|
+
required: true
|
108
|
+
END
|
109
|
+
assert_text_equal <<'END', rules[3].send(:_inspect)
|
110
|
+
type: int
|
111
|
+
klass: Integer
|
112
|
+
required: false
|
113
|
+
END
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_get_value
|
118
|
+
schema = YAML.load(SCHEMA1)
|
119
|
+
path = ['sequence', 0, 'mapping', 'name', 'type']
|
120
|
+
assert_equal 'str', Kwalify::Util.get_value(schema, path)
|
121
|
+
path = ['sequence', 1, 'mapping', 'name', 'type']
|
122
|
+
assert_equal nil, Kwalify::Util.get_value(schema, path)
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
data/test/test-validator.rb
CHANGED
data/test/test-validator.yaml
CHANGED
data/test/test-yaml-parser.rb
CHANGED
data/test/test-yaml-parser.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
##
|
2
|
-
## $Rev
|
3
|
-
## $Release: 0.7.
|
4
|
-
## copyright(c) 2005-
|
2
|
+
## $Rev$
|
3
|
+
## $Release: 0.7.2 $
|
4
|
+
## copyright(c) 2005-2010 kuwata-lab all rights reserved.
|
5
5
|
##
|
6
6
|
---
|
7
7
|
name: sequence1
|
@@ -909,7 +909,7 @@ expected*:
|
|
909
909
|
[{"type"=>"map",
|
910
910
|
"mapping"=>
|
911
911
|
{"name"=>{"type"=>"str"},
|
912
|
-
"post"=>{"
|
912
|
+
"post"=>{"enum"=>["exective", "manager", "clerk"], "type"=>"str"},
|
913
913
|
"supervisor"=>{...}}}],
|
914
914
|
"type"=>"seq"}
|
915
915
|
java: |
|
data/test/test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
###
|
2
|
-
### $Rev
|
3
|
-
### $Release: 0.7.
|
4
|
-
### copyright(c) 2005-
|
2
|
+
### $Rev$
|
3
|
+
### $Release: 0.7.2 $
|
4
|
+
### copyright(c) 2005-2010 kuwata-lab all rights reserved.
|
5
5
|
###
|
6
6
|
|
7
7
|
unless defined?(TESTDIR)
|
@@ -50,6 +50,7 @@ if $0 == __FILE__
|
|
50
50
|
require 'test-main.rb'
|
51
51
|
require 'test-action.rb'
|
52
52
|
require 'test-users-guide.rb'
|
53
|
+
require 'test-util.rb'
|
53
54
|
|
54
55
|
#suite = Test::Unit::TestSuite.new()
|
55
56
|
#suite << ValidatorTest.suite()
|
metadata
CHANGED
@@ -1,50 +1,45 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.2
|
3
|
-
specification_version: 1
|
4
2
|
name: kwalify
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
-
|
11
|
-
|
12
|
-
|
13
|
-
rubyforge_project:
|
14
|
-
description: Kwalify is a parser, schema validator, and data binding tool for YAML and JSON.
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: false
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
hash: 7
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 7
|
9
|
+
- 2
|
10
|
+
version: 0.7.2
|
25
11
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
12
|
authors:
|
30
13
|
- makoto kuwata
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-07-18 00:00:00 +09:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: " Kwalify is a parser, schema validator, and data binding tool for YAML and JSON.\n"
|
23
|
+
email:
|
24
|
+
executables:
|
25
|
+
- kwalify
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
31
30
|
files:
|
32
|
-
- lib/kwalify
|
33
31
|
- lib/kwalify/errors.rb
|
34
32
|
- lib/kwalify/kwalify.schema.yaml
|
35
33
|
- lib/kwalify/main.rb
|
36
34
|
- lib/kwalify/messages.rb
|
37
35
|
- lib/kwalify/meta-validator.rb
|
38
|
-
- lib/kwalify/parser
|
39
36
|
- lib/kwalify/parser/base.rb
|
40
37
|
- lib/kwalify/parser/yaml.rb
|
41
38
|
- lib/kwalify/rule.rb
|
42
|
-
- lib/kwalify/templates
|
43
39
|
- lib/kwalify/templates/genclass-java.eruby
|
44
40
|
- lib/kwalify/templates/genclass-php.eruby
|
45
41
|
- lib/kwalify/templates/genclass-ruby.eruby
|
46
42
|
- lib/kwalify/types.rb
|
47
|
-
- lib/kwalify/util
|
48
43
|
- lib/kwalify/util/assert-text-equal.rb
|
49
44
|
- lib/kwalify/util/hash-interface.rb
|
50
45
|
- lib/kwalify/util/hashlike.rb
|
@@ -56,27 +51,21 @@ files:
|
|
56
51
|
- lib/kwalify/yaml-parser.rb
|
57
52
|
- lib/kwalify.rb
|
58
53
|
- bin/kwalify
|
59
|
-
- examples/address-book
|
60
54
|
- examples/address-book/address-book.schema.yaml
|
61
55
|
- examples/address-book/address-book.yaml
|
62
56
|
- examples/address-book/Makefile
|
63
|
-
- examples/data-binding
|
64
57
|
- examples/data-binding/BABEL.data.yaml
|
65
58
|
- examples/data-binding/BABEL.schema.yaml
|
66
59
|
- examples/data-binding/main.rb
|
67
60
|
- examples/data-binding/Makefile
|
68
61
|
- examples/data-binding/Rakefile
|
69
|
-
- examples/invoice
|
70
62
|
- examples/invoice/invoice.schema.yaml
|
71
63
|
- examples/invoice/invoice.yaml
|
72
64
|
- examples/invoice/Makefile
|
73
|
-
- examples/tapkit
|
74
65
|
- examples/tapkit/main.rb
|
75
66
|
- examples/tapkit/Makefile
|
76
67
|
- examples/tapkit/tapkit.schema.yaml
|
77
68
|
- examples/tapkit/tapkit.yaml
|
78
|
-
- test/data
|
79
|
-
- test/data/users-guide
|
80
69
|
- test/data/users-guide/address_book.rb
|
81
70
|
- test/data/users-guide/address_book.schema.yaml
|
82
71
|
- test/data/users-guide/address_book.yaml
|
@@ -176,6 +165,7 @@ files:
|
|
176
165
|
- test/test-rule.rb
|
177
166
|
- test/test-rule.yaml
|
178
167
|
- test/test-users-guide.rb
|
168
|
+
- test/test-util.rb
|
179
169
|
- test/test-validator.rb
|
180
170
|
- test/test-validator.yaml
|
181
171
|
- test/test-yaml-parser.rb
|
@@ -183,10 +173,8 @@ files:
|
|
183
173
|
- test/test.rb
|
184
174
|
- contrib/inline-require
|
185
175
|
- contrib/kwalify
|
186
|
-
- doc-api/classes
|
187
176
|
- doc-api/classes/CommandOptionError.html
|
188
177
|
- doc-api/classes/CommandOptionParser.html
|
189
|
-
- doc-api/classes/Kwalify
|
190
178
|
- doc-api/classes/Kwalify/AssertionError.html
|
191
179
|
- doc-api/classes/Kwalify/BaseError.html
|
192
180
|
- doc-api/classes/Kwalify/BaseParser.html
|
@@ -198,43 +186,34 @@ files:
|
|
198
186
|
- doc-api/classes/Kwalify/Main.html
|
199
187
|
- doc-api/classes/Kwalify/MetaValidator.html
|
200
188
|
- doc-api/classes/Kwalify/Parser.html
|
201
|
-
- doc-api/classes/Kwalify/PlainYamlParser
|
202
189
|
- doc-api/classes/Kwalify/PlainYamlParser/Alias.html
|
203
190
|
- doc-api/classes/Kwalify/PlainYamlParser.html
|
204
191
|
- doc-api/classes/Kwalify/Rule.html
|
205
192
|
- doc-api/classes/Kwalify/SchemaError.html
|
206
193
|
- doc-api/classes/Kwalify/SyntaxError.html
|
207
194
|
- doc-api/classes/Kwalify/Types.html
|
208
|
-
- doc-api/classes/Kwalify/Util
|
209
195
|
- doc-api/classes/Kwalify/Util/HashLike.html
|
210
196
|
- doc-api/classes/Kwalify/Util/OrderedHash.html
|
211
197
|
- doc-api/classes/Kwalify/Util.html
|
212
198
|
- doc-api/classes/Kwalify/ValidationError.html
|
213
199
|
- doc-api/classes/Kwalify/Validator.html
|
214
|
-
- doc-api/classes/Kwalify/Yaml
|
215
200
|
- doc-api/classes/Kwalify/Yaml/Parser.html
|
216
201
|
- doc-api/classes/Kwalify/Yaml.html
|
217
202
|
- doc-api/classes/Kwalify/YamlParser.html
|
218
203
|
- doc-api/classes/Kwalify/YamlSyntaxError.html
|
219
204
|
- doc-api/classes/Kwalify.html
|
220
|
-
- doc-api/classes/Test
|
221
205
|
- doc-api/classes/Test/Unit.html
|
222
206
|
- doc-api/classes/Test.html
|
223
207
|
- doc-api/created.rid
|
224
|
-
- doc-api/files
|
225
|
-
- doc-api/files/__
|
226
208
|
- doc-api/files/__/README_txt.html
|
227
|
-
- doc-api/files/kwalify
|
228
209
|
- doc-api/files/kwalify/errors_rb.html
|
229
210
|
- doc-api/files/kwalify/main_rb.html
|
230
211
|
- doc-api/files/kwalify/messages_rb.html
|
231
212
|
- doc-api/files/kwalify/meta-validator_rb.html
|
232
|
-
- doc-api/files/kwalify/parser
|
233
213
|
- doc-api/files/kwalify/parser/base_rb.html
|
234
214
|
- doc-api/files/kwalify/parser/yaml_rb.html
|
235
215
|
- doc-api/files/kwalify/rule_rb.html
|
236
216
|
- doc-api/files/kwalify/types_rb.html
|
237
|
-
- doc-api/files/kwalify/util
|
238
217
|
- doc-api/files/kwalify/util/assert-text-equal_rb.html
|
239
218
|
- doc-api/files/kwalify/util/hash-interface_rb.html
|
240
219
|
- doc-api/files/kwalify/util/hashlike_rb.html
|
@@ -257,17 +236,39 @@ files:
|
|
257
236
|
- CHANGES.txt
|
258
237
|
- MIT-LICENSE
|
259
238
|
- setup.rb
|
260
|
-
|
261
|
-
-
|
262
|
-
|
263
|
-
|
264
|
-
extra_rdoc_files: []
|
239
|
+
has_rdoc: true
|
240
|
+
homepage: http://www.kuwata-lab.com/kwalify/
|
241
|
+
licenses: []
|
265
242
|
|
266
|
-
|
267
|
-
|
268
|
-
extensions: []
|
243
|
+
post_install_message:
|
244
|
+
rdoc_options: []
|
269
245
|
|
246
|
+
require_paths:
|
247
|
+
- lib
|
248
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
249
|
+
none: false
|
250
|
+
requirements:
|
251
|
+
- - ">="
|
252
|
+
- !ruby/object:Gem::Version
|
253
|
+
hash: 3
|
254
|
+
segments:
|
255
|
+
- 0
|
256
|
+
version: "0"
|
257
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
258
|
+
none: false
|
259
|
+
requirements:
|
260
|
+
- - ">="
|
261
|
+
- !ruby/object:Gem::Version
|
262
|
+
hash: 3
|
263
|
+
segments:
|
264
|
+
- 0
|
265
|
+
version: "0"
|
270
266
|
requirements: []
|
271
267
|
|
272
|
-
|
273
|
-
|
268
|
+
rubyforge_project:
|
269
|
+
rubygems_version: 1.3.7
|
270
|
+
signing_key:
|
271
|
+
specification_version: 3
|
272
|
+
summary: a parser, schema validator, and data-binding tool for YAML and JSON.
|
273
|
+
test_files:
|
274
|
+
- test/test.rb
|