easy_diff 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YWJhY2NkMDUwNDViYWQ2Nzk5OTc0YTE4ODJjYTM4MTBmNmQ0MzYxNw==
5
+ data.tar.gz: !binary |-
6
+ ZDAwZWZjNmY5ZTY4NjJkYTgzYjJiMzUxNmNiMzNkNGI2NjZhMGQyNQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MzEzZDE5OWY3ODBiYmEzZjJlNmE3MWZmNWYwMDM0OTMzZTEzZWUwMzMyODkz
10
+ YWRiNzA3ZTUxNDhiNWU4OTJiYTQxNDM0YWM1ZjZjZjYxOWM4NWM0Y2QwYjc2
11
+ NDNhMzRhODY5NjQxMTczMmQ1ZTJhZmJkMzJlM2IzNDY5Njc1MTY=
12
+ data.tar.gz: !binary |-
13
+ ZDViMzFiZGUzZjU0MmQ0NzYzMmFjYjJmYTM3YWNiZDk0MWVhMGZmYzFjMzU1
14
+ ZTUzOWY4YzViZGI2ZjQ1MGVlZDc2NWMxMDY2ZjNhOTdiMzIxODdjNWZkYjkw
15
+ OTQyOTYxODY0M2YwZTUwOGU2ODg3ZDZlODQxNGMyMGVlZWUxYzM=
data/Gemfile CHANGED
@@ -8,7 +8,6 @@ source "http://rubygems.org"
8
8
  group :development do
9
9
  gem "rspec", "~> 2.4.0"
10
10
  gem "yard", "~> 0.6.0"
11
- gem "bundler", "~> 1.0.0"
12
- gem "jeweler", "~> 1.5.2"
13
- gem "rcov", ">= 0"
11
+ gem "jeweler"
12
+ gem "simplecov", ">= 0", require: false
14
13
  end
@@ -1,14 +1,52 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ addressable (2.3.8)
5
+ builder (3.2.2)
6
+ descendants_tracker (0.0.4)
7
+ thread_safe (~> 0.3, >= 0.3.1)
4
8
  diff-lcs (1.1.3)
5
- git (1.2.5)
6
- jeweler (1.5.2)
7
- bundler (~> 1.0.0)
9
+ docile (1.1.5)
10
+ faraday (0.9.1)
11
+ multipart-post (>= 1.2, < 3)
12
+ git (1.2.9.1)
13
+ github_api (0.12.4)
14
+ addressable (~> 2.3)
15
+ descendants_tracker (~> 0.0.4)
16
+ faraday (~> 0.8, < 0.10)
17
+ hashie (>= 3.4)
18
+ multi_json (>= 1.7.5, < 2.0)
19
+ nokogiri (~> 1.6.6)
20
+ oauth2
21
+ hashie (3.4.2)
22
+ highline (1.7.3)
23
+ jeweler (2.0.1)
24
+ builder
25
+ bundler (>= 1.0)
8
26
  git (>= 1.2.5)
27
+ github_api
28
+ highline (>= 1.6.15)
29
+ nokogiri (>= 1.5.10)
9
30
  rake
10
- rake (0.8.7)
11
- rcov (0.9.9)
31
+ rdoc
32
+ json (1.8.3)
33
+ jwt (1.5.1)
34
+ mini_portile (0.6.2)
35
+ multi_json (1.11.2)
36
+ multi_xml (0.5.5)
37
+ multipart-post (2.0.0)
38
+ nokogiri (1.6.6.2)
39
+ mini_portile (~> 0.6.0)
40
+ oauth2 (1.0.0)
41
+ faraday (>= 0.8, < 0.10)
42
+ jwt (~> 1.0)
43
+ multi_json (~> 1.3)
44
+ multi_xml (~> 0.5)
45
+ rack (~> 1.2)
46
+ rack (1.6.4)
47
+ rake (10.4.2)
48
+ rdoc (4.2.0)
49
+ json (~> 1.4)
12
50
  rspec (2.4.0)
13
51
  rspec-core (~> 2.4.0)
14
52
  rspec-expectations (~> 2.4.0)
@@ -17,14 +55,19 @@ GEM
17
55
  rspec-expectations (2.4.0)
18
56
  diff-lcs (~> 1.1.2)
19
57
  rspec-mocks (2.4.0)
20
- yard (0.6.4)
58
+ simplecov (0.10.0)
59
+ docile (~> 1.1.0)
60
+ json (~> 1.8)
61
+ simplecov-html (~> 0.10.0)
62
+ simplecov-html (0.10.0)
63
+ thread_safe (0.3.5)
64
+ yard (0.6.8)
21
65
 
22
66
  PLATFORMS
23
67
  ruby
24
68
 
25
69
  DEPENDENCIES
26
- bundler (~> 1.0.0)
27
- jeweler (~> 1.5.2)
28
- rcov
70
+ jeweler
29
71
  rspec (~> 2.4.0)
72
+ simplecov
30
73
  yard (~> 0.6.0)
@@ -54,7 +54,8 @@ The first contains what has to be removed from self to create the second hash. T
54
54
 
55
55
  === Hash#easy_merge
56
56
 
57
- Takes a hash and recursively merges it with self. Arrays are merged by the union operation and then sorted.
57
+ Takes a hash and recursively merges it with self. Arrays are merged by the union operation and then sorted. Arrays of Hashes are sorted by invoking +#sort+ on each Hash to make them comparable.
58
+
58
59
  Using Hash#easy_merge! will modify self instead of returning a new hash.
59
60
 
60
61
  original = {
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -51,20 +51,20 @@ Gem::Specification.new do |s|
51
51
  s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
52
52
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
53
53
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
54
- s.add_development_dependency(%q<rcov>, [">= 0"])
54
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
55
55
  else
56
56
  s.add_dependency(%q<rspec>, ["~> 2.4.0"])
57
57
  s.add_dependency(%q<yard>, ["~> 0.6.0"])
58
58
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
59
59
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
60
- s.add_dependency(%q<rcov>, [">= 0"])
60
+ s.add_dependency(%q<simplecov>, [">= 0"])
61
61
  end
62
62
  else
63
63
  s.add_dependency(%q<rspec>, ["~> 2.4.0"])
64
64
  s.add_dependency(%q<yard>, ["~> 0.6.0"])
65
65
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
66
66
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
67
- s.add_dependency(%q<rcov>, [">= 0"])
67
+ s.add_dependency(%q<simplecov>, [">= 0"])
68
68
  end
69
69
  end
70
70
 
@@ -56,7 +56,9 @@ module EasyDiff
56
56
  added_keys.each{ |key| original[key] = easy_merge!(original[key], added[key])}
57
57
  elsif original.is_a?(Array) && added.is_a?(Array)
58
58
  original |= added
59
- original.sort!
59
+ original.sort_by! { |item|
60
+ item.is_a?(Hash) ? item.sort : item
61
+ }
60
62
  else
61
63
  original = added.safe_dup
62
64
  end
@@ -131,4 +131,30 @@ describe EasyDiff do
131
131
  removed.should == {:possibly_empty_string => ""}
132
132
  added.should == {:possibly_empty_string => "not empty"}
133
133
  end
134
+
135
+ it "should merge Arrays containing Hashes" do
136
+ original = {
137
+ "key" => [
138
+ {"c" => "1"},
139
+ {"a" => "2"},
140
+ {"a" => "1"},
141
+ ]
142
+ }
143
+
144
+ to_merge = {
145
+ "key" => [
146
+ {"b" => "2"},
147
+ ]
148
+ }
149
+
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
+ }
159
+ end
134
160
  end
@@ -1,3 +1,6 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
1
4
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
5
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
6
  require 'rspec'
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 0.0.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Abner Qian
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-12-19 00:00:00.000000000 Z
11
+ date: 2015-08-03 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: yard
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,47 +34,27 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
45
40
  version: 0.6.0
46
- - !ruby/object:Gem::Dependency
47
- name: bundler
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: 1.0.0
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: 1.0.0
62
41
  - !ruby/object:Gem::Dependency
63
42
  name: jeweler
64
43
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
44
  requirements:
67
- - - ~>
45
+ - - ! '>='
68
46
  - !ruby/object:Gem::Version
69
- version: 1.5.2
47
+ version: '0'
70
48
  type: :development
71
49
  prerelease: false
72
50
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
51
  requirements:
75
- - - ~>
52
+ - - ! '>='
76
53
  - !ruby/object:Gem::Version
77
- version: 1.5.2
54
+ version: '0'
78
55
  - !ruby/object:Gem::Dependency
79
- name: rcov
56
+ name: simplecov
80
57
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
58
  requirements:
83
59
  - - ! '>='
84
60
  - !ruby/object:Gem::Version
@@ -86,7 +62,6 @@ dependencies:
86
62
  type: :development
87
63
  prerelease: false
88
64
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
65
  requirements:
91
66
  - - ! '>='
92
67
  - !ruby/object:Gem::Version
@@ -121,31 +96,25 @@ files:
121
96
  homepage: http://github.com/Blargel/easy_diff
122
97
  licenses:
123
98
  - MIT
99
+ metadata: {}
124
100
  post_install_message:
125
101
  rdoc_options: []
126
102
  require_paths:
127
103
  - lib
128
104
  required_ruby_version: !ruby/object:Gem::Requirement
129
- none: false
130
105
  requirements:
131
106
  - - ! '>='
132
107
  - !ruby/object:Gem::Version
133
108
  version: '0'
134
- segments:
135
- - 0
136
- hash: -1698235666282817780
137
109
  required_rubygems_version: !ruby/object:Gem::Requirement
138
- none: false
139
110
  requirements:
140
111
  - - ! '>='
141
112
  - !ruby/object:Gem::Version
142
113
  version: '0'
143
114
  requirements: []
144
115
  rubyforge_project:
145
- rubygems_version: 1.8.29
116
+ rubygems_version: 2.2.2
146
117
  signing_key:
147
- specification_version: 3
118
+ specification_version: 4
148
119
  summary: Recursive diff, merge, and unmerge for hashes and arrays.
149
- test_files:
150
- - spec/easy_diff_spec.rb
151
- - spec/spec_helper.rb
120
+ test_files: []