hashdiff 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +0 -5
- data/Gemfile +4 -0
- data/Gemfile.lock +3 -1
- data/LICENSE +19 -0
- data/README.md +34 -24
- data/changelog.md +14 -0
- data/lib/hashdiff/diff.rb +15 -10
- data/lib/hashdiff/lcs.rb +1 -1
- data/lib/hashdiff/patch.rb +14 -34
- data/lib/hashdiff/util.rb +14 -42
- data/lib/hashdiff/version.rb +1 -1
- data/spec/hashdiff/diff_spec.rb +8 -8
- data/spec/hashdiff/util_spec.rb +14 -0
- metadata +10 -8
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hashdiff (0.0.
|
4
|
+
hashdiff (0.0.3)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
8
8
|
specs:
|
9
9
|
bluecloth (2.2.0)
|
10
10
|
diff-lcs (1.1.3)
|
11
|
+
rake (0.9.2.2)
|
11
12
|
rspec (2.10.0)
|
12
13
|
rspec-core (~> 2.10.0)
|
13
14
|
rspec-expectations (~> 2.10.0)
|
@@ -24,5 +25,6 @@ PLATFORMS
|
|
24
25
|
DEPENDENCIES
|
25
26
|
bluecloth
|
26
27
|
hashdiff!
|
28
|
+
rake
|
27
29
|
rspec (~> 2.0)
|
28
30
|
yard
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2012 Liu Fengyun
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,24 +1,38 @@
|
|
1
|
-
HashDiff
|
2
|
-
|
1
|
+
# HashDiff
|
2
|
+
|
3
|
+
[](http://travis-ci.org/liufengyun/hashdiff)
|
3
4
|
|
4
5
|
HashDiff is a ruby library to compute the smallest difference between two hashes.
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
**Demo**: [HashDiff](http://hashdiff.herokuapp.com/)
|
8
|
+
|
9
|
+
**Docs**: [Documentation](http://rubydoc.info/gems/hashdiff)
|
10
|
+
|
11
|
+
## Why HashDiff?
|
12
|
+
|
13
|
+
Given two Hashes A and B, sometimes you face the question: what's the smallest changes that can be made to change A to B?
|
14
|
+
|
15
|
+
An algorithm responds to this question has to do following:
|
16
|
+
|
17
|
+
* Generate a list of additions, deletions and changes, so that `A + ChangeSet = B` and `B - ChangeSet = A`.
|
18
|
+
* Compute recursively -- Arrays and Hashes may be nested arbitrarily in A or B.
|
19
|
+
* Compute the smallest change -- it should recoganize similar child Hashes or child Arrays between A and B.
|
9
20
|
|
10
|
-
|
11
|
-
- 1.9.2
|
12
|
-
- 1.9.3
|
13
|
-
- rbx
|
14
|
-
- rbx-2.0
|
15
|
-
- ree
|
16
|
-
- jruby
|
17
|
-
- ruby-head
|
21
|
+
HashDiff answers the question above in an opinionated approach:
|
18
22
|
|
19
|
-
|
20
|
-
|
21
|
-
|
23
|
+
* Hash can be represented as a list of (dot-syntax-path, value) pairs. For example, `{a:[{c:2}]}` can be represented as `["a[0].c", 2]`.
|
24
|
+
* The change set can be represented using the do-syntax representation. For example, `[['-', 'b.x', 3], ['~', 'b.z', 45, 30], ['+', 'b.y', 3]]`.
|
25
|
+
* It compares Arrays using LCS(longest common subsequence) algorithm.
|
26
|
+
* It recoganize similar Hashes in Array using a similarity value(0 < similarity <= 1).
|
27
|
+
|
28
|
+
|
29
|
+
## Compatibility
|
30
|
+
|
31
|
+
HashDiff is tested against `1.9.2`, `1.9.3` and `ruby-head`. It should work on other versions as well.
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
|
35
|
+
If you're using bundler, add following to the Gemfile:
|
22
36
|
|
23
37
|
gem 'hashdiff'
|
24
38
|
|
@@ -26,10 +40,7 @@ Or, you can run `gem install hashdiff`, then add following line to your ruby fil
|
|
26
40
|
|
27
41
|
require 'hashdiff'
|
28
42
|
|
29
|
-
Quick Start
|
30
|
-
-----------
|
31
|
-
|
32
|
-
You can find full docs here: [Documentation](http://rubydoc.info/gems/hashdiff)
|
43
|
+
## Quick Start
|
33
44
|
|
34
45
|
### Diff
|
35
46
|
|
@@ -65,7 +76,7 @@ patch example:
|
|
65
76
|
b = {a: {a1: 1, a2: 2}}
|
66
77
|
|
67
78
|
diff = HashDiff.diff(a, b)
|
68
|
-
HashDiff.patch(a, diff).should == b
|
79
|
+
HashDiff.patch!(a, diff).should == b
|
69
80
|
|
70
81
|
unpatch example:
|
71
82
|
|
@@ -73,11 +84,10 @@ unpatch example:
|
|
73
84
|
b = [1, {a: 1, b: 2, c: 3, e: 5}]
|
74
85
|
|
75
86
|
diff = HashDiff.diff(a, b) # diff two array is OK
|
76
|
-
HashDiff.unpatch(b, diff).should == a
|
87
|
+
HashDiff.unpatch!(b, diff).should == a
|
77
88
|
|
78
89
|
|
79
|
-
License
|
80
|
-
-------
|
90
|
+
## License
|
81
91
|
|
82
92
|
HashDiff is distributed under the MIT-LICENSE.
|
83
93
|
|
data/changelog.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## v0.0.4 2012-6-24
|
4
|
+
|
5
|
+
Main changes in this version is to output the whole object in addition & deletion, instead of recursely add/deletes the object.
|
6
|
+
|
7
|
+
For example, `diff({a:2, c:[4, 5]}, {a:2}) will generate following output:
|
8
|
+
|
9
|
+
[['-', 'c', [4, 5]]]
|
10
|
+
|
11
|
+
instead of following:
|
12
|
+
|
13
|
+
[['-', 'c[0]', 4], ['-', 'c[1]', 5], ['-', 'c', []]]
|
14
|
+
|
data/lib/hashdiff/diff.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module HashDiff
|
2
2
|
|
3
|
-
# Best diff two objects, which tries to generate the smallest change set.
|
3
|
+
# Best diff two objects, which tries to generate the smallest change set using different similarity values.
|
4
4
|
#
|
5
5
|
# HashDiff.best_diff is only meaningful in case of comparing two objects which includes similar objects in array.
|
6
6
|
#
|
@@ -19,11 +19,16 @@ module HashDiff
|
|
19
19
|
# @since 0.0.1
|
20
20
|
def self.best_diff(obj1, obj2)
|
21
21
|
diffs_1 = diff(obj1, obj2, "", 0.3)
|
22
|
+
count_1 = count_diff diffs_1
|
23
|
+
|
22
24
|
diffs_2 = diff(obj1, obj2, "", 0.5)
|
25
|
+
count_2 = count_diff diffs_2
|
26
|
+
|
23
27
|
diffs_3 = diff(obj1, obj2, "", 0.8)
|
28
|
+
count_3 = count_diff diffs_3
|
24
29
|
|
25
|
-
diffs =
|
26
|
-
diffs =
|
30
|
+
count, diffs = count_1 < count_2 ? [count_1, diffs_1] : [count_2, diffs_2]
|
31
|
+
diffs = count < count_3 ? diffs : diffs_3
|
27
32
|
end
|
28
33
|
|
29
34
|
# Compute the diff of two hashes
|
@@ -51,15 +56,15 @@ module HashDiff
|
|
51
56
|
end
|
52
57
|
|
53
58
|
if obj1.nil?
|
54
|
-
return [['
|
59
|
+
return [['~', prefix, nil, obj2]]
|
55
60
|
end
|
56
61
|
|
57
62
|
if obj2.nil?
|
58
|
-
return
|
63
|
+
return [['~', prefix, obj1, nil]]
|
59
64
|
end
|
60
65
|
|
61
66
|
if !(obj1.is_a?(Array) and obj2.is_a?(Array)) and !(obj1.is_a?(Hash) and obj2.is_a?(Hash)) and !(obj1.is_a?(obj2.class) or obj2.is_a?(obj1.class))
|
62
|
-
return
|
67
|
+
return [['~', prefix, obj1, obj2]]
|
63
68
|
end
|
64
69
|
|
65
70
|
result = []
|
@@ -73,9 +78,9 @@ module HashDiff
|
|
73
78
|
|
74
79
|
changeset.each do |change|
|
75
80
|
if change[0] == '-'
|
76
|
-
result
|
81
|
+
result << ['-', "#{prefix}[#{change[1]}]", change[2]]
|
77
82
|
elsif change[0] == '+'
|
78
|
-
result
|
83
|
+
result << ['+', "#{prefix}[#{change[1]}]", change[2]]
|
79
84
|
end
|
80
85
|
end
|
81
86
|
elsif obj1.is_a?(Hash)
|
@@ -93,7 +98,7 @@ module HashDiff
|
|
93
98
|
end
|
94
99
|
|
95
100
|
# add deleted properties
|
96
|
-
deleted_keys.each {|k| result
|
101
|
+
deleted_keys.each {|k| result << ['-', "#{prefix}#{k}", obj1[k]] }
|
97
102
|
|
98
103
|
# recursive comparison for common keys
|
99
104
|
common_keys.each {|k| result.concat(diff(obj1[k], obj2[k], "#{prefix}#{k}", similarity)) }
|
@@ -101,7 +106,7 @@ module HashDiff
|
|
101
106
|
# added properties
|
102
107
|
obj2.each do |k, v|
|
103
108
|
unless obj1.key?(k)
|
104
|
-
result
|
109
|
+
result << ['+', "#{prefix}#{k}", obj2[k]]
|
105
110
|
end
|
106
111
|
end
|
107
112
|
else
|
data/lib/hashdiff/lcs.rb
CHANGED
@@ -15,7 +15,7 @@ module HashDiff
|
|
15
15
|
(0..b_finish).each do |bi|
|
16
16
|
lcs[bi] = []
|
17
17
|
(0..a_finish).each do |ai|
|
18
|
-
if
|
18
|
+
if similar?(a[ai], b[bi], similarity)
|
19
19
|
topleft = (ai > 0 and bi > 0)? lcs[bi-1][ai-1][1] : 0
|
20
20
|
lcs[bi][ai] = [:topleft, topleft + 1]
|
21
21
|
elsif
|
data/lib/hashdiff/patch.rb
CHANGED
@@ -16,32 +16,22 @@ module HashDiff
|
|
16
16
|
parts = decode_property_path(change[1])
|
17
17
|
last_part = parts.last
|
18
18
|
|
19
|
-
|
19
|
+
parent_node = node(obj, parts[0, parts.size-1])
|
20
20
|
|
21
21
|
if change[0] == '+'
|
22
|
-
if dest_node == nil
|
23
|
-
parent_key = parts[parts.size-2]
|
24
|
-
parent_node = node(obj, parts[0, parts.size-2])
|
25
|
-
if last_part.is_a?(Fixnum)
|
26
|
-
dest_node = parent_node[parent_key] = []
|
27
|
-
else
|
28
|
-
dest_node = parent_node[parent_key] = {}
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
22
|
if last_part.is_a?(Fixnum)
|
33
|
-
|
23
|
+
parent_node.insert(last_part, change[2])
|
34
24
|
else
|
35
|
-
|
25
|
+
parent_node[last_part] = change[2]
|
36
26
|
end
|
37
27
|
elsif change[0] == '-'
|
38
28
|
if last_part.is_a?(Fixnum)
|
39
|
-
|
29
|
+
parent_node.delete_at(last_part)
|
40
30
|
else
|
41
|
-
|
31
|
+
parent_node.delete(last_part)
|
42
32
|
end
|
43
33
|
elsif change[0] == '~'
|
44
|
-
|
34
|
+
parent_node[last_part] = change[3]
|
45
35
|
end
|
46
36
|
end
|
47
37
|
|
@@ -56,41 +46,31 @@ module HashDiff
|
|
56
46
|
# @return the object after unpatch
|
57
47
|
#
|
58
48
|
# @since 0.0.1
|
59
|
-
def self.unpatch!(
|
49
|
+
def self.unpatch!(obj, changes)
|
60
50
|
changes.reverse_each do |change|
|
61
51
|
parts = decode_property_path(change[1])
|
62
52
|
last_part = parts.last
|
63
53
|
|
64
|
-
|
54
|
+
parent_node = node(obj, parts[0, parts.size-1])
|
65
55
|
|
66
56
|
if change[0] == '+'
|
67
57
|
if last_part.is_a?(Fixnum)
|
68
|
-
|
58
|
+
parent_node.delete_at(last_part)
|
69
59
|
else
|
70
|
-
|
60
|
+
parent_node.delete(last_part)
|
71
61
|
end
|
72
62
|
elsif change[0] == '-'
|
73
|
-
if dest_node == nil
|
74
|
-
parent_key = parts[parts.size-2]
|
75
|
-
parent_node = node(hash, parts[0, parts.size-2])
|
76
|
-
if last_part.is_a?(Fixnum)
|
77
|
-
dest_node = parent_node[parent_key] = []
|
78
|
-
else
|
79
|
-
dest_node = parent_node[parent_key] = {}
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
63
|
if last_part.is_a?(Fixnum)
|
84
|
-
|
64
|
+
parent_node.insert(last_part, change[2])
|
85
65
|
else
|
86
|
-
|
66
|
+
parent_node[last_part] = change[2]
|
87
67
|
end
|
88
68
|
elsif change[0] == '~'
|
89
|
-
|
69
|
+
parent_node[last_part] = change[2]
|
90
70
|
end
|
91
71
|
end
|
92
72
|
|
93
|
-
|
73
|
+
obj
|
94
74
|
end
|
95
75
|
|
96
76
|
end
|
data/lib/hashdiff/util.rb
CHANGED
@@ -1,54 +1,28 @@
|
|
1
1
|
module HashDiff
|
2
2
|
|
3
|
-
# @private
|
4
|
-
#
|
5
|
-
# return an array of added properties
|
6
|
-
# e.g. [[ '+', 'a.b', 45 ], [ '-', 'a.c', 5 ]]
|
7
|
-
def self.changed(obj, sign, prefix = "")
|
8
|
-
return [[sign, prefix, obj]] unless obj
|
9
|
-
|
10
|
-
results = []
|
11
|
-
if obj.is_a?(Array)
|
12
|
-
if sign == '+'
|
13
|
-
# add from the begining
|
14
|
-
results << [sign, prefix, []]
|
15
|
-
obj.each_index do |index|
|
16
|
-
results.concat(changed(obj[index], sign, "#{prefix}[#{index}]"))
|
17
|
-
end
|
18
|
-
elsif sign == '-'
|
19
|
-
# delete from the end
|
20
|
-
obj.each_index do |index|
|
21
|
-
i = obj.size - index - 1
|
22
|
-
results.concat(changed(obj[i], sign, "#{prefix}[#{i}]"))
|
23
|
-
end
|
24
|
-
results << [sign, prefix, []]
|
25
|
-
end
|
26
|
-
elsif obj.is_a?(Hash)
|
27
|
-
results << [sign, prefix, {}] if sign == '+'
|
28
|
-
prefix_t = prefix.empty? ? "" : "#{prefix}."
|
29
|
-
obj.each do |k, v|
|
30
|
-
results.concat(changed(v, sign, "#{prefix_t}#{k}"))
|
31
|
-
end
|
32
|
-
results << [sign, prefix, {}] if sign == '-'
|
33
|
-
else
|
34
|
-
return [[sign, prefix, obj]]
|
35
|
-
end
|
36
|
-
|
37
|
-
results
|
38
|
-
end
|
39
|
-
|
40
3
|
# @private
|
41
4
|
#
|
42
5
|
# judge whether two objects are similar
|
43
|
-
def self.
|
6
|
+
def self.similar?(a, b, similarity = 0.8)
|
44
7
|
count_a = count_nodes(a)
|
45
8
|
count_b = count_nodes(b)
|
46
|
-
|
9
|
+
diffs = count_diff diff(a, b, "", similarity)
|
47
10
|
|
48
11
|
if count_a + count_b == 0
|
49
12
|
return true
|
50
13
|
else
|
51
|
-
(1 -
|
14
|
+
(1 - diffs.to_f/(count_a + count_b).to_f) >= similarity
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# @private
|
19
|
+
#
|
20
|
+
# count node differences
|
21
|
+
def self.count_diff(diffs)
|
22
|
+
diffs.inject(0) do |sum, item|
|
23
|
+
old_change_count = count_nodes(item[2])
|
24
|
+
new_change_count = count_nodes(item[3])
|
25
|
+
sum += (old_change_count > new_change_count ? old_change_count : new_change_count)
|
52
26
|
end
|
53
27
|
end
|
54
28
|
|
@@ -60,10 +34,8 @@ module HashDiff
|
|
60
34
|
|
61
35
|
count = 0
|
62
36
|
if obj.is_a?(Array)
|
63
|
-
count = obj.size
|
64
37
|
obj.each {|e| count += count_nodes(e) }
|
65
38
|
elsif obj.is_a?(Hash)
|
66
|
-
count = obj.size
|
67
39
|
obj.each {|k, v| count += count_nodes(v) }
|
68
40
|
else
|
69
41
|
return 1
|
data/lib/hashdiff/version.rb
CHANGED
data/spec/hashdiff/diff_spec.rb
CHANGED
@@ -53,10 +53,10 @@ describe HashDiff do
|
|
53
53
|
b = {"a" => {"a1" => 1, "a2" => 2}}
|
54
54
|
|
55
55
|
diff = HashDiff.diff(a, b)
|
56
|
-
diff.should == [['
|
56
|
+
diff.should == [['~', 'a', 3, {"a1" => 1, "a2" => 2}]]
|
57
57
|
|
58
58
|
diff = HashDiff.diff(b, a)
|
59
|
-
diff.should == [['
|
59
|
+
diff.should == [['~', 'a', {"a1" => 1, "a2" => 2}, 3]]
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should be able to diff value changes: array <=> []" do
|
@@ -72,7 +72,7 @@ describe HashDiff do
|
|
72
72
|
b = {"a" => 1, "b" => nil}
|
73
73
|
|
74
74
|
diff = HashDiff.diff(a, b)
|
75
|
-
diff.should == [[
|
75
|
+
diff.should == [["~", "b", [1, 2], nil]]
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should be able to diff value chagnes: remove array completely" do
|
@@ -80,7 +80,7 @@ describe HashDiff do
|
|
80
80
|
b = {"a" => 1}
|
81
81
|
|
82
82
|
diff = HashDiff.diff(a, b)
|
83
|
-
diff.should == [[
|
83
|
+
diff.should == [["-", "b", [1, 2]]]
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should be able to diff value changes: remove whole hash" do
|
@@ -88,7 +88,7 @@ describe HashDiff do
|
|
88
88
|
b = {"a" => 1}
|
89
89
|
|
90
90
|
diff = HashDiff.diff(a, b)
|
91
|
-
diff.should == [[
|
91
|
+
diff.should == [["-", "b", {"b1"=>1, "b2"=>2}]]
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should be able to diff value changes: hash <=> {}" do
|
@@ -104,7 +104,7 @@ describe HashDiff do
|
|
104
104
|
b = {"a" => 1, "b" => nil}
|
105
105
|
|
106
106
|
diff = HashDiff.diff(a, b)
|
107
|
-
diff.should == [[
|
107
|
+
diff.should == [["~", "b", {"b1"=>1, "b2"=>2}, nil]]
|
108
108
|
end
|
109
109
|
|
110
110
|
it "should be able to diff similar objects in array" do
|
@@ -120,7 +120,7 @@ describe HashDiff do
|
|
120
120
|
b = [{'a' => 1, 'b' => 2, 'c' => 3, 'e' => 5}, 3]
|
121
121
|
|
122
122
|
diff = HashDiff.diff(a, b)
|
123
|
-
diff.should == [[
|
123
|
+
diff.should == [["-", "[0].d", 4], ["-", "[1]", {"x"=>5, "y"=>6, "z"=>3}]]
|
124
124
|
end
|
125
125
|
|
126
126
|
it "should be able to best diff" do
|
@@ -128,7 +128,7 @@ describe HashDiff do
|
|
128
128
|
b = {'x' => [{'a' => 1, 'b' => 2, 'e' => 5}] }
|
129
129
|
|
130
130
|
diff = HashDiff.best_diff(a, b)
|
131
|
-
diff.should == [[
|
131
|
+
diff.should == [["-", "x[0].c", 3], ["+", "x[0].b", 2], ["-", "x[1]", {"y"=>3}]]
|
132
132
|
end
|
133
133
|
|
134
134
|
end
|
data/spec/hashdiff/util_spec.rb
CHANGED
@@ -5,5 +5,19 @@ describe HashDiff do
|
|
5
5
|
decoded = HashDiff.send(:decode_property_path, "a.b[0].c.city[5]")
|
6
6
|
decoded.should == ['a', 'b', 0, 'c', 'city', 5]
|
7
7
|
end
|
8
|
+
|
9
|
+
it "should be able to tell similiar hash" do
|
10
|
+
a = {'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5}
|
11
|
+
b = {'a' => 1, 'b' => 2, 'c' => 3, 'e' => 5}
|
12
|
+
HashDiff.similar?(a, b).should be_true
|
13
|
+
HashDiff.similar?(a, b, 1).should be_false
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should be able to tell numbers and strings" do
|
17
|
+
HashDiff.similar?(1, 2).should_not be_true
|
18
|
+
HashDiff.similar?("a", "b").should_not be_true
|
19
|
+
HashDiff.similar?("a", [1, 2, 3]).should_not be_true
|
20
|
+
HashDiff.similar?(1, {'a' => 1, 'b' => 2, 'c' => 3, 'e' => 5}).should_not be_true
|
21
|
+
end
|
8
22
|
end
|
9
23
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hashdiff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-24 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &29117920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *29117920
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: yard
|
27
|
-
requirement: &
|
27
|
+
requirement: &29117540 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *29117540
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bluecloth
|
38
|
-
requirement: &
|
38
|
+
requirement: &29116960 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *29116960
|
47
47
|
description: ! ' HashDiff is a diff lib to compute the smallest difference between
|
48
48
|
two hashes. '
|
49
49
|
email:
|
@@ -58,8 +58,10 @@ files:
|
|
58
58
|
- .yardopts
|
59
59
|
- Gemfile
|
60
60
|
- Gemfile.lock
|
61
|
+
- LICENSE
|
61
62
|
- README.md
|
62
63
|
- Rakefile
|
64
|
+
- changelog.md
|
63
65
|
- hashdiff.gemspec
|
64
66
|
- lib/hashdiff.rb
|
65
67
|
- lib/hashdiff/diff.rb
|