metanorma-utils 1.4.0 → 1.4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/utils/hash_transform_keys.rb +6 -6
- data/lib/utils/main.rb +4 -4
- data/lib/utils/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d3067eb2910d94d8fdea52e4909ca6ff1691d7a1fbe11859c1c7c0163381a43
|
4
|
+
data.tar.gz: 633a4d5dfc20a1fd98832dee94e66ee9f974fe57e9bd0b6252793b57838a558b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bf2b0ee3f74b32e6dda49771df96f9f7121f32ed9eba76d89e5cba66b55a338da69b25acadd652092b3ad81fd313bc5506db3c8e2e054b9192ab7cfc59f017b
|
7
|
+
data.tar.gz: a1e0079091ba03bd9d173624dd43d764d409c4bf32cc75a052492b079a99a66833056ea8bf6e4f85d75d323835f2f38961de59af865fef0865b0a28492e907a5
|
@@ -4,7 +4,7 @@ module Metanorma
|
|
4
4
|
def stringify_all_keys
|
5
5
|
map do |v|
|
6
6
|
case v
|
7
|
-
when Hash, Array
|
7
|
+
when ::Hash, ::Array
|
8
8
|
v.stringify_all_keys
|
9
9
|
else
|
10
10
|
v
|
@@ -15,7 +15,7 @@ module Metanorma
|
|
15
15
|
def symbolize_all_keys
|
16
16
|
map do |v|
|
17
17
|
case v
|
18
|
-
when Hash, Array
|
18
|
+
when ::Hash, ::Array
|
19
19
|
v.symbolize_all_keys
|
20
20
|
else
|
21
21
|
v
|
@@ -33,7 +33,7 @@ module Metanorma
|
|
33
33
|
result = {}
|
34
34
|
each do |k, v|
|
35
35
|
result[k.to_s] = case v
|
36
|
-
when Hash, Array
|
36
|
+
when ::Hash, ::Array
|
37
37
|
v.stringify_all_keys
|
38
38
|
else
|
39
39
|
v
|
@@ -46,7 +46,7 @@ module Metanorma
|
|
46
46
|
result = {}
|
47
47
|
each do |k, v|
|
48
48
|
result[k.to_sym] = case v
|
49
|
-
when Hash, Array
|
49
|
+
when ::Hash, ::Array
|
50
50
|
v.symbolize_all_keys
|
51
51
|
else
|
52
52
|
v
|
@@ -57,9 +57,9 @@ module Metanorma
|
|
57
57
|
|
58
58
|
def deep_merge(second)
|
59
59
|
merger = proc { |_, v1, v2|
|
60
|
-
if Hash === v1 && Hash === v2
|
60
|
+
if ::Hash === v1 && ::Hash === v2
|
61
61
|
v1.merge(v2, &merger)
|
62
|
-
elsif Array === v1 && Array === v2
|
62
|
+
elsif ::Array === v1 && ::Array === v2
|
63
63
|
v1 | v2
|
64
64
|
elsif [:undefined, nil,
|
65
65
|
:nil].include?(v2)
|
data/lib/utils/main.rb
CHANGED
@@ -73,17 +73,17 @@ module Metanorma
|
|
73
73
|
def set_nested_value(hash, keys, new_val)
|
74
74
|
key = keys[0]
|
75
75
|
if keys.length == 1
|
76
|
-
hash[key] = if hash[key].is_a?(Array) then (hash[key] << new_val)
|
76
|
+
hash[key] = if hash[key].is_a?(::Array) then (hash[key] << new_val)
|
77
77
|
else hash[key].nil? ? new_val : [hash[key], new_val]
|
78
78
|
end
|
79
|
-
elsif hash[key].is_a?(Array)
|
79
|
+
elsif hash[key].is_a?(::Array)
|
80
80
|
hash[key][-1] = {} if !hash[key].empty? && hash[key][-1].nil?
|
81
|
-
hash[key] << {} if hash[key].empty? || !hash[key][-1].is_a?(Hash)
|
81
|
+
hash[key] << {} if hash[key].empty? || !hash[key][-1].is_a?(::Hash)
|
82
82
|
set_nested_value(hash[key][-1], keys[1..-1], new_val)
|
83
83
|
elsif hash[key].nil? || hash[key].empty?
|
84
84
|
hash[key] = {}
|
85
85
|
set_nested_value(hash[key], keys[1..-1], new_val)
|
86
|
-
elsif hash[key].is_a?(Hash) && !hash[key][keys[1]]
|
86
|
+
elsif hash[key].is_a?(::Hash) && !hash[key][keys[1]]
|
87
87
|
set_nested_value(hash[key], keys[1..-1], new_val)
|
88
88
|
elsif !hash[key][keys[1]]
|
89
89
|
hash[key] = [hash[key], {}]
|
data/lib/utils/version.rb
CHANGED