An open API service indexing awesome lists of open source software.

https://github.com/200ok-ch/yaml_extensions

Extensions to make YAML even more useful
https://github.com/200ok-ch/yaml_extensions

Last synced: 9 days ago
JSON representation

Extensions to make YAML even more useful

Awesome Lists containing this project

README

          

* YamlExtensions
:PROPERTIES:
:CUSTOM_ID: yamlextensions
:END:

Extensions to make YAML even more useful.

** Installation
:PROPERTIES:
:CUSTOM_ID: installation
:END:

Add this line to your application's Gemfile:

#+BEGIN_SRC ruby
gem 'yaml_extensions'
#+END_SRC

And then execute:

#+BEGIN_EXAMPLE
$ bundle install
#+END_EXAMPLE

Or install it yourself as:

#+BEGIN_EXAMPLE
$ gem install yaml_extensions
#+END_EXAMPLE

** Usage
:PROPERTIES:
:CUSTOM_ID: usage
:END:

Just require =yaml_extensions=. For now this will [[https://twitter.com/dhh/status/813075241236762624][freedom patch]] the
YAML module to extend its functionality.

#+begin_src ruby
require 'yaml_extensions'
#+end_src

Deep Merge any key-value-list by replacing YAML's regular Merge Key
=<<= with =<<<=. Example:

#+begin_src yaml
defaults: &DEFAULTS
hello: world
this:
is:
even: deeper

main:
<<<: *DEFAULTS
this:
is:
somewhat: deep
#+end_src

will be interpreted as

#+begin_src yaml
defaults:
hello: world
this:
is:
even: deeper

main:
this:
is:
somewhat: deep
even: deeper
hello: world
#+end_src

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:

#+begin_src yaml
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
#+end_src

will be interpreted as

#+begin_src yaml
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
#+end_src

** Development
:PROPERTIES:
:CUSTOM_ID: development
:END:

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 [[https://rubygems.org][rubygems.org]].

** Contributing
:PROPERTIES:
:CUSTOM_ID: contributing
:END:

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
[[https://github.com/branch14/yaml_extensions/blob/master/CODE_OF_CONDUCT.md][code of conduct]].

** License
:PROPERTIES:
:CUSTOM_ID: license
:END:

The gem is available as open source under the terms of the
[[https://opensource.org/licenses/MIT][MIT License]].

** Code of Conduct
:PROPERTIES:
:CUSTOM_ID: code-of-conduct
:END:

Everyone interacting in the YamlExtensions project's codebases, issue
trackers, chat rooms and mailing lists is expected to follow the
[[https://github.com/200ok-ch/yaml_extensions/blob/master/CODE_OF_CONDUCT.md][code
of conduct]].