#yaml

yaml-merge-keys

Implementation of the YAML merge key extension. http://yaml.org/type/merge.html

5 releases (3 breaking)

0.4.0 Oct 15, 2019
0.3.0 Nov 14, 2018
0.2.1 Feb 12, 2018
0.2.0 May 12, 2017
0.1.0 Mar 30, 2017

#7 in #yaml

Download history 652/week @ 2019-12-10 16/week @ 2019-12-17 63/week @ 2019-12-24 47/week @ 2019-12-31 214/week @ 2020-01-07 192/week @ 2020-01-14 248/week @ 2020-01-21 135/week @ 2020-01-28 50/week @ 2020-02-04 60/week @ 2020-02-11 45/week @ 2020-02-18 117/week @ 2020-02-25 140/week @ 2020-03-03 66/week @ 2020-03-10 203/week @ 2020-03-17 7682/week @ 2020-03-24

833 downloads per month
Used in 2 crates

MIT/Apache

21KB
479 lines

Yaml merge keys

This crate implements support for the Merge Key Language-Independent Type for YAML draft specification for YAML documents from the yaml-rust and serde_yaml (with the serde_yaml feature) crates.

When a mapping in a YAML document contains a << key, its value should be either a mapping or a sequence of mappings. For each mapping, it is merged into the parent mapping where the parent mapping wins conflicts (so that it may override keys from the merge set).


lib.rs:

YAML Merge Keys

The YAML Merge Key extension is not supported by the core YAML crate, but can be implemented after parsing. This crate transforms a parsed YAML document and merges dictionaries together.

Example

---
- &CENTER { x: 1, y: 2 }
- &LEFT { x: 0, y: 2 }
- &BIG { r: 10 }
- &SMALL { r: 1 }

# All the following maps are equal:

- # Explicit keys
  x: 1
  y: 2
  r: 10
  label: center/big

- # Merge one map
  << : *CENTER
  r: 10
  label: center/big

- # Merge multiple maps
  << : [ *CENTER, *BIG ]
  label: center/big

- # Override
  << : [ *BIG, *LEFT, *SMALL ]
  x: 1
  label: center/big

Dependencies

~0.6–1MB
~25K SLoC