isomorfeus-transport 22.10.0.rc1 → 22.11.0.rc1

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
  SHA256:
3
- metadata.gz: 7998e7da4356c47ca28dde957c4192a52eb5911f1406497a23db331a011b20cb
4
- data.tar.gz: 4b57a6abeebb81b2285f0b18b715eca2ede04d815d22c15898eee21f0b57fdf3
3
+ metadata.gz: a52fb1eba15fff63bd7e7b5ca33e8138da430fdb47478e68f512b2089cb0fc23
4
+ data.tar.gz: f3f6390def9478f310c4e2d910557b49151e87e5cc1135e55e5ed866ae67c8b9
5
5
  SHA512:
6
- metadata.gz: bbe960d1b159349e2d2898bf2e0c075df7d7ee6d576418c815b0bba8a1d06dfa205e17dc3b1f1ad8e251977d11b9998a49269b7c07ef92c2f27eab4dca3989d9
7
- data.tar.gz: 669de961119738dd48ceb1a77bc291ef654196119a6bab07d7413482fba6e48e863d3048c4639445299343ef6396c0278a60140bd33db924332bdd56a78d3a47
6
+ metadata.gz: 9219d64d678b7e0d2f3fcfc4584b6796904cee15329110eba690524735e52a4ad4569cbf6535bbad1667c5640c3bafc57e67bfa404ececd00187948858439bb2
7
+ data.tar.gz: 2b0b3eb3395cb4bcc67d4c95b4f18e40d937a82b0af623fda717fd7aeb76c51f8bacccc152020213197bda85687ae5668245d5bc14a85b1739adcd9a977928bd
@@ -0,0 +1,77 @@
1
+ class Hash
2
+ def deep_freeze
3
+ each_value do |value|
4
+ value.deep_freeze if value.is_a?(Hash)
5
+ end
6
+ self
7
+ end
8
+
9
+ if RUBY_ENGINE == 'opal'
10
+ def self.recursive_new(obj)
11
+ %x{
12
+ var key, val;
13
+ for (var key in obj) {
14
+ val = obj[key];
15
+ if (typeof val === "object" && !val.$$is_array && !val.$$is_hash && !Array.isArray(val)) {
16
+ obj[key] = #{Hash.recursive_new(`val`)};
17
+ }
18
+ }
19
+ return Opal.hash(obj);
20
+ }
21
+ end
22
+ end
23
+
24
+ # originally taken from: https://github.com/rails/rails/blob/main/activesupport/lib/active_support/core_ext/object/deep_dup.rb
25
+ # Returns a deep copy of hash.
26
+ #
27
+ # hash = { a: { b: 'b' } }
28
+ # dup = hash.deep_dup
29
+ # dup[:a][:c] = 'c'
30
+ #
31
+ # hash[:a][:c] # => nil
32
+ # dup[:a][:c] # => "c"
33
+ def deep_dup
34
+ hash = dup
35
+ each_pair do |key, value|
36
+ if ::String === key || ::Symbol === key
37
+ hash[key] = value.deep_dup
38
+ else
39
+ hash.delete(key)
40
+ hash[key.deep_dup] = value.deep_dup
41
+ end
42
+ end
43
+ hash
44
+ end
45
+
46
+ # originally taken from: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/hash/deep_merge.rb
47
+ # Returns a new hash with +self+ and +other_hash+ merged recursively.
48
+ #
49
+ # h1 = { a: true, b: { c: [1, 2, 3] } }
50
+ # h2 = { a: false, b: { x: [3, 4, 5] } }
51
+ #
52
+ # h1.deep_merge(h2) # => { a: false, b: { c: [1, 2, 3], x: [3, 4, 5] } }
53
+ #
54
+ # Like with Hash#merge in the standard library, a block can be provided
55
+ # to merge values:
56
+ #
57
+ # h1 = { a: 100, b: 200, c: { c1: 100 } }
58
+ # h2 = { b: 250, c: { c1: 200 } }
59
+ # h1.deep_merge(h2) { |key, this_val, other_val| this_val + other_val }
60
+ # # => { a: 100, b: 450, c: { c1: 300 } }
61
+ def deep_merge(other_hash, &block)
62
+ dup.deep_merge!(other_hash, &block)
63
+ end
64
+
65
+ # Same as +deep_merge+, but modifies +self+.
66
+ def deep_merge!(other_hash, &block)
67
+ merge!(other_hash) do |key, this_val, other_val|
68
+ if this_val.is_a?(Hash) && other_val.is_a?(Hash)
69
+ this_val.deep_merge(other_val, &block)
70
+ elsif block_given?
71
+ block.call(key, this_val, other_val)
72
+ else
73
+ other_val
74
+ end
75
+ end
76
+ end
77
+ end
@@ -28,26 +28,3 @@ class Array
28
28
  map(&:deep_dup)
29
29
  end
30
30
  end
31
-
32
- class Hash
33
- # Returns a deep copy of hash.
34
- #
35
- # hash = { a: { b: 'b' } }
36
- # dup = hash.deep_dup
37
- # dup[:a][:c] = 'c'
38
- #
39
- # hash[:a][:c] # => nil
40
- # dup[:a][:c] # => "c"
41
- def deep_dup
42
- hash = dup
43
- each_pair do |key, value|
44
- if ::String === key || ::Symbol === key
45
- hash[key] = value.deep_dup
46
- else
47
- hash.delete(key)
48
- hash[key.deep_dup] = value.deep_dup
49
- end
50
- end
51
- hash
52
- end
53
- end
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Transport
3
- VERSION = '22.10.0.rc1'
3
+ VERSION = '22.11.0.rc1'
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  require 'isomorfeus/core_ext/kernel'
2
2
  require 'isomorfeus/core_ext/object/duplicable'
3
3
  require 'isomorfeus/core_ext/object/deep_dup'
4
- require 'isomorfeus/core_ext/hash/deep_merge'
4
+ require 'isomorfeus/core_ext/hash_ext'
5
5
  require 'active_support/core_ext/string'
6
6
 
7
7
  require 'zeitwerk'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 22.10.0.rc1
4
+ version: 22.11.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-06 00:00:00.000000000 Z
11
+ date: 2022-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -86,42 +86,42 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 3.13.21
89
+ version: 3.13.23
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 3.13.21
96
+ version: 3.13.23
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: opal
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.5.1
103
+ version: 1.6.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.5.1
110
+ version: 1.6.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: opal-zeitwerk
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.4.2
117
+ version: 0.4.3
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.4.2
124
+ version: 0.4.3
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rack
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -184,14 +184,14 @@ dependencies:
184
184
  requirements:
185
185
  - - '='
186
186
  - !ruby/object:Gem::Version
187
- version: 22.10.0.rc1
187
+ version: 22.11.0.rc1
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - '='
193
193
  - !ruby/object:Gem::Version
194
- version: 22.10.0.rc1
194
+ version: 22.11.0.rc1
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: rake
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -229,7 +229,7 @@ files:
229
229
  - LICENSE
230
230
  - README.md
231
231
  - lib/isomorfeus-transport.rb
232
- - lib/isomorfeus/core_ext/hash/deep_merge.rb
232
+ - lib/isomorfeus/core_ext/hash_ext.rb
233
233
  - lib/isomorfeus/core_ext/kernel.rb
234
234
  - lib/isomorfeus/core_ext/object/deep_dup.rb
235
235
  - lib/isomorfeus/core_ext/object/duplicable.rb
@@ -1,34 +0,0 @@
1
- # originally taken from: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/hash/deep_merge.rb
2
-
3
- class Hash
4
- # Returns a new hash with +self+ and +other_hash+ merged recursively.
5
- #
6
- # h1 = { a: true, b: { c: [1, 2, 3] } }
7
- # h2 = { a: false, b: { x: [3, 4, 5] } }
8
- #
9
- # h1.deep_merge(h2) # => { a: false, b: { c: [1, 2, 3], x: [3, 4, 5] } }
10
- #
11
- # Like with Hash#merge in the standard library, a block can be provided
12
- # to merge values:
13
- #
14
- # h1 = { a: 100, b: 200, c: { c1: 100 } }
15
- # h2 = { b: 250, c: { c1: 200 } }
16
- # h1.deep_merge(h2) { |key, this_val, other_val| this_val + other_val }
17
- # # => { a: 100, b: 450, c: { c1: 300 } }
18
- def deep_merge(other_hash, &block)
19
- dup.deep_merge!(other_hash, &block)
20
- end
21
-
22
- # Same as +deep_merge+, but modifies +self+.
23
- def deep_merge!(other_hash, &block)
24
- merge!(other_hash) do |key, this_val, other_val|
25
- if this_val.is_a?(Hash) && other_val.is_a?(Hash)
26
- this_val.deep_merge(other_val, &block)
27
- elsif block_given?
28
- block.call(key, this_val, other_val)
29
- else
30
- other_val
31
- end
32
- end
33
- end
34
- end