Introduction
bogy is YAML wrapper, which provides a little more convenient interaction with YAML
Installation
Add this line to your application's Gemfile:
gem 'bogy'
And then execute:
$ bundle
Or install it yourself as:
$ gem install bogy
Usage
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
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/bogem/bogy.