0.0
Low commit activity in last 3 years
No release in over a year
Load YAML files that deep merge other YAML files
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Extended YAML

Gem Version Build Status Maintainability


ExtendedYAML adds a couple of additional features to the standard YAML library:

  1. Each YAML file can extend (inherit from) other YAML files by specifying extends: other_file
  2. YAML files are parsed for ERB tags.

It is a simpler reimplementation of yaml_extend.

Installation

$ gem install extended_yaml

Usage

Given this simple.yml file:

extends: subdir/production.yml

settings:
  host: localhost
  port: 80

which uses extends to load this subdir/production.yml file.

settings:
  host: example.com

We can now load the extended YAML file like this:

# Load an extended YAML
require 'extended_yaml'

p ExtendedYAML.load 'examples/simple.yml'
#=> {"settings"=>{"host"=>"localhost", "port"=>80}}

Notes

  1. Arrays will be merged.
  2. Nested hashes will be merged.
  3. Other types of values will be overridden based on which loaded file was the last to define them.
  4. ERB tags will be evaluated in all YAML files.
  5. The extends option can use either a single file string, or an array. Extensions are optional.
  6. Using * anywhere in the extends path will load multiple files with one call.
  7. If you need to use a key that is named differently than extends, provide it using the key keyword argument:
    ExtendedYAML.load 'examples/simple.yml', key: 'include'

See the examples/master.yml file for additional information.