Module: Canals::Tools::YAML

Defined in:
lib/canals/tools/yaml.rb

Class Method Summary collapse

Class Method Details

.dump_file(filename, content) ⇒ Object



17
18
19
20
21
# File 'lib/canals/tools/yaml.rb', line 17

def self.dump_file(filename, content)
  File.open(filename, 'w') do |f|
    f.write(self.to_yaml(content))
  end
end

.load(content) ⇒ Object



7
8
9
# File 'lib/canals/tools/yaml.rb', line 7

def self.load(content)
  Psych.load(content, symbolize_names: true)
end

.load_file(filename) ⇒ Object



11
12
13
14
15
# File 'lib/canals/tools/yaml.rb', line 11

def self.load_file(filename)
  File.open(filename, 'r:bom|utf-8') { |f|
    Psych.load(f, filename, fallback: false, symbolize_names: true)
  }
end

.to_yaml(content) ⇒ Object



23
24
25
# File 'lib/canals/tools/yaml.rb', line 23

def self.to_yaml(content)
  Psych.dump(content)
end