meld 0.0.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d28b02559c91c8dc55627f5ddbeca8c27d6accb6
4
- data.tar.gz: 027e2e81e919e098d51eefc0465101e5af2e2e9e
3
+ metadata.gz: b51b7e506fd31218fc910168885864ffd44fe24f
4
+ data.tar.gz: 2656279b91f4f527ef5c9a256620091b8c22c8fb
5
5
  SHA512:
6
- metadata.gz: a6c8eb2a81ad1bc078ce6bea8b0585701045792747e534691aa676e6e7d2d3cc9fc2c192038452abc9fe5bf98657d0294fcc092dd52b10cf9a96231803ada0e0
7
- data.tar.gz: 71720e7ce7e01ef288564df301bd043994a45941d96e356c9d26893ae8507f8c33328104b5df45ff0e76a171cf3aa7c2209dcbd94c9cf23538fb925462450bf8
6
+ metadata.gz: eb1bd6ca73cc2fc7756de17b35ac2ee3cc6822000745f4ab117e3e8f7d7a9160421ee515a51ec597327061f48235277065d2ef4798e42402c8b82045ba2c820b
7
+ data.tar.gz: d64560178d81d1c2c1e50ac90e4ed87ce72e8dee4b1da8a53ddb3f31be33eaec48d50420ae2bdfaf88d14bc58e569f16dd6954ae1de31725368d4a229a7aff93
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
+ sudo: false
2
3
  cache: bundler
3
4
  rvm:
4
5
  - 2.1.0
@@ -8,4 +9,6 @@ notifications:
8
9
  email: false
9
10
  irc:
10
11
  template:
11
- - '%{repository}/%{branch}/%{build_number}: %{message} -- %{build_url}'
12
+ - '%{repository}/%{branch}/%{build_number}: %{message} -- %{build_url}'
13
+ channels:
14
+ - irc.oftc.net#akerl
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ # 1.0.0 / 2015-01-22
2
+
3
+ * [ENHANCEMENT] Stabilized API
4
+
data/README.md CHANGED
@@ -14,7 +14,21 @@ Utility library for combining objects
14
14
 
15
15
  ### Deep hash merge -- .deep_merge
16
16
 
17
- This will merge nested hashes
17
+ This will merge nested hashes:
18
+
19
+ ```
20
+ require 'meld/hash/deep_merge'
21
+
22
+ a = { x: 4, y: { dogs: 3, cats: 5 }, z: { pizza: 10 } }
23
+ b = { y: { dogs: 6, fish: 2 } }
24
+ c = a.deep_merge(b)
25
+ p c
26
+ # {:x=>4, :y=>{:dogs=>6, :cats=>5, :fish=>2}, :z=>{:pizza=>10}}
27
+
28
+ a.deep_merge! b
29
+ p a
30
+ # {:x=>4, :y=>{:dogs=>6, :cats=>5, :fish=>2}, :z=>{:pizza=>10}}
31
+ ```
18
32
 
19
33
  Credit for the method goes to [this StackOverflow answer](http://stackoverflow.com/questions/9381553/ruby-merge-nested-hash)
20
34
 
@@ -1,16 +1,14 @@
1
- module Kernel
2
- # From https://gist.github.com/ku/e17e3d65ec4c37b60149
3
- # From http://stackoverflow.com/questions/9381553/ruby-merge-nested-hash
4
- class Hash
5
- def deep_merge!(second)
6
- merger = proc do |_, v1, v2|
7
- [v1, v2].all? { |x| x.is_a? Hash } ? v1.merge(v2, &merger) : v2
8
- end
9
- merge!(second, &merger)
1
+ # From https://gist.github.com/ku/e17e3d65ec4c37b60149
2
+ # From http://stackoverflow.com/questions/9381553/ruby-merge-nested-hash
3
+ class Hash
4
+ def deep_merge!(second)
5
+ merger = proc do |_, v1, v2|
6
+ [v1, v2].all? { |x| x.is_a? Hash } ? v1.merge(v2, &merger) : v2
10
7
  end
8
+ merge!(second, &merger)
9
+ end
11
10
 
12
- def deep_merge(second)
13
- dup.deep_merge! second
14
- end
11
+ def deep_merge(second)
12
+ dup.deep_merge! second
15
13
  end
16
14
  end
data/meld.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'meld'
3
- s.version = '0.0.2'
3
+ s.version = '1.0.0'
4
4
  s.date = Time.now.strftime("%Y-%m-%d")
5
5
 
6
6
  s.summary = 'Utility library for combining objects'
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  s.files = `git ls-files`.split
14
14
  s.test_files = `git ls-files spec/*`.split
15
15
 
16
- s.add_development_dependency 'rubocop', '~> 0.26.0'
17
- s.add_development_dependency 'rake', '~> 10.3.2'
16
+ s.add_development_dependency 'rubocop', '~> 0.28.0'
17
+ s.add_development_dependency 'rake', '~> 10.4.0'
18
18
  s.add_development_dependency 'coveralls', '~> 0.7.1'
19
19
  s.add_development_dependency 'rspec', '~> 3.1.0'
20
20
  s.add_development_dependency 'fuubar', '~> 2.0.0'
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hash do
4
+ let(:first) do
5
+ { x: 4, y: { a: 6, b: 5 } }
6
+ end
7
+ let(:second) do
8
+ { z: 9, y: { a: 9, c: 8 } }
9
+ end
10
+ let(:result) do
11
+ { x: 4, y: { a: 9, b: 5, c: 8 }, z: 9 }
12
+ end
13
+
14
+ describe '#deep_merge!' do
15
+ it 'merges subhashes' do
16
+ first.deep_merge!(second)
17
+ expect(first).to eql result
18
+ end
19
+
20
+ it 'overwrites original object' do
21
+ copy = first.dup
22
+ first.deep_merge!(second)
23
+ expect(first).not_to eql copy
24
+ end
25
+ end
26
+
27
+ describe '#deep_merge' do
28
+ it 'merges subhashes' do
29
+ third = first.deep_merge(second)
30
+ expect(third).to eql result
31
+ end
32
+
33
+ it 'does not overwrite original object' do
34
+ copy = first.dup
35
+ first.deep_merge(second)
36
+ expect(first).to eql copy
37
+ end
38
+ end
39
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meld
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Les Aker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-25 00:00:00.000000000 Z
11
+ date: 2015-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.26.0
19
+ version: 0.28.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
- version: 0.26.0
26
+ version: 0.28.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 10.3.2
33
+ version: 10.4.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
- version: 10.3.2
40
+ version: 10.4.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: coveralls
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -90,6 +90,7 @@ files:
90
90
  - ".rspec"
91
91
  - ".rubocop.yml"
92
92
  - ".travis.yml"
93
+ - CHANGELOG.md
93
94
  - Gemfile
94
95
  - LICENSE
95
96
  - README.md
@@ -97,6 +98,7 @@ files:
97
98
  - lib/meld.rb
98
99
  - lib/meld/hash/deep_merge.rb
99
100
  - meld.gemspec
101
+ - spec/meld/hash/deep_merge_spec.rb
100
102
  - spec/meld_spec.rb
101
103
  - spec/spec_helper.rb
102
104
  homepage: https://github.com/akerl/meld
@@ -124,5 +126,6 @@ signing_key:
124
126
  specification_version: 4
125
127
  summary: Utility library for combining objects
126
128
  test_files:
129
+ - spec/meld/hash/deep_merge_spec.rb
127
130
  - spec/meld_spec.rb
128
131
  - spec/spec_helper.rb