blargel / easy_diff Goto Github PK
View Code? Open in Web Editor NEWRecursive diff, merge, and unmerge for hashes and arrays.
License: MIT License
Recursive diff, merge, and unmerge for hashes and arrays.
License: MIT License
Hi, I've came across a problem with easy_diff that breaks, but I'm not sure why, because for some nested hashes it works fine, here is the gist that demonstrates the weird behaviour:
https://gist.github.com/anonymous/f2995ef213e4c8f8f54c
With given hashes, the output for removed should be an empty hash, but instead it gives whole hash.
I think it's a bug, unless it's not then i would like to know what exactly is causing this.
Easy_diff 0.0.6
ruby -v:
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
So, I love this tool. But, I'm trying to diff some rather complicated JSON documents, and everything goes swimmingly until an array contains hashes. My preferred behavior would be to recursively diff each hash in the array. I'm looking at the code, and may attempt this myself, but I'm wondering if you've already tried and hit issues.
Steps to Reproduce :
If original = {
:tags => ['a', 'b', 'c'],
:pos => {:x => '1', :y => '2'},
:some_str => "bla",
:some_int => 1,
:some_bool => false,
:extra_removed => "bye"
}
modified = {
:tags => ['b', 'c', 'd'],
:pos => {:x => '1', :y => '2'},
:some_str => "bla",
:some_int => 2,
:some_bool => true,
:extra_added => "hi"
}
Expected Result :
Actual Result :
Tested in version : 0.0.2
Say I have the following:
a = { :a => 1 }
b = { :a => 2, :b => 5 }
remove, added = a.easy_diff(b) # => [{:a=>1}, {:b=>5, :a=>2}]
I would like to get a diff of only when the keys are added or removed, not if the value of a key changes like so:
a = { :a => 1 }
b = { :a => 2, :b => 5 }
remove, added = a.easy_diff(b, :ignore_values => true) # => [{}, {:b=>5}]
Is that possible?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.