bogy is Ruby wrapper for YAML, which provides a little more convenient interaction with YAML
Installation
$ gem install bogy
Available methods
# Parsing files
path = 'file.yml'
yaml = Bogy.new(file: path)
# Parsing strings
string = "---\n:a: 1\n:b: 2\n" # Looks {a: 1, b: 2} as hash
yaml = Bogy.new(string: string)
yaml['foo'] = 'bar' # => "bar". Automatically writes to file, if you parse file
yaml['foo'] # => "bar"
yaml.delete('foo') # => "bar". Also automatically writes to file, if you parse file
yaml.to_h # => {:a=>1, :b=>2}
yaml.to_yaml # => ---\n:a: 1\n:b: 2\n"
yaml.write_to_file('another_yaml_file.yml') # Writes to 'another_yaml_file.yml' file
# Also you can easy convert hash to YAML and write it to file
hash = {a: 1, b:2}
Bogy.new(hash: hash).write_to_file('file.yml') # Automatically converts to YAML
License
MIT License