0.0
No commit activity in last 3 years
No release in over 3 years
HashDiffSym is a diff lib to compute the smallest difference between two hashes.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
>= 0
 Project Readme

Summary

HashDiffSym is a fork of HashDiff (by liufengyun) with symbols support.

diff = HashDiffSym.diff({ 'a' => { x: 2, y: 3, z: 4 }, 'b' => { x: 3, z: [1, 2, 3] } },
                        { 'a' => { y: 3 },             'b' => { y: 3, z: [2, 3, 4] } })
diff.should == [['-', 'a.:x', 2], ['-', 'a.:z', 4], ['-', 'b.:x', 3], ["-", "b.:z[0]", 1], ["+", "b.:z[2]", 4], ['+', 'b.:y', 3]]

Also works for patch:

a = {a: 3}
b = {a: {a1: 1, a2: 2}}
diff = HashDiffSym.diff(a, b)
HashDiffSym.patch!(a, diff).should == b

Installing

Add this to your Gemfile

gem "hashdiff_sym"

or just run

gem install hashdiff_sym

License

HashDiffSym is distributed under the MIT-LICENSE.