Git Product home page Git Product logo

easy_diff's People

Contributors

blargel avatar johnnyshields avatar kayakyakr avatar parasmk avatar peakxu avatar vuntz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

easy_diff's Issues

Diff breaks for hashes within arrays

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]

Arrays of hashes are not recursively diff'd

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.

Summary : If the value of any key is nested hash and the value is same in both 'original' and 'modified' hash then corresponding key appears in both 'removed' and 'added' hash.

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 :

  • Then after doing : "removed, added = original.easy_diff modified", the removed and added hash should not contain the key 'pos', as the corresponding key value is same in both hash.

Actual Result :

  • Then after doing : "removed, added = original.easy_diff modified", the removed and added hash contains the key 'pos' with value as {} (i.e. :pos => {}).

Tested in version : 0.0.2

Is it possible to ignore values when comparing

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.