apple_core 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +4 -2
- data/lib/apple_core/refinements/deep_dup.rb +61 -0
- data/lib/apple_core/refinements/hash.rb +22 -0
- data/lib/apple_core/version.rb +1 -1
- metadata +3 -2
- metadata.gz.sig +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 757255ae409a091e04dba5776628ae28c89e95b3e33f3aa44734a3dfe1797bba
|
4
|
+
data.tar.gz: 2dac16f8a9b9e1e430f8bb2facf9ad900687cfd308f6c9bd53a7480076704056
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 134fe2c31b537e9d297a1c3efdd27c9eb3d15457071006747c35f15cecc15183b78ad1a05c7f20d1f5d57430c4ca2ffe937c9994ee127816cb2bc608444608c7
|
7
|
+
data.tar.gz: 6570d7870fbf243e87dc19e8fcb20b8af28d37692ddfba9f77fdd7a7143f1004db8bb9a65a21ab0b0d9eb3ea87e63e5bfd9cc5613695e3a7b229f723374dc9d5
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AppleCore
|
4
|
+
module Refinements
|
5
|
+
module DeepDup
|
6
|
+
refine ::Array do
|
7
|
+
unless method_defined?(:deep_dup)
|
8
|
+
def deep_dup
|
9
|
+
map { |i| i.respond_to?(:deep_dup) ? i.deep_dup : i.dup }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
refine ::Object do
|
15
|
+
unless method_defined?(:deep_dup)
|
16
|
+
def deep_dup
|
17
|
+
dup
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
refine ::Hash do
|
23
|
+
unless method_defined?(:deep_dup)
|
24
|
+
def deep_dup
|
25
|
+
dup.tap do |hash|
|
26
|
+
each_pair do |key, value|
|
27
|
+
if key.frozen? && key.is_a?(::String)
|
28
|
+
hash[key] = value.deep_dup
|
29
|
+
else
|
30
|
+
hash.delete(key)
|
31
|
+
hash[key.deep_dup] = value.deep_dup
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
module ActiveSupport
|
43
|
+
class HashWithIndifferentAccess < Hash
|
44
|
+
using ::AppleCore::Refinements::DeepDup
|
45
|
+
|
46
|
+
unless method_defined?(:deep_dup)
|
47
|
+
def deep_dup
|
48
|
+
dup.tap do |hash|
|
49
|
+
each_pair do |key, value|
|
50
|
+
if key.frozen? && key.is_a?(::String)
|
51
|
+
hash[key] = value.deep_dup
|
52
|
+
else
|
53
|
+
hash.delete(key)
|
54
|
+
hash[key.deep_dup] = value.deep_dup
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -20,6 +20,28 @@ refine ::Hash do
|
|
20
20
|
Transforms::Hash.deep_underscore_keys(self)
|
21
21
|
end
|
22
22
|
|
23
|
+
unless method_defined?(:slice)
|
24
|
+
def slice(*keys)
|
25
|
+
keys.each_with_object({}) do |k, hash|
|
26
|
+
hash[k] = self[k] if has_key?(k)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
unless method_defined?(:slice!)
|
32
|
+
def slice!(*keys)
|
33
|
+
omit = slice(*self.keys - keys)
|
34
|
+
|
35
|
+
hash = slice(*keys)
|
36
|
+
hash.default = default
|
37
|
+
hash.default_proc = default_proc if default_proc
|
38
|
+
|
39
|
+
replace(hash)
|
40
|
+
|
41
|
+
omit
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
23
45
|
def symbolize_keys
|
24
46
|
result = {}
|
25
47
|
|
data/lib/apple_core/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apple_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thegranddesign
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
Y2GAoHKstmfIVhc4XHOPpmTd2o/C29O9oaRgjrkfQEhF/KvJ/PhoV5hvokzsCyI5
|
32
32
|
iUeXPfvrGD/itYIBCgk+fnzyQQ4QtE5hTQaWQ3o2
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2018-
|
34
|
+
date: 2018-05-03 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: activemodel
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/apple_core/active_model/validations/inclusion_validator.rb
|
117
117
|
- lib/apple_core/active_record/base.rb
|
118
118
|
- lib/apple_core/refinements/array.rb
|
119
|
+
- lib/apple_core/refinements/deep_dup.rb
|
119
120
|
- lib/apple_core/refinements/hash.rb
|
120
121
|
- lib/apple_core/refinements/integer.rb
|
121
122
|
- lib/apple_core/refinements/string.rb
|
metadata.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
R��,��ɢH�;�]R��J�O�����1�1��[�Oл�����bߞ�J���u��Ki����j�!&otY�|DR.
|