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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9d571e05d246f09dafc63c5a131a26ab77394134815c52d817477c8440b5efd
4
- data.tar.gz: 1a110bf8e0cbed652db35fe1a3de3795c2564b9c57d5c627ad6b94493e98b581
3
+ metadata.gz: 5d3067eb2910d94d8fdea52e4909ca6ff1691d7a1fbe11859c1c7c0163381a43
4
+ data.tar.gz: 633a4d5dfc20a1fd98832dee94e66ee9f974fe57e9bd0b6252793b57838a558b
5
5
  SHA512:
6
- metadata.gz: 9ffdd78c66d3bafed88f984f9d56f6cdd7a0a8fe5bbfa772d2feaba0d1af37112781a8fc00765b1c1708ec1d06de875fc9aaf9b3fb174b9ad1f732fcb21c76ba
7
- data.tar.gz: 50f999d01bf00141eeffe84470053b1f7c4c89c881eb69c118333b056e573408d744b24f39d19d396dbc13aca62e96a2890d8da06b8c46b0213bb171828cdd52
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
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Utils
3
- VERSION = "1.4.0".freeze
3
+ VERSION = "1.4.0.1".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.