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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGE4YThiNDMzODk5ZDA1MDQyZTY5YWZjMDI3MzNhNTJlMjA2ZTI3Mg==
4
+ YWUyMjFiNjI3ODUzYjhjNjI0N2YyODczNDU3MTNlMmExZGI3NWI4Ng==
5
5
  data.tar.gz: !binary |-
6
- ZDkzMmJjMzA5OWVjYzRhNjQ1NTQ1MTc4NWQwOTJkNjQ3NmRhN2E4ZQ==
6
+ NDk4MzAzNzVmZTJhMzc5M2VlMDVmMmE1Mjg1MjAxYjkwN2E3ZGQwYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Nzc5NmE0M2U1ZTAzYjk5OWU3YzJmZjgyYTcyZmM0MzZjZDVmMGVjNDhiN2Ix
10
- OWVmM2U2NTRmNmNmZjYzYjljYmI0ZGZhOTVhMDM2ZWYwYjFkNjYzMDdmZjM1
11
- ODE1NzQ2NGQwOTE0NWY3YTc3NDBjYzY2ZDYyODAyY2IyZWE5ODI=
9
+ NWFjNTYxNDJiNzQ1MmIwZDdmZDAxMzE4NTc5M2FhNGUxY2Q5ZmZiMzRjMmMx
10
+ MmRmZDEzYWE1YWZjZWE1OGVlYzZiODc2ZDA4ZmQ5M2UxNjgyZmVkMmU3OThi
11
+ ODhmM2VkODdkYTQyNGY4MTM1YTExNzRiNzQwNDAwZjgxNjNiNWU=
12
12
  data.tar.gz: !binary |-
13
- NzQ4ZGU3MmU1ZjY2ZGRhNTJiODFlYTI2ZjUxZjlkNWQ3MDM5YWJkZmI2OWVi
14
- MzI1MWZiOTYyYzhmMDc1MjkzYzY4NGZjM2I0ZjI4YmI3MWJkZmFiNjE1NzY3
15
- ZGVkY2I2YjBiNzkwNmQzMTA0MjBlOWRiNjA4ZDQzMWExYzcyYWQ=
13
+ NWZiYjcyZGViOGZiZjYzZTZiYWVkMDA4MTU3YjczYmJjZDYyYmM1Mjg5YTE4
14
+ NzUxOWVjOGVlZjUzZTRhMTBiYzlhMGJmMjdlZDRhMDgyYTIwMDEyNWQ0NWRl
15
+ NmQ1ZTE4YWQwZWJlY2Q0MjcwMTExY2U0ZWNlOWE5ZmQ0YWNkYjg=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -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.sort!
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
@@ -132,29 +132,49 @@ describe EasyDiff do
132
132
  added.should == {:possibly_empty_string => "not empty"}
133
133
  end
134
134
 
135
- it "should merge Arrays containing Hashes" do
136
- original = {
137
- "key" => [
138
- {"c" => "1"},
139
- {"a" => "2"},
140
- {"a" => "1"},
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
- to_merge = {
145
- "key" => [
146
- {"b" => "2"},
147
- ]
148
- }
146
+ it "should merge properly" do
147
+ to_merge = {
148
+ "key" => [
149
+ {"b" => "2"},
150
+ ]
151
+ }
149
152
 
150
- merged = original.easy_merge to_merge
151
- merged.should == {
152
- "key" => [
153
- {"a" => "1"},
154
- {"a" => "2"},
155
- {"b" => "2"},
156
- {"c" => "1"},
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.6
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: 2015-08-05 00:00:00.000000000 Z
11
+ date: 2016-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec