metanorma-utils 1.3.2 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +1 -1
- data/.github/workflows/release.yml +24 -0
- data/lib/metanorma-utils.rb +1 -0
- data/lib/utils/hash_transform_keys.rb +63 -55
- data/lib/utils/version.rb +1 -1
- data/spec/hash_transform_keys_spec.rb +5 -0
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9d571e05d246f09dafc63c5a131a26ab77394134815c52d817477c8440b5efd
|
4
|
+
data.tar.gz: 1a110bf8e0cbed652db35fe1a3de3795c2564b9c57d5c627ad6b94493e98b581
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ffdd78c66d3bafed88f984f9d56f6cdd7a0a8fe5bbfa772d2feaba0d1af37112781a8fc00765b1c1708ec1d06de875fc9aaf9b3fb174b9ad1f732fcb21c76ba
|
7
|
+
data.tar.gz: 50f999d01bf00141eeffe84470053b1f7c4c89c881eb69c118333b056e573408d744b24f39d19d396dbc13aca62e96a2890d8da06b8c46b0213bb171828cdd52
|
data/.github/workflows/rake.yml
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
|
+
name: release
|
4
|
+
|
5
|
+
on:
|
6
|
+
workflow_dispatch:
|
7
|
+
inputs:
|
8
|
+
next_version:
|
9
|
+
description: |
|
10
|
+
Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
|
11
|
+
required: true
|
12
|
+
default: 'skip'
|
13
|
+
push:
|
14
|
+
tags: [ v* ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
release:
|
18
|
+
uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
|
19
|
+
with:
|
20
|
+
next_version: ${{ github.event.inputs.next_version }}
|
21
|
+
secrets:
|
22
|
+
rubygems-api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
|
23
|
+
pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
|
24
|
+
|
data/lib/metanorma-utils.rb
CHANGED
@@ -1,67 +1,75 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
module Metanorma
|
2
|
+
module Utils
|
3
|
+
module Array
|
4
|
+
def stringify_all_keys
|
5
|
+
map do |v|
|
6
|
+
case v
|
7
|
+
when Hash, Array
|
8
|
+
v.stringify_all_keys
|
9
|
+
else
|
10
|
+
v
|
11
|
+
end
|
12
|
+
end
|
9
13
|
end
|
10
|
-
end
|
11
|
-
end
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
def symbolize_all_keys
|
16
|
+
map do |v|
|
17
|
+
case v
|
18
|
+
when Hash, Array
|
19
|
+
v.symbolize_all_keys
|
20
|
+
else
|
21
|
+
v
|
22
|
+
end
|
23
|
+
end
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
29
|
+
module Metanorma
|
30
|
+
module Utils
|
31
|
+
module Hash
|
32
|
+
def stringify_all_keys
|
33
|
+
result = {}
|
34
|
+
each do |k, v|
|
35
|
+
result[k.to_s] = case v
|
36
|
+
when Hash, Array
|
37
|
+
v.stringify_all_keys
|
38
|
+
else
|
39
|
+
v
|
40
|
+
end
|
41
|
+
end
|
42
|
+
result
|
43
|
+
end
|
38
44
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
def symbolize_all_keys
|
46
|
+
result = {}
|
47
|
+
each do |k, v|
|
48
|
+
result[k.to_sym] = case v
|
49
|
+
when Hash, Array
|
50
|
+
v.symbolize_all_keys
|
51
|
+
else
|
52
|
+
v
|
53
|
+
end
|
54
|
+
end
|
55
|
+
result
|
56
|
+
end
|
51
57
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
def deep_merge(second)
|
59
|
+
merger = proc { |_, v1, v2|
|
60
|
+
if Hash === v1 && Hash === v2
|
61
|
+
v1.merge(v2, &merger)
|
62
|
+
elsif Array === v1 && Array === v2
|
63
|
+
v1 | v2
|
64
|
+
elsif [:undefined, nil,
|
65
|
+
:nil].include?(v2)
|
66
|
+
v1
|
67
|
+
else
|
68
|
+
v2
|
69
|
+
end
|
70
|
+
}
|
71
|
+
merge(second.to_h, &merger)
|
63
72
|
end
|
64
|
-
|
65
|
-
merge(second.to_h, &merger)
|
73
|
+
end
|
66
74
|
end
|
67
75
|
end
|
data/lib/utils/version.rb
CHANGED
@@ -3,6 +3,8 @@ require "utils/hash_transform_keys"
|
|
3
3
|
|
4
4
|
RSpec.describe Metanorma::Utils do
|
5
5
|
it "deep stringify hash but skip values" do
|
6
|
+
Hash.include Metanorma::Utils::Hash
|
7
|
+
Array.include Metanorma::Utils::Array
|
6
8
|
result = {
|
7
9
|
test0: :test0,
|
8
10
|
test1: false,
|
@@ -27,6 +29,8 @@ RSpec.describe Metanorma::Utils do
|
|
27
29
|
end
|
28
30
|
|
29
31
|
it "deep symbolize hash but skip values" do
|
32
|
+
Hash.include Metanorma::Utils::Hash
|
33
|
+
Array.include Metanorma::Utils::Array
|
30
34
|
result = {
|
31
35
|
test0: "test0",
|
32
36
|
test1: false,
|
@@ -51,6 +55,7 @@ RSpec.describe Metanorma::Utils do
|
|
51
55
|
end
|
52
56
|
|
53
57
|
it "deep merges hashes" do
|
58
|
+
Hash.include Metanorma::Utils::Hash
|
54
59
|
hash1 = { a: [1, 2], b: "c", c: 4, e: { f: { g: "1" } } }
|
55
60
|
hash2 = { a: [3], b: "d", d: 5, e: { f: { h: "2" } } }
|
56
61
|
expect(hash1.deep_merge(hash2)).to eq({ a: [1, 2, 3], b: "d", c: 4,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -300,6 +300,7 @@ extensions: []
|
|
300
300
|
extra_rdoc_files: []
|
301
301
|
files:
|
302
302
|
- ".github/workflows/rake.yml"
|
303
|
+
- ".github/workflows/release.yml"
|
303
304
|
- ".gitignore"
|
304
305
|
- ".hound.yml"
|
305
306
|
- ".rubocop.yml"
|
@@ -327,7 +328,7 @@ homepage: https://github.com/metanorma/metanorma-utils
|
|
327
328
|
licenses:
|
328
329
|
- BSD-2-Clause
|
329
330
|
metadata: {}
|
330
|
-
post_install_message:
|
331
|
+
post_install_message:
|
331
332
|
rdoc_options: []
|
332
333
|
require_paths:
|
333
334
|
- lib
|
@@ -342,8 +343,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
342
343
|
- !ruby/object:Gem::Version
|
343
344
|
version: '0'
|
344
345
|
requirements: []
|
345
|
-
rubygems_version: 3.
|
346
|
-
signing_key:
|
346
|
+
rubygems_version: 3.1.6
|
347
|
+
signing_key:
|
347
348
|
specification_version: 4
|
348
349
|
summary: metanorma-utils
|
349
350
|
test_files: []
|