Class: YAMLHelper
- Inherits:
-
Object
- Object
- YAMLHelper
- Defined in:
- lib/yaml_helper.rb
Class Method Summary collapse
Class Method Details
.create_yaml(file, values) ⇒ Object
24 25 26 27 28 |
# File 'lib/yaml_helper.rb', line 24 def self.create_yaml(file, values) directory = File.dirname(file) create_directory_unless_exists(directory) File.open(file, 'w') {|f| f << YAML::dump(values) } end |
.modify_yaml(file, values) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/yaml_helper.rb', line 30 def self.modify_yaml(file, values) if File.exist?(file) config = YAML::load(File.open(file)) config.merge!(values) else config = values end create_yaml(file, config) end |