If I end a YAML file with the last non-comment component being "- - -" (no spaces), then kwalify 0.7.1 (Ruby) dumps stack with no reasonable error message. This also happens if I follow that line with "..." For example: running on Ubuntu 10.04, with command line "kwalify -lf schema-defs.yaml junk.yaml" I get:
junk.yaml#0: valid.
/usr/lib/ruby/1.8/kwalify/main.rb:326:in `_show_errors': undefined local variable or method `kwalify' for #<Kwalify::Main:0xb76ecf14> (NameError)
from /usr/lib/ruby/1.8/kwalify/main.rb:294:in `_validate_files'
from /usr/lib/ruby/1.8/kwalify/parser/yaml.rb:171:in `parse_stream'
from /usr/lib/ruby/1.8/kwalify/main.rb:293:in `_validate_files'
from /usr/lib/ruby/1.8/kwalify/main.rb:267:in `each'
from /usr/lib/ruby/1.8/kwalify/main.rb:267:in `_validate_files'
from /usr/lib/ruby/1.8/kwalify/main.rb:215:in `validate_files'
from /usr/lib/ruby/1.8/kwalify/main.rb:111:in `execute'
from /usr/lib/ruby/1.8/kwalify/main.rb:124:in `main'
from /usr/bin/kwalify:13
Kwalify schema for object definition.
The junky file to be validated that generates the stack dump.
Thank you for reporting a bug.
Could you attach (or write) a yaml file which raises error?
Thank you for reporting bugs.
Could you append files which raises error?
I tried the followings but no errors.
schema.yaml
-------------------------------
type: map
required: true
mapping:
"name":
type: str
required: true
"age":
type: int
required: false
-------------------------------
data.yaml
-------------------------------
name: "---"
age: 20
-------------------------------
result:
-------------------------------
$ kwalify -f schema.yaml data.yaml
data.yaml#0: valid.
-------------------------------
Sorry David, you already attached files.
I'll check it. Thank you.
Fixed by the following patch.
Index: lib/kwalify/main.rb
--- lib/kwalify/main.rb (revision 97)
+++ lib/kwalify/main.rb (working copy)
@@ -323,7 +323,7 @@
end
elsif ydoc.nil?
#* key=:validation_empty msg="%s#%d: empty.\n"
- puts kwalify.msg(:validation_empty) % [filename, i]
+ puts Kwalify.msg(:validation_empty) % [filename, i]
else
#* key=:validation_valid msg="%s#%d: valid."
puts Kwalify.msg(:validation_valid) % [filename, i] unless @options[:quiet]