Class: Resat::KwalifyHelper
- Inherits:
-
Object
- Object
- Resat::KwalifyHelper
- Defined in:
- lib/kwalify_helper.rb
Class Method Summary collapse
-
.new_parser(schema_file) ⇒ Object
Create new parser from given schema file.
-
.parser_error(parser) ⇒ Object
Format error message from parser errors.
Class Method Details
.new_parser(schema_file) ⇒ Object
Create new parser from given schema file
11 12 13 14 15 16 17 |
# File 'lib/kwalify_helper.rb', line 11 def KwalifyHelper.new_parser(schema_file) schema = Kwalify::Yaml.load_file(schema_file) validator = Kwalify::Validator.new(schema) res = Kwalify::Yaml::Parser.new(validator) res.data_binding = true res end |
.parser_error(parser) ⇒ Object
Format error message from parser errors
20 21 22 23 24 25 26 27 |
# File 'lib/kwalify_helper.rb', line 20 def KwalifyHelper.parser_error(parser) first = true parser.errors.inject("") do |msg, e| msg << "\n" unless first first = false if first msg << "#{e.linenum}:#{e.column} [#{e.path}] #{e.}" end end |