Class: YamlWrapper

Inherits:
Object show all
Defined in:
lib/ceedling/yaml_wrapper.rb

Instance Method Summary collapse

Instance Method Details

#dump(filepath, structure) ⇒ Object



31
32
33
34
35
# File 'lib/ceedling/yaml_wrapper.rb', line 31

def dump(filepath, structure)
  File.open(filepath, 'w') do |output|
    YAML.dump(structure, output)
  end
end

#load(filepath) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/ceedling/yaml_wrapper.rb', line 14

def load(filepath)
  source = ERB.new(File.read(filepath)).result
  begin
    return YAML.load(source, aliases: true)
  rescue ArgumentError
    return YAML.load(source)
  end
end

#load_string(source) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/ceedling/yaml_wrapper.rb', line 23

def load_string(source)
  begin
    return YAML.load(source, aliases: true)
  rescue ArgumentError
    return YAML.load(source)
  end
end