### YAML Inheritance Structure Example Source: https://github.com/magynhard/yaml_extend/blob/master/README.md Illustrates common inheritance patterns in YAML configuration files using the 'extends:' key. ```yaml defaults.yml \ \ dev.yml int.yml prod.yml ``` ```yaml fruits.yml vegetables.yml default.yml extensions.yml \ / \ / food.yml merged.yml | another_extended.yml ``` -------------------------------- ### Install yaml_extend via Command Line Source: https://github.com/magynhard/yaml_extend/blob/master/README.md Install the gem directly using the gem install command for command-line usage. ```bash gem install yaml_extend ``` -------------------------------- ### Install yaml_extend Gem Source: https://github.com/magynhard/yaml_extend/blob/master/README.md Add the gem to your application's Gemfile and run bundle install. ```ruby gem 'yaml_extend' ``` -------------------------------- ### Using Custom Extend Key (Parameter) Source: https://github.com/magynhard/yaml_extend/blob/master/README.md Specify a custom key for inheritance by passing it as a parameter to `ext_load_file`. This is useful for one-off custom key usage. ```yaml #custom1.yml inherit_from: - 'super_file.yml' foo: 'bar' ... ``` ```ruby config = YAML.ext_load_file 'custom1.yml', 'inherit_from' ``` -------------------------------- ### Basic YAML Inheritance Source: https://github.com/magynhard/yaml_extend/blob/master/README.md Demonstrates basic YAML inheritance using 'extends' and ERB templating. The 'start.erb.yml' file extends 'super.yml', merging their data. ```yaml # start.erb.yml extends: 'super.yml' data: name: 'Mr. Superman' age: 134 # using ERB templating with ruby code foo: '<%= 'bar' %>' favorites: - 'Raspberrys' ``` ```yaml # super.yml data: name: 'Unknown' power: 2000 favorites: - 'Bananas' - 'Apples' ``` ```ruby config = YAML.ext_load_file 'start.erb.yml' ``` ```yaml data: name: 'Mr. Superman' age: 134 foo: 'bar' power: 2000 favorites: - 'Bananas' - 'Apples' - 'Raspberrys' ``` -------------------------------- ### Run yaml_extend from Command Line Source: https://github.com/magynhard/yaml_extend/blob/master/README.md Execute yaml_extend to parse and merge a YAML file. The output can be redirected to a file. ```bash yaml_extend path/to/my/yaml_file.yml ``` ```bash yaml_extend path/to/my/yaml_file.yml > combined_yaml.yml ``` -------------------------------- ### Load YAML File with Inheritance in Ruby Source: https://github.com/magynhard/yaml_extend/blob/master/README.md Use YAML.ext_load_file to load and merge YAML files, supporting inheritance. The inheritance_key is removed by default from the final output. Custom options can be passed to control merging behavior, including deep merge options. ```ruby YAML.ext_load_file(yaml_path, inheritance_key='extends', options = {}) ``` -------------------------------- ### Global Configuration of Custom Extend Key Source: https://github.com/magynhard/yaml_extend/blob/master/README.md Set a custom inheritance key globally by assigning it to `YAML.ext_load_key`. This avoids needing to specify the key as a parameter for every call. ```ruby YAML.ext_load_key = 'inherit_from' config = YAML.ext_load_file 'custom1.yml' ``` -------------------------------- ### Using Custom Nested Extend Key Source: https://github.com/magynhard/yaml_extend/blob/master/README.md Specify a custom extend key that is nested within the YAML structure by providing an array of keys to `ext_load_file`. ```yaml #custom2.yml options: extend_file: 'super_file.yml' database: false foo: 'bar' ... ``` ```ruby config = YAML.ext_load_file 'custom2.yml', ['options','extend_file'] ``` -------------------------------- ### Inherit from Several YAML Files Source: https://github.com/magynhard/yaml_extend/blob/master/README.md Specify a list of files in the 'extends' key to inherit from multiple YAML files. Files are merged from top to bottom, with later files overwriting earlier ones. ```yaml extends: - 'super_file.yml' - 'parent_file.yml' ... ``` -------------------------------- ### Reset Global Custom Extend Key Source: https://github.com/magynhard/yaml_extend/blob/master/README.md Reset the globally configured inheritance key using `YAML.reset_load_key` or by setting `YAML.ext_load_key` to nil. ```ruby YAML.reset_load_key # more readable YAML.ext_load_key = nil # more explicit ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.