easy_diff 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/VERSION +1 -1
- data/lib/easy_diff/core.rb +3 -1
- data/spec/easy_diff_spec.rb +42 -22
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWUyMjFiNjI3ODUzYjhjNjI0N2YyODczNDU3MTNlMmExZGI3NWI4Ng==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDk4MzAzNzVmZTJhMzc5M2VlMDVmMmE1Mjg1MjAxYjkwN2E3ZGQwYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWFjNTYxNDJiNzQ1MmIwZDdmZDAxMzE4NTc5M2FhNGUxY2Q5ZmZiMzRjMmMx
|
10
|
+
MmRmZDEzYWE1YWZjZWE1OGVlYzZiODc2ZDA4ZmQ5M2UxNjgyZmVkMmU3OThi
|
11
|
+
ODhmM2VkODdkYTQyNGY4MTM1YTExNzRiNzQwNDAwZjgxNjNiNWU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NWZiYjcyZGViOGZiZjYzZTZiYWVkMDA4MTU3YjczYmJjZDYyYmM1Mjg5YTE4
|
14
|
+
NzUxOWVjOGVlZjUzZTRhMTBiYzlhMGJmMjdlZDRhMDgyYTIwMDEyNWQ0NWRl
|
15
|
+
NmQ1ZTE4YWQwZWJlY2Q0MjcwMTExY2U0ZWNlOWE5ZmQ0YWNkYjg=
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
data/lib/easy_diff/core.rb
CHANGED
@@ -41,7 +41,9 @@ module EasyDiff
|
|
41
41
|
keys_in_common.each{ |key| original.delete(key) if easy_unmerge!(original[key], removed[key]).nil? }
|
42
42
|
elsif original.is_a?(Array) && removed.is_a?(Array)
|
43
43
|
original.reject!{ |e| removed.include?(e) }
|
44
|
-
original.
|
44
|
+
original.sort_by! { |item|
|
45
|
+
item.is_a?(Hash) ? item.sort : item
|
46
|
+
}
|
45
47
|
elsif original == removed
|
46
48
|
original = nil
|
47
49
|
end
|
data/spec/easy_diff_spec.rb
CHANGED
@@ -132,29 +132,49 @@ describe EasyDiff do
|
|
132
132
|
added.should == {:possibly_empty_string => "not empty"}
|
133
133
|
end
|
134
134
|
|
135
|
-
|
136
|
-
original
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
135
|
+
describe 'handling Arrays containing Hashes' do
|
136
|
+
let(:original) do
|
137
|
+
{
|
138
|
+
"key" => [
|
139
|
+
{"c" => "1"},
|
140
|
+
{"a" => "2"},
|
141
|
+
{"a" => "1"},
|
142
|
+
]
|
143
|
+
}
|
144
|
+
end
|
143
145
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
146
|
+
it "should merge properly" do
|
147
|
+
to_merge = {
|
148
|
+
"key" => [
|
149
|
+
{"b" => "2"},
|
150
|
+
]
|
151
|
+
}
|
149
152
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
153
|
+
merged = original.easy_merge to_merge
|
154
|
+
merged.should == {
|
155
|
+
"key" => [
|
156
|
+
{"a" => "1"},
|
157
|
+
{"a" => "2"},
|
158
|
+
{"b" => "2"},
|
159
|
+
{"c" => "1"},
|
160
|
+
]
|
161
|
+
}
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should unmerge properly" do
|
165
|
+
to_unmerge = {
|
166
|
+
"key" => [
|
167
|
+
{"a" => "2"},
|
168
|
+
]
|
169
|
+
}
|
170
|
+
|
171
|
+
unmerged = original.easy_unmerge to_unmerge
|
172
|
+
unmerged.should == {
|
173
|
+
"key" => [
|
174
|
+
{"a" => "1"},
|
175
|
+
{"c" => "1"},
|
176
|
+
]
|
177
|
+
}
|
178
|
+
end
|
159
179
|
end
|
160
180
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abner Qian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|