YAML Hash with merge/update capabilities
Wrapper around yaml_rust::yaml::Hash
, which is a type alias for
linked_hash_map::LinkedHashMap
``` use mergeyamlhash::{MergeYamlHash, Yaml};
let mut hash = MergeYamlHash::new();
// Merge YAML data from strings hash.merge("apple: 1\nbanana: 2"); hash.merge("cherry:\n sweet: 1\n tart: 2"); asserteq!( hash.tostring(), "apple: 1\nbanana: 2\ncherry:\n sweet: 1\n tart: 2" );
// Merge YAML data from file // * Note that insertion order is maintained hash.merge("tests/c.yaml"); // "banana: 3" asserteq!( hash.tostring(), "apple: 1\ncherry:\n sweet: 1\n tart: 2\nbanana: 3" ); ```
data
field public```text Copyright 2019 qtfkwk
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ```
```text $ cargo test
running 17 tests test tests::debug ... ok test tests::debugpretty ... ok test tests::display ... ok test tests::mergefile ... ok test tests::mergemultiplefilefilenoconflicts ... ok test tests::mergemultiplefilefilewithconflict ... ok test tests::mergemultiplefilestringnoconflicts ... ok test tests::mergemultiplefilestringwithconflict ... ok test tests::mergemultiplestringfilenoconflicts ... ok test tests::mergemultiplestringfilewithconflict ... ok test tests::mergemultiplestringstringnoconflicts ... ok test tests::mergestring ... ok test tests::mergemultiplestringstringwithconflict ... ok test tests::mergemultiplestringstringnoconflictsdeep ... ok test tests::tostring ... ok test tests::mergemultiplestringstringwithconflictdeep ... ok test tests::readdatafields ... ok
test result: ok. 17 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
running 1 test test integrationreaddata_fields ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
running 7 tests test src/lib.rs - MergeYamlHash::merge (line 339) ... ok test src/lib.rs - MergeYamlHash::merge (line 332) ... ok test src/lib.rs - (line 10) ... ok test src/lib.rs - MergeYamlHash::mergevec (line 383) ... ok test src/lib.rs - MergeYamlHash::mergevec (line 396) ... ok test src/lib.rs - MergeYamlHash::new (line 302) ... ok test src/lib.rs - MergeYamlHash::to_string (line 314) ... ok
test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
```