README.md in hashdiff-1.0.0 vs README.md in hashdiff-1.0.1

- old
+ new

@@ -30,11 +30,11 @@ ## Usage To use the gem, add the following to your Gemfile: -```ruby +```Ruby gem 'hashdiff' ``` ## Quick Start @@ -93,22 +93,22 @@ ``` ### Options There are eight options available: `:delimiter`, `:similarity`, -`:strict`, `:numeric_tolerance`, `:strip`, `:case_insensitive`, `:array_path` -and `:use_lcs` +`:strict`, `:indifferent`, `:numeric_tolerance`, `:strip`, `:case_insensitive`, +`:array_path` and `:use_lcs` #### `:delimiter` You can specify `:delimiter` to be something other than the default dot. For example: ```ruby a = {a:{x:2, y:3, z:4}, b:{x:3, z:45}} b = {a:{y:3}, b:{y:3, z:30}} -diff = Hashdiff.diff(a, b, :delimiter => '\t') +diff = Hashdiff.diff(a, b, delimiter: '\t') diff.should == [['-', 'a\tx', 2], ['-', 'a\tz', 4], ['-', 'b\tx', 3], ['~', 'b\tz', 45, 30], ['+', 'b\ty', 3]] ``` #### `:similarity` @@ -116,19 +116,23 @@ #### `:strict` The `:strict` option, which defaults to `true`, specifies whether numeric types are compared on type as well as value. By default, an Integer will never be equal to a Float (e.g. 4 != 4.0). Setting `:strict` to false makes the comparison looser (e.g. 4 == 4.0). +#### `:indifferent` + +The `:indifferent` option, which defaults to `false`, specifies whether to treat hash keys indifferently. Setting `:indifferent` to true has the effect of ignoring differences between symbol keys (ie. {a: 1} ~= {'a' => 1}) + #### `:numeric_tolerance` The :numeric_tolerance option allows for a small numeric tolerance. ```ruby a = {x:5, y:3.75, z:7} b = {x:6, y:3.76, z:7} -diff = Hashdiff.diff(a, b, :numeric_tolerance => 0.1) +diff = Hashdiff.diff(a, b, numeric_tolerance: 0.1) diff.should == [["~", "x", 5, 6]] ``` #### `:strip` @@ -136,11 +140,11 @@ ```ruby a = {x:5, s:'foo '} b = {x:6, s:'foo'} -diff = Hashdiff.diff(a, b, :comparison => { :numeric_tolerance => 0.1, :strip => true }) +diff = Hashdiff.diff(a, b, numeric_tolerance: 0.1, strip: true) diff.should == [["~", "x", 5, 6]] ``` #### `:case_insensitive` @@ -148,11 +152,11 @@ ```ruby a = {x:5, s:'FooBar'} b = {x:6, s:'foobar'} -diff = Hashdiff.diff(a, b, :comparison => { :numeric_tolerance => 0.1, :case_insensitive => true }) +diff = Hashdiff.diff(a, b, numeric_tolerance: 0.1, case_insensitive: true) diff.should == [["~", "x", 5, 6]] ``` #### `:array_path` @@ -162,30 +166,30 @@ ```ruby a = {x:5} b = {'x'=>6} -diff = Hashdiff.diff(a, b, :array_path => true) +diff = Hashdiff.diff(a, b, array_path: true) diff.should == [['-', [:x], 5], ['+', ['x'], 6]] ``` For cases where there are arrays in paths their index will be added to the path. ```ruby a = {x:[0,1]} b = {x:[0,2]} -diff = Hashdiff.diff(a, b, :array_path => true) +diff = Hashdiff.diff(a, b, array_path: true) diff.should == [["-", [:x, 1], 1], ["+", [:x, 1], 2]] ``` This shouldn't cause problems if you are comparing an array with a hash: ```ruby a = {x:{0=>1}} b = {x:[1]} -diff = Hashdiff.diff(a, b, :array_path => true) +diff = Hashdiff.diff(a, b, array_path: true) diff.should == [["~", [:x], {0=>1}, [1]]] ``` #### `:use_lcs` @@ -203,11 +207,11 @@ ```ruby a = {x: [0, 1, 2]} b = {x: [0, 2, 2, 3]} -diff = Hashdiff.diff(a, b, :use_lcs => false) +diff = Hashdiff.diff(a, b, use_lcs: false) diff.should == [["~", "x[1]", 1, 2], ["+", "x[3]", 3]] ``` #### Specifying a custom comparison method @@ -253,14 +257,14 @@ ```ruby a = {a:'car', b:['boat', 'plane'] } b = {a:'car', b:['plane', 'boat'] } -Hashdiff.diff(a, b) => [["+", "b[0]", "plane"], ["-", "b[2]", "plane"]] +Hashdiff.diff(a, b).should == [["+", "b[0]", "plane"], ["-", "b[2]", "plane"]] b[:b].sort! -Hashdiff.diff(a, b) => [] +Hashdiff.diff(a, b).should == [] ``` ## Maintainers - Krzysztof Rybka ([@krzysiek1507](https://github.com/krzysiek1507))