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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb766833ae078338bdac8e0954736f83dfc5feee9de6cbc15c03bd1998848529
4
- data.tar.gz: 93ee70fa9e268f252c5c9c3f5dd58e2859c2b794b13d50e117f374ae8e80efde
3
+ metadata.gz: a9d571e05d246f09dafc63c5a131a26ab77394134815c52d817477c8440b5efd
4
+ data.tar.gz: 1a110bf8e0cbed652db35fe1a3de3795c2564b9c57d5c627ad6b94493e98b581
5
5
  SHA512:
6
- metadata.gz: 8572ae07eb6b970d0b00c1289b0652c293690b241b4d39a91b4df235a77ef29809dba122be75795bd7f8bde1fcebd59deeee9cb4f001259675626f73e0cd5869
7
- data.tar.gz: 63f761a6ada0d87f7663811b89f594eb23dafb9d9da9c130d158bd58671648fc5b6cd8a3ed9db895345b1267e3c02141937bda7141e414971dabafa9ec93bbaa
6
+ metadata.gz: 9ffdd78c66d3bafed88f984f9d56f6cdd7a0a8fe5bbfa772d2feaba0d1af37112781a8fc00765b1c1708ec1d06de875fc9aaf9b3fb174b9ad1f732fcb21c76ba
7
+ data.tar.gz: 50f999d01bf00141eeffe84470053b1f7c4c89c881eb69c118333b056e573408d744b24f39d19d396dbc13aca62e96a2890d8da06b8c46b0213bb171828cdd52
@@ -10,6 +10,6 @@ on:
10
10
 
11
11
  jobs:
12
12
  rake:
13
- uses: metanorma/metanorma-build-scripts/.github/workflows/generic-rake.yml@main
13
+ uses: metanorma/ci/.github/workflows/generic-rake.yml@main
14
14
  secrets:
15
15
  pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
@@ -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
+
@@ -1,4 +1,5 @@
1
1
  require_relative "utils/version"
2
+ require_relative "utils/hash_transform_keys"
2
3
  require_relative "utils/main"
3
4
  require_relative "utils/image"
4
5
  require_relative "utils/log"
@@ -1,67 +1,75 @@
1
- class Array
2
- def stringify_all_keys
3
- map do |v|
4
- case v
5
- when Hash, Array
6
- v.stringify_all_keys
7
- else
8
- v
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
- def symbolize_all_keys
14
- map do |v|
15
- case v
16
- when Hash, Array
17
- v.symbolize_all_keys
18
- else
19
- v
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
- class Hash
26
- def stringify_all_keys
27
- result = {}
28
- each do |k, v|
29
- result[k.to_s] = case v
30
- when Hash, Array
31
- v.stringify_all_keys
32
- else
33
- v
34
- end
35
- end
36
- result
37
- end
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
- def symbolize_all_keys
40
- result = {}
41
- each do |k, v|
42
- result[k.to_sym] = case v
43
- when Hash, Array
44
- v.symbolize_all_keys
45
- else
46
- v
47
- end
48
- end
49
- result
50
- end
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
- def deep_merge(second)
53
- merger = proc { |_, v1, v2|
54
- if Hash === v1 && Hash === v2
55
- v1.merge(v2, &merger)
56
- elsif Array === v1 && Array === v2
57
- v1 | v2
58
- elsif [:undefined, nil,
59
- :nil].include?(v2)
60
- v1
61
- else
62
- v2
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
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Utils
3
- VERSION = "1.3.2".freeze
3
+ VERSION = "1.4.0".freeze
4
4
  end
5
5
  end
@@ -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.3.2
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-08-29 00:00:00.000000000 Z
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.3.16
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: []