gorilla-patch 2.1.2 → 2.2.1

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: 37db570b68e851bafb5b9f0677878b96d6b06146
4
- data.tar.gz: ec39262b859492824376df4cc7df1a4ba89065b3
3
+ metadata.gz: 5f2d2ea928c8b7555ede0e40a74318ef2f4c976e
4
+ data.tar.gz: 0be9453981f83324853200d3b78c3c8774c7c26f
5
5
  SHA512:
6
- metadata.gz: 56838483857370a8a09f127be44a16041e87fdaf402e4614fc2c25fde57e878eb052bf805ea0a1ddb63a81e3e3ad44106ddc44cfc29442655a5368f32c80adc8
7
- data.tar.gz: c68842cd800c09ada27fc0281c36c22e3eea3233e9964f97cb319dc588c616dfb183b9dc7c32710096b19eca2f71d924228a057d710ecc7df3ff4ae0ac9b6ace
6
+ metadata.gz: f3592067dfabeb4f8484ae1567f4ea60210f7641e499767bd4eafb15cd448fed3a84e2fa6c4a328bbfc5b5a6455db6c0ee699ba9837855f0aee0ca6e06a33aa8
7
+ data.tar.gz: 2181e90dd2d46872049d0b81a1ff72ef4e5ee77358ea1c9b357acff6660fce437e2262b0ec1cfe977af3dead5f55fcce36b8e5f7ffe13ea55fe6e260f773a81d
data/lib/gorilla-patch.rb CHANGED
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  Dir.glob(
4
2
  File.join(__dir__, 'gorilla-patch', '*.rb')
5
3
  ).each { |file| require file }
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require_relative 'deep_dup'
4
2
 
5
3
  module GorillaPatch
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module GorillaPatch
4
2
  ## Adding compact methods
5
3
  module Compact
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module GorillaPatch
4
2
  ## Adding include methods
5
3
  module Cover
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module GorillaPatch
4
2
  ## Adding deep_dup method
5
3
  module DeepDup
@@ -0,0 +1,33 @@
1
+ module GorillaPatch
2
+ ## Adding deep_merge method
3
+ module DeepMerge
4
+ refine Hash do
5
+ def deep_merge!(other_hash, &block)
6
+ other_hash.each do |other_key, other_value|
7
+ self_value = self[other_key]
8
+
9
+ deep_value_merge!(other_key, self_value, other_value, &block)
10
+ end
11
+
12
+ self
13
+ end
14
+
15
+ def deep_merge(other_hash, &block)
16
+ dup.deep_merge!(other_hash, &block)
17
+ end
18
+
19
+ private
20
+
21
+ def deep_value_merge!(other_key, self_value, other_value, &block)
22
+ self[other_key] =
23
+ if self_value.is_a?(Hash) && other_value.is_a?(Hash)
24
+ self_value.deep_merge(other_value, &block)
25
+ elsif block_given? && key?(other_key)
26
+ yield(other_key, self_value, other_value)
27
+ else
28
+ other_value
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module GorillaPatch
4
2
  ## Adding except methods
5
3
  module Except
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module GorillaPatch
4
2
  ## Inflections
5
3
  module Inflections
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module GorillaPatch
4
2
  ## Adding keys methods
5
3
  module Keys
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module GorillaPatch
4
2
  ## Adding namespaces-changing methods
5
3
  module Namespace
@@ -9,11 +7,9 @@ module GorillaPatch
9
7
  end
10
8
  end
11
9
 
12
- [Module, Class].each do |klass|
13
- refine klass do
14
- def demodulize
15
- to_s.demodulize
16
- end
10
+ refine Module do
11
+ def demodulize
12
+ to_s.demodulize
17
13
  end
18
14
  end
19
15
  end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module GorillaPatch
4
2
  ## Adding slice methods
5
3
  module Slice
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module GorillaPatch
4
2
  ## Adding symbolize methods
5
3
  module Symbolize
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module GorillaPatch
4
2
  ## Module for truncating
5
3
  module Truncate
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gorilla-patch
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Popov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-18 00:00:00.000000000 Z
11
+ date: 2017-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -119,6 +119,7 @@ files:
119
119
  - lib/gorilla-patch/compact.rb
120
120
  - lib/gorilla-patch/cover.rb
121
121
  - lib/gorilla-patch/deep_dup.rb
122
+ - lib/gorilla-patch/deep_merge.rb
122
123
  - lib/gorilla-patch/except.rb
123
124
  - lib/gorilla-patch/inflections.rb
124
125
  - lib/gorilla-patch/keys.rb
@@ -146,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
147
  version: '0'
147
148
  requirements: []
148
149
  rubyforge_project:
149
- rubygems_version: 2.6.8
150
+ rubygems_version: 2.6.11
150
151
  signing_key:
151
152
  specification_version: 4
152
153
  summary: Refining core classes