bogy is tiny Ruby tool, which provides a little more convenient interaction with YAML

Gem Version Build Status Dependency Status Code Climate

Installation

gem install bogy

or

add gem 'bogy' to your application's Gemfile

Available methods

# Parsing files
path = 'file.yml'
yaml = Bogy.new(file: path)

# Parsing hashes
hash = { 'a' => 1, 'b' => 2 }
yaml = Bogy.new(hash: hash)

# Parsing strings
string = "---\na: 1\nb: 2\n" # Looks {'a' => 1, 'b' => 2} as hash
yaml = Bogy.new(string: string)

yaml = Bogy.new(file: path)
yaml['foo'] = 'bar' # => "bar". Automatically writes changes to file, if you parse file
yaml['foo'] # => "bar"
yaml.delete('foo') # => "bar". Also automatically writes changes to file, if you parse file
yaml.to_h # => {'a'=>1, 'b'=>2}
yaml.to_yaml # => ---\na: 1\nb: 2\n"
yaml.write_to_file('yaml_file.yml') # Converts to YAML and writes to 'yaml_file.yml' file

License

MIT License