README.md in deep_merge-1.2.1 vs README.md in deep_merge-1.2.2

- old
+ new

@@ -1,8 +1,11 @@ -DeepMerge Overview -================== +DeepMerge +========= +[![Gem Version](https://badge.fury.io/rb/deep_merge.svg)](http://badge.fury.io/rb/deep_merge) +[![CI](https://github.com/danielsdeleo/deep_merge/actions/workflows/ci.yaml/badge.svg)](https://github.com/danielsdeleo/deep_merge/actions/workflows/ci.yaml) + Deep Merge is a simple set of utility functions for Hash. It permits you to merge elements inside a hash together recursively. The manner by which it does this is somewhat arbitrary (since there is no defining standard for this) but it should end up being pretty intuitive and do what you expect. You can learn a lot more about this by reading the test file. It's pretty well documented and has many examples of various merges from very simple to pretty complex. The primary need that caused me to write this library is the merging of elements coming from HTTP parameters and related stored parameters in session. This lets a user build up a set of parameters over time, modifying individual items. @@ -37,10 +40,12 @@ Set to string value to run "Array::join" then "String::split" against all arrays :merge_hash_arrays DEFAULT: false Set to true to merge hashes within arrays :extend_existing_arrays DEFAULT: false Set to true to extend existing arrays, instead of overwriting them + :keep_array_duplicates DEFAULT: false + Set to true to keep duplicate entries in arrays, instead of coalescing them :merge_nil_values DEFAULT: false Set to true to merge nil hash values, overwriting a possibly non-nil value :merge_debug DEFAULT: false Set to true to get console output of merge process for debugging @@ -62,20 +67,18 @@ dest = {:x => [1,2,3]} dest.ko_deep_merge!(source) Results: {:x => ""} **:overwrite_arrays** - The purpose of this is to provide a way to replace Arrays instead of having them merge together. source = {:x => ['1', '2']} dest = {:x => ['3', '4']} dest.deep_merge!(source, {:overwrite_arrays => true}) Results: {:x => ['1', '2']} **:unpack_arrays** - The purpose of this is to permit compound elements to be passed in as strings and to be converted into discrete array elements irsource = {:x => ['1,2,3', '4']} dest = {:x => ['5','6','7,8']} dest.deep_merge!(source, {:unpack_arrays => ','}) @@ -99,10 +102,28 @@ source = { "property" => "4" } dest = { "property" => ["1", "2", "3"] } dest.deep_merge!(source, {:extend_existing_arrays => true}) Results: {"property" => ["1", "2", "3", "4"]} +**:keep_array_duplicates** + +Keeps duplicate entries in arrays, instead of coalescing them. + +Without this setting: + + source = { "property" => ["2", "3"] } + dest = { "property" => ["1", "2"] } + dest.deep_merge!(source) + Results: {"property" => ["1", "2", "3"]} + +With this setting: + + source = { "property" => ["1", "2"] } + dest = { "property" => ["2", "3"] } + dest.deep_merge!(source, {:keep_array_duplicates => true}) + Results: {"property" => ["1", "2", "2", "3"]} + **:merge_nil_values** The purpose of this option is to allow nil hash values to be merged. The prior behavior was to discard nil hash values and remains the default if not specified. source = {"item" => nil} @@ -136,11 +157,11 @@ x = {:x => [3,4,5]} y = {:x => [1,2,3]} y.deep_merge!(x) # results: y = {:x => [1,2,3,4,5]} -Availablility -============= +Availability +============ `deep_merge` was written by Steve Midgley, and is now maintained by Daniel DeLeo. The official home of `deep_merge` on the internet is now https://github.com/danielsdeleo/deep_merge Copyright (c) 2008-2016 Steve Midgley, released under the MIT license