-
Notifications
You must be signed in to change notification settings - Fork 6
/
CHANGES.txt
243 lines (182 loc) · 7.47 KB
/
CHANGES.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
.=title: ChangeLog
.?release: $Release: 0.7.1 $
.?lastupdate: $Date: 2008-01-28 15:27:12 +0900 (Mon, 28 Jan 2008) $
.?version: $Rev: 99 $
.: Release 0.7.1 (2008-01-28)
.* bugfix:
.- 'Duplicated key' error is now not raised if corresponding rule
has 'default:' constraint.
.- Path is now copied in Kwalify::ValidationError#initialize()
.: Release 0.7.0 (2008-01-27)
.* enhancements:
.- YAML parser is rewrited from scratch.
The new parser class Kwalify::Yaml::Parser is available.
The old parser class Kwalify::YamlParser is stil available,
but it is not recommended to use.
.- Validator is integrated with yaml parser.
It is able to parse and validate at once.
.--------------------
## create validator
require 'kwalify'
schema = Kwalify::Yaml.load_file('schema.yaml')
validator = Kwalify::Validator.new(schema)
## parse with validation
parser = Kwalify::Yaml::Parser.new(validator)
ydoc = parser.parse(File.read('data.yaml'))
## show validation errors if exist
errors = parser.errors()
if errors && !errors.empty?
for e in errors
puts "** %d:%d [%s] %s" % [e.linenum, e.column, e.path, e.message]
end
end
.--------------------
.- Data binding is integrated into Kwalify::Yaml::Parser.
If you set Kwalify::Yaml::Parser#data_binding to true
and you specified class names in schema file,
parser creates instance objects instead of Hash objects.
It means that you don't need to add '!ruby/Classname'
for each data.
.? schema file (config.schema.yaml)
.--------------------
type: map
class: Config
mapping:
"host": { type: str, required: true }
"port": { type: int }
"user": { type: str, required: true }
"pass": { type: str, required: true }
.--------------------
.? configuration file (config.yaml)
.--------------------
host: localhost
port: 8080
user: user1
pass: password1
.--------------------
.? ruby program (ex1.rb)
.--------------------
## class definition
require 'kwalify/util/hashlike'
class Config
include Kwalify::Util::HashLike # defines [], []=, ...
attr_accessor :host, :posrt, :user, :pass
end
## create validator object
require 'kwalify'
schema = Kwalify::Yaml.load_file('config.schema.yaml')
validator = Kwalify::Validator.new(schema)
## parse configuration file with data binding
parser = Kwalify::Yaml::Parser.new(validator)
parser.data_binding = true # enable data binding
config = parser.parse_file('config.yaml')
p config #=> #<Config:0x542590 @user="user1", @port=8080,
# @pass="password1", @host="localhost">
.--------------------
.- Preceding alias supported.
If you set Kwalify::Yaml::Parser#preceding_alias to true,
parser allows aliases to apprear before corresponding anchor
appears.
This is very useful when node graph is complex.
.--------------------
- name: Foo
parent: *bar # preceding alias
- &bar
name: Bar
parent: *baz # preceding alias
- &baz
name: Baz
.--------------------
.- New command-line option '-P' enables preceding alias.
.- Kwalify::Yaml.load() and Kwalify::Yaml.load_file() are added.
They are similar to YAML.load() and YAML.load_file() but they
use Kwalify::Yaml::Parser object.
.- New utilify method Kwalify::Util.traverse_schema() provided.
.--------------------
require 'kwalify'
require 'kwalify/util'
schema = Kwalify::Yaml.load('schema.yaml')
Kwalify::Util.traverse_schema(schema) do |rulehash|
if classname = rulehash['class']
## add namespace to class name
rulehash['class'] = "Foo::Bar::#{classname}"
end
end
.--------------------
.- Add 'kwalify/util/hashlike.rb' which contains definition of
Kwalify::Util::HashLike module.
This module defines [], []=, keys(), key?(), and each() methods,
and these are required for data-binding.
.- Action 'genclass-ruby' supports '--hashlike' property.
.- Action 'genclass-ruby' supports '--initialize=false' property.
.- Add action 'geclass-php'
.- '\xXX' and '\uXXXX' are supported in Kwalify::Yaml::Parser.
.- New constrant 'default:' is added to kwalify.schema.yaml.
This constrant have no effect to validation and parsing,
and it is used only in 'genclass-xxx' action.
.* changes:
.- Action 'genclass-ruby' and 'genclass-java' are changed to
generate boolean accessors.
For example, attribute 'active' is specified as 'type: bool'
in schema file, action 'genclass-ruby' generates
"def active? ; @active; end"
and action 'genclass-java' generates
"public boolean isActive() { return _active; }".
.- Command-line option '-s' (silent) is obsolete and replaced with
'-q' (quiet). Option '-s' is still available but it is recommended
to use '-q'.
.- License is changed from LGPL to MIT-LICENSE.
.: Release 0.6.0 (2006-05-30)
.* enhancements:
.- Class definition generation support.
New command-line option '-a genclass-ruby' or '-a genclass-java' generates
class definitions in Ruby or Java from schema file.
.: Release 0.5.1 (2005-12-20)
.* enhances:
.- add new command-line option '-E' which show errors in emacs-compatible style.
.: Release 0.5.0 (2005-12-17)
.* enhancements:
.- Meta-validation check for 'max < min', 'max-ex <= min-ex', and so on.
.- Many test-cases are added
.* changes:
.- 'Parser' class is renamed to 'YamlParser'
.- 'PlainParser' class is renamed to 'PlainYamlParser'
.- YamlParser#set_error_linenums() is renamed to set_errors_linenum()
.- ValidatorError#<=> added
.- ParseError class is renamed to YamlSyntaxError
.: Release 0.4.1 (2005-10-26)
.* bugfix:
.- Support Ruby 1.8.3 (around YAML::Syck::DomainType)
.- Show correct error line number when key is undefined or unknown.
.: Release 0.4.0 (2005-10-25)
.* enhancements:
.- New command-line option '-l' prints error line numbers.
.- Supports default rule of mapping.
.: Release 0.3.0 (2005-09-30)
.* enhancements:
.- Support 'max-ex' and 'min-ex' (max/min exclusive) support with 'range:'
.- Support 'max-ex' and 'min-ex' (max/min exclusive) support with 'length:'
.- Support 'unique' constraint
.: Release 0.2.0 (2005-09-25)
.* enhancements:
.- New type 'scalar' and 'timestamp' added
.- Add new rule 'range:' which validates value range.
See users' guide for details.
.- Add new rule 'length:' which validate length of string value.
See users' guide for details.
.- Add experimental rule 'assert:' which validates value with an
expression. See users' guide for details.
.- New method 'Kwalify::Validator#validate_hook()' is added.
This method is called by Kwalify::Validator#validate().
See users' guide for details.
.- New class 'MetaValidator' added.
.- New test script 'test/test-metavalidator.rb' added.
.* changes:
.- Type name changed to suite YAML data type:
.= string -> str
.= integer -> int
.= boolean -> bool
.- Error index starts with 0 (before starts with 1).
.- Class 'Schema' is renamed to 'Rule'.
.: Release 0.1.0 (2005-08-01)
.- beta release