Module: DTK::DSL::YamlHelper

Defined in:
lib/dsl/yaml_helper.rb

Class Method Summary collapse

Class Method Details

.generate(yaml_object) ⇒ Object

yaml_object can be a ::Hash or child of a ::Hash



31
32
33
# File 'lib/dsl/yaml_helper.rb', line 31

def self.generate(yaml_object)
  ::YAML.dump(convert_for_yaml_dump(yaml_object))
end

.parse(file_obj) ⇒ Object

Returns hash if succsefully parse; otherwise raises error



22
23
24
25
26
27
28
# File 'lib/dsl/yaml_helper.rb', line 22

def self.parse(file_obj)
  begin
    ::YAML.load(file_obj.content)
  rescue Exception => e
    raise Error::Usage, yaml_parsing_error_msg(e, file_obj)
  end
end