Extensions to make YAML even more useful.
Add this line to your application’s Gemfile:
gem 'yaml_extensions'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install yaml_extensions
Just require yaml_extensions
. For now this will freedom patch the
YAML module to extend its functionality.
require 'yaml_extensions'
Deep Merge any key-value-list by replacing YAML’s regular Merge Key
<<
with <<<
. Example:
defaults: &DEFAULTS
hello: world
this:
is:
even: deeper
main:
<<<: *DEFAULTS
this:
is:
somewhat: deep
will be interpreted as
defaults:
hello: world
this:
is:
even: deeper
main:
this:
is:
somewhat: deep
even: deeper
hello: world
This does not acutally patch the parser, but runs a transformation on
the already parse data structure. Multiple deep merges can be achieved
by appending digits to <<<
. Exmaple:
defaults: &DEFAULTS
hello: world
this:
is:
even: deeper
overrides: &OVERRIDES
this:
is:
even: deeper, i tell you
main:
<<<1: *DEFAULTS
<<<2: *OVERRIDES
this:
is:
somewhat: deep
will be interpreted as
defaults:
hello: world
this:
is:
even: deeper
overrides:
this:
is:
even: deeper, i tell you
main:
this:
is:
somewhat: deep
even: deeper, i tell you
hello: world
After checking out the repo, run bin/setup
to install dependencies.
Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run
bundle exec rake install
. To release a new version, update the version
number in version.rb
, and then run bundle exec rake release
, which
will create a git tag for the version, push git commits and tags, and
push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/200ok-ch/yaml_extensions. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the YamlExtensions project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.