README.md in hashdiff-1.0.1 vs README.md in hashdiff-1.1.0
- old
+ new
@@ -92,13 +92,12 @@
Hashdiff.unpatch!(b, diff).should == a
```
### Options
-There are eight options available: `:delimiter`, `:similarity`,
-`:strict`, `:indifferent`, `:numeric_tolerance`, `:strip`, `:case_insensitive`,
-`:array_path` and `:use_lcs`
+The following options are available: `:delimiter`, `:similarity`, `:strict`, `:ignore_keys`,
+`: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:
@@ -115,9 +114,29 @@
In cases where you have similar hash objects in arrays, you can pass a custom value for `:similarity` instead of the default `0.8`. This is interpreted as a ratio of similarity (default is 80% similar, whereas `:similarity => 0.5` would look for at least a 50% similarity).
#### `: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).
+
+#### `:ignore_keys`
+
+The `:ignore_keys` option allows you to specify one or more keys to ignore, which defaults to `[]` (none). Ignored keys are ignored at all levels. For example:
+
+```ruby
+a = { a: 1, b: { d: 2, a: 3 }, c: 4 }
+b = { a: 2, b: { d: 2, a: 7 }, c: 5 }
+diff = Hashdiff.diff(a, b, ignore_keys: :a)
+diff.should == [['~', 'c', 4, 5]]
+```
+If you wish instead to ignore keys at a particlar level you should
+use a [custom comparison method](https://github.com/liufengyun/hashdiff#specifying-a-custom-comparison-method) instead. For example:
+
+```ruby
+a = { a: 1, b: { d: 2, a: 3 }, c: 4 }
+b = { a: 2, b: { d: 2, a: 7 }, c: 5 }
+diff = Hashdiff.diff(a, b) { |path, _e, _a| true if path == 'b.a' } # note '.' is the default delimiter
+diff.should == [['~', 'a', 1, 2], ['~', 'c', 4, 5]]
+```
#### `: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})