hashdiff 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -3
- data/README.md +25 -3
- data/changelog.md +4 -0
- data/hashdiff.gemspec +1 -1
- data/lib/hashdiff/diff.rb +3 -0
- data/lib/hashdiff/version.rb +1 -1
- metadata +18 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6af49f121e2b09e5dcdf8a649f6d48c25f63ae03
|
4
|
+
data.tar.gz: c6738c2b03d36f622ac1e0a3c228a863b691ac29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dfda8cd1b17af2c64ea4626570e7d858b76a5ed918df4b6a5703c63e0ae43c371cbe5e3573b4382aa1491915f48335e62d3b4300f3c678660f329f39e8d9b62
|
7
|
+
data.tar.gz: 71ab91ba878e19c436dbad30cc08c85645aadf6aabeed889dc8e3661102d2ddf5a98b12c7a6a8b1007a5115f64e082829f88d99abe11ad87f2a69cf504f28885
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -91,9 +91,9 @@ HashDiff.unpatch!(b, diff).should == a
|
|
91
91
|
|
92
92
|
### Options
|
93
93
|
|
94
|
-
There are
|
95
|
-
`:strict`, `:numeric_tolerance`, `:strip`, `:case_insensitive`
|
96
|
-
and `:
|
94
|
+
There are eight options available: `:delimiter`, `:similarity`,
|
95
|
+
`:strict`, `:numeric_tolerance`, `:strip`, `:case_insensitive`, `:array_path`
|
96
|
+
and `:use_lcs`
|
97
97
|
|
98
98
|
#### `:delimiter`
|
99
99
|
|
@@ -184,6 +184,28 @@ diff = HashDiff.diff(a, b, :array_path => true)
|
|
184
184
|
diff.should == [["~", [:a], [1], {0=>1}]]
|
185
185
|
```
|
186
186
|
|
187
|
+
#### `:use_lcs`
|
188
|
+
|
189
|
+
The :use_lcs option is used to specify whether a
|
190
|
+
[Longest common subsequence](https://en.wikipedia.org/wiki/Longest_common_subsequence_problem)
|
191
|
+
(LCS) algorithm is used to determine differences in arrays. This defaults to
|
192
|
+
`true` but can be changed to `false` for significantly faster array comparisons
|
193
|
+
(O(n) complexity rather than O(n<sup>2</sup>) for LCS).
|
194
|
+
|
195
|
+
When :use_lcs is false the results of array comparisons have a tendency to
|
196
|
+
show changes at indexes rather than additions and subtractions when :use_lcs is
|
197
|
+
true.
|
198
|
+
|
199
|
+
Note, currently the :similarity option has no effect when :use_lcs is false.
|
200
|
+
|
201
|
+
```ruby
|
202
|
+
a = {x: [0, 1, 2]}
|
203
|
+
b = {x: [0, 2, 2, 3]}
|
204
|
+
|
205
|
+
diff = HashDiff.diff(a, b, :use_lcs => false)
|
206
|
+
diff.should == [["~", "x[1]", 1, 2], ["+", "x[3]", 3]]
|
207
|
+
```
|
208
|
+
|
187
209
|
#### Specifying a custom comparison method
|
188
210
|
|
189
211
|
It's possible to specify how the values of a key should be compared.
|
data/changelog.md
CHANGED
data/hashdiff.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.test_files = `git ls-files -- Appraisals {spec}/*`.split("\n")
|
13
13
|
|
14
14
|
s.require_paths = ['lib']
|
15
|
-
s.required_ruby_version = Gem::Requirement.new(">= 1.
|
15
|
+
s.required_ruby_version = Gem::Requirement.new(">= 1.9.3")
|
16
16
|
|
17
17
|
s.authors = ["Liu Fengyun"]
|
18
18
|
s.email = ["liufengyunchina@gmail.com"]
|
data/lib/hashdiff/diff.rb
CHANGED
@@ -12,6 +12,7 @@ module HashDiff
|
|
12
12
|
# * :numeric_tolerance (Numeric) [0] should be a positive numeric value. Value by which numeric differences must be greater than. By default, numeric values are compared exactly; with the :tolerance option, the difference between numeric values must be greater than the given value.
|
13
13
|
# * :strip (Boolean) [false] whether or not to call #strip on strings before comparing
|
14
14
|
# * :array_path (Boolean) [false] whether to return the path references for nested values in an array, can be used for patch compatibility with non string keys.
|
15
|
+
# * :use_lcs (Boolean) [true] whether or not to use an implementation of the Longest common subsequence algorithm for comparing arrays, produces better diffs but is slower.
|
15
16
|
#
|
16
17
|
# @yield [path, value1, value2] Optional block is used to compare each value, instead of default #==. If the block returns value other than true of false, then other specified comparison options will be used to do the comparison.
|
17
18
|
#
|
@@ -55,6 +56,8 @@ module HashDiff
|
|
55
56
|
# * :numeric_tolerance (Numeric) [0] should be a positive numeric value. Value by which numeric differences must be greater than. By default, numeric values are compared exactly; with the :tolerance option, the difference between numeric values must be greater than the given value.
|
56
57
|
# * :strip (Boolean) [false] whether or not to call #strip on strings before comparing
|
57
58
|
# * :array_path (Boolean) [false] whether to return the path references for nested values in an array, can be used for patch compatibility with non string keys.
|
59
|
+
# * :use_lcs (Boolean) [true] whether or not to use an implementation of the Longest common subsequence algorithm for comparing arrays, produces better diffs but is slower.
|
60
|
+
#
|
58
61
|
#
|
59
62
|
# @yield [path, value1, value2] Optional block is used to compare each value, instead of default #==. If the block returns value other than true of false, then other specified comparison options will be used to do the comparison.
|
60
63
|
#
|
data/lib/hashdiff/version.rb
CHANGED
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hashdiff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Liu Fengyun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08
|
11
|
+
date: 2017-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: yard
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bluecloth
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description:
|
56
|
-
hashes.
|
55
|
+
description: ' HashDiff is a diff lib to compute the smallest difference between two
|
56
|
+
hashes. '
|
57
57
|
email:
|
58
58
|
- liufengyunchina@gmail.com
|
59
59
|
executables: []
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
-
-
|
64
|
-
-
|
65
|
-
-
|
66
|
-
-
|
63
|
+
- .gitignore
|
64
|
+
- .rspec
|
65
|
+
- .travis.yml
|
66
|
+
- .yardopts
|
67
67
|
- Gemfile
|
68
68
|
- LICENSE
|
69
69
|
- README.md
|
@@ -95,19 +95,18 @@ require_paths:
|
|
95
95
|
- lib
|
96
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
97
|
requirements:
|
98
|
-
- -
|
98
|
+
- - '>='
|
99
99
|
- !ruby/object:Gem::Version
|
100
|
-
version: 1.
|
100
|
+
version: 1.9.3
|
101
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- -
|
103
|
+
- - '>='
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
107
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.0.14.1
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: HashDiff is a diff lib to compute the smallest difference between two hashes.
|
112
112
|
test_files: []
|
113
|
-
has_rdoc:
|