Module: Kwalify::Yaml

Defined in:
lib/kwalify.rb,
lib/kwalify/parser/yaml.rb

Defined Under Namespace

Classes: Parser

Class Method Summary collapse

Class Method Details

.load(yaml_str, opts = {}) ⇒ Object

read yaml_str, parse it, and return yaml document.

opts: ::validator: Kwalify::Validator object ::preceding_aliass: allow preceding alias if true ::data_binding: enable data binding if true ::untabify: expand tab chars if true ::filename: filename



45
46
47
48
49
50
51
52
53
# File 'lib/kwalify.rb', line 45

def self.load(yaml_str, opts={})
  #require 'kwalify/parser/yaml'
  parser = Kwalify::Yaml::Parser.new(opts[:validator])
  parser.preceding_alias = true if opts[:preceding_alias]
  parser.data_binding    = true if opts[:data_binding]
  yaml_str = Kwalify::Util.untabify(yaml_str) if opts[:untabify]
  ydoc = parser.parse(yaml_str, :filename=>opts[:filename])
  return ydoc
end

.load_file(filename, opts = {}) ⇒ Object

read file, parse it, and return yaml document. see Kwalify::Yaml::Parser.load()



57
58
59
60
# File 'lib/kwalify.rb', line 57

def self.load_file(filename, opts={})
  opts[:filename] = filename
  return self.load(File.read(filename), opts)
end