hierarchical_config 0.13 → 1.0.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: 63ac58b07f108d686879b6257643b289d9c2d702941b294d96cd64f2899dc241
4
- data.tar.gz: 23deffaef12f8c1c252f889c0ae62f53a580d711df76b0909d3d2047515d99ab
3
+ metadata.gz: 070231b8c0179a1e16e43d1ea74a0e3073bf2fcb8af2ba0dcd49ec085a34a1e0
4
+ data.tar.gz: f1f298936c9f901db2d87d59e70541dc12628716cdf382af40322e5b0a5fc282
5
5
  SHA512:
6
- metadata.gz: f7847a6250d05cd1a9f5af1666d1b0632664dc7a5b49c98c845c5e69892ba0a8988a3355d10418504aed9a427caf475832fca2922003164d58cfdca1ef36e6cf
7
- data.tar.gz: feeafb9fd68c08ef03c6ebf9d9900d3cfd8da773499cbedcf19b58306bbce09bef40fe931f86b37300a3487244d8fe1a34e6fef919fcf874bcbebe0ed37bb454
6
+ metadata.gz: 014c8263e145a8b5b850c05166f6dedee5423e05b7972f463074b9a594b735ad624f1c46989580692dc6f25af1f0e205bdfaea3095ee1db08ab0973f4d0f7468
7
+ data.tar.gz: 92a99098ba12a055b88127fd9d8f0003f26b376a53ac6bbe4da594ff768b9a13400143925176b3493d12f148cea537d42ce8a1a85d72d4464c3f4899643c18f4
@@ -0,0 +1,41 @@
1
+ name: release-please
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ permissions:
9
+ contents: write
10
+ pull-requests: write
11
+
12
+ jobs:
13
+ release-please:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: GoogleCloudPlatform/release-please-action@v3
17
+ id: release
18
+ with:
19
+ release-type: ruby
20
+ package-name: hierarchical_config
21
+ bump-minor-pre-major: true
22
+ version-file: "lib/hierarchical_config/version.rb"
23
+ - uses: actions/checkout@v2
24
+ if: ${{ steps.release.outputs.release_created }}
25
+ - uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: 3.2.2
28
+ if: ${{ steps.release.outputs.release_created }}
29
+ - run: bundle install
30
+ if: ${{ steps.release.outputs.release_created }}
31
+ - name: publish gem
32
+ run: |
33
+ mkdir -p $HOME/.gem
34
+ touch $HOME/.gem/credentials
35
+ chmod 0600 $HOME/.gem/credentials
36
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
37
+ gem build *.gemspec
38
+ gem push *.gem
39
+ env:
40
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
41
+ if: ${{ steps.release.outputs.release_created }}
@@ -22,15 +22,12 @@ jobs:
22
22
  runs-on: ubuntu-latest
23
23
  strategy:
24
24
  matrix:
25
- ruby-version: ['2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2']
25
+ ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2']
26
26
  include:
27
27
  - gemfile: Gemfile
28
28
  not-only-test: true
29
- - gemfile: Gemfile.2.4
30
- ruby-version: 2.5
31
- not-only-test: false
32
- - gemfile: Gemfile.2.4
33
- ruby-version: 2.4
29
+ - gemfile: Gemfile
30
+ ruby-version: 2.6
34
31
  not-only-test: false
35
32
  env:
36
33
  BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "1.0.0"
3
+ }
data/.rubocop.yml CHANGED
@@ -4,7 +4,7 @@ require:
4
4
 
5
5
  AllCops:
6
6
  NewCops: enable
7
- TargetRubyVersion: 2.4
7
+ TargetRubyVersion: 2.6
8
8
 
9
9
  Layout/DotPosition:
10
10
  EnforcedStyle: trailing
@@ -25,7 +25,7 @@ Metrics/BlockLength:
25
25
  Metrics/ClassLength:
26
26
  Enabled: false
27
27
 
28
- Metrics/LineLength:
28
+ Layout/LineLength:
29
29
  Max: 120
30
30
 
31
31
  Metrics/MethodLength:
@@ -66,3 +66,6 @@ Metrics/AbcSize:
66
66
 
67
67
  Metrics/CyclomaticComplexity:
68
68
  Enabled: false
69
+
70
+ RSpec/MultipleExpectations:
71
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,22 @@
1
+ # Changelog
2
+
3
+ ## [1.0.0](https://github.com/timgaleckas/hierarchical_config/compare/v0.13.2...v1.0.0) (2024-04-26)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * release 1.0.0 ([b6d1d53](https://github.com/timgaleckas/hierarchical_config/commit/b6d1d534072bf60bebacabef5f81d57bcb907eef))
9
+
10
+ ## [0.13.2](https://github.com/timgaleckas/hierarchical_config/compare/v0.13.1...v0.13.2) (2023-08-09)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * allow for all upercase config keys and error on yaml keys that end with ? ([62d3d4b](https://github.com/timgaleckas/hierarchical_config/commit/62d3d4b4c863787dd5b54d601ce0fed01f73ce4f))
16
+
17
+ ## [0.13.1](https://github.com/timgaleckas/hierarchical_config/compare/v0.13.0...v0.13.1) (2023-08-09)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * allow for all upercase config keys and error on yaml keys that end with ? ([62d3d4b](https://github.com/timgaleckas/hierarchical_config/commit/62d3d4b4c863787dd5b54d601ce0fed01f73ce4f))
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hierarchical_config (0.13)
4
+ hierarchical_config (1.0.0)
5
5
  activesupport
6
6
  sorbet-runtime
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (7.0.4.2)
11
+ activesupport (7.0.6)
12
12
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
13
  i18n (>= 1.6, < 2)
14
14
  minitest (>= 5.1)
@@ -20,12 +20,12 @@ GEM
20
20
  concurrent-ruby (1.2.2)
21
21
  debug_inspector (1.1.0)
22
22
  diff-lcs (1.5.0)
23
- i18n (1.12.0)
23
+ i18n (1.14.1)
24
24
  concurrent-ruby (~> 1.0)
25
25
  interception (0.5)
26
26
  json (2.6.3)
27
27
  method_source (1.0.0)
28
- minitest (5.17.0)
28
+ minitest (5.19.0)
29
29
  netrc (0.11.0)
30
30
  parallel (1.22.1)
31
31
  parser (3.2.1.0)
@@ -87,7 +87,9 @@ GEM
87
87
  sorbet (0.5.10689)
88
88
  sorbet-static (= 0.5.10689)
89
89
  sorbet-runtime (0.5.10689)
90
+ sorbet-static (0.5.10689-universal-darwin-21)
90
91
  sorbet-static (0.5.10689-universal-darwin-22)
92
+ sorbet-static (0.5.10689-x86_64-linux)
91
93
  sorbet-static-and-runtime (0.5.10689)
92
94
  sorbet (= 0.5.10689)
93
95
  sorbet-runtime (= 0.5.10689)
@@ -119,7 +121,9 @@ GEM
119
121
  yard (>= 0.9)
120
122
 
121
123
  PLATFORMS
124
+ x86_64-darwin-21
122
125
  x86_64-darwin-22
126
+ x86_64-linux
123
127
 
124
128
  DEPENDENCIES
125
129
  bundler
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.metadata['rubygems_mfa_required'] = 'true'
28
28
 
29
- spec.required_ruby_version = '>= 2.4.6'
29
+ spec.required_ruby_version = '>= 2.6.10'
30
30
  end
@@ -1,5 +1,5 @@
1
1
  # typed: true
2
2
 
3
3
  module HierarchicalConfig
4
- VERSION = '0.13'.freeze
4
+ VERSION = '1.0.0'.freeze
5
5
  end
@@ -3,6 +3,7 @@
3
3
  require 'yaml'
4
4
  require 'erb'
5
5
  require 'set'
6
+ require 'date'
6
7
  require 'sorbet-runtime'
7
8
  require 'active_support'
8
9
  require 'active_support/core_ext/hash/keys'
@@ -24,6 +25,36 @@ module HierarchicalConfig
24
25
  Hash[self.class.props.keys.map{|key| [key, item_to_hash(send(key))]}] # rubocop:disable Style/HashConversion
25
26
  end
26
27
 
28
+ sig do
29
+ type_parameters(:A, :B).
30
+ params(
31
+ blk: T.nilable(
32
+ T.proc.params(name: Symbol, value: T.untyped).
33
+ returns([T.type_parameter(:A), T.type_parameter(:B)]),
34
+ ),
35
+ ).
36
+ returns(
37
+ T.any(
38
+ T::Hash[T.type_parameter(:A), T.type_parameter(:B)],
39
+ T::Hash[Symbol, T.untyped],
40
+ ),
41
+ )
42
+ end
43
+ def to_h(&blk)
44
+ hash = self.class.props.keys.map{|key| [key, send(key)]}
45
+ if blk
46
+ # copied from https://github.com/marcandre/backports/blob/36572870cbdc0cda30e5bab81af8ba390a6cf7c7/lib/backports/2.6.0/hash/to_h.rb#L3C39-L3C39
47
+ # to implement to_h with block for ruby < 2.6.0
48
+ if {n: true}.to_h{[:ok, true]}[:n]
49
+ T.unsafe(hash).map(&blk).to_h
50
+ else
51
+ hash.to_h(&blk)
52
+ end
53
+ else
54
+ hash.to_h
55
+ end
56
+ end
57
+
27
58
  sig{params(key: T.any(String, Symbol)).returns(T.untyped)}
28
59
  def [](key)
29
60
  send(key)
@@ -71,7 +102,7 @@ module HierarchicalConfig
71
102
  def build_types(current_item, name, parent_class)
72
103
  case current_item
73
104
  when Hash
74
- new_type_name = ActiveSupport::Inflector.camelize(ActiveSupport::Inflector.underscore(name))
105
+ new_type_name = inflect_typename(name)
75
106
 
76
107
  return Hash if current_item.keys.to_a.any?{|k| k =~ /^[0-9]/ || k =~ /[- ]/}
77
108
 
@@ -115,7 +146,7 @@ module HierarchicalConfig
115
146
  when Hash
116
147
  return current_item.symbolize_keys if current_item.keys.to_a.any?{|k| k =~ /^[0-9]/ || k =~ /[- ]/}
117
148
 
118
- current_type = parent_class.const_get(ActiveSupport::Inflector.camelize(name))
149
+ current_type = parent_class.const_get(inflect_typename(name))
119
150
  current_type.new(Hash[current_item.map{|key, value| [key.to_sym, build_config(value, key, current_type)]}]) # rubocop:disable Style/HashConversion
120
151
  when Array
121
152
  current_item.each_with_index.map do |item, index|
@@ -177,7 +208,7 @@ module HierarchicalConfig
177
208
  else
178
209
  raise "Unknown preprocessor <#{preprocess_with}>"
179
210
  end
180
- yaml_config = YAML.safe_load(yaml_contents)
211
+ yaml_config = YAML.safe_load(yaml_contents, permitted_classes: [Symbol, Date])
181
212
 
182
213
  ordered_stanza_labels = []
183
214
  ordered_stanza_labels << 'defaults' if yaml_config.key? 'defaults'
@@ -247,5 +278,10 @@ module HierarchicalConfig
247
278
  end
248
279
  hash1
249
280
  end
281
+
282
+ sig{params(name: String).returns(String)}
283
+ def inflect_typename(name)
284
+ ActiveSupport::Inflector.camelize(name)
285
+ end
250
286
  end
251
287
  end
@@ -0,0 +1,14 @@
1
+ {
2
+ "packages": {
3
+ ".": {
4
+ "changelog-path": "CHANGELOG.md",
5
+ "release-type": "ruby",
6
+ "bump-minor-pre-major": true,
7
+ "bump-patch-for-minor-pre-major": true,
8
+ "draft": false,
9
+ "prerelease": false,
10
+ "version-file": "lib/hierarchical_config/version.rb"
11
+ }
12
+ },
13
+ "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
14
+ }
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hierarchical_config
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.13'
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - timgaleckas
8
8
  - tjbladez
9
9
  - jdfrens
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2023-02-28 00:00:00.000000000 Z
13
+ date: 2024-04-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -47,15 +47,16 @@ executables: []
47
47
  extensions: []
48
48
  extra_rdoc_files: []
49
49
  files:
50
+ - ".github/workflows/release.yml"
50
51
  - ".github/workflows/ruby.yml"
51
52
  - ".gitignore"
53
+ - ".release-please-manifest.json"
52
54
  - ".rspec"
53
55
  - ".rubocop.yml"
54
56
  - ".ruby-version"
57
+ - CHANGELOG.md
55
58
  - CODE_OF_CONDUCT.md
56
59
  - Gemfile
57
- - Gemfile.2.4
58
- - Gemfile.2.4.lock
59
60
  - Gemfile.lock
60
61
  - LICENSE.txt
61
62
  - README.md
@@ -65,6 +66,7 @@ files:
65
66
  - hierarchical_config.gemspec
66
67
  - lib/hierarchical_config.rb
67
68
  - lib/hierarchical_config/version.rb
69
+ - release-please-config.json
68
70
  - sorbet/config
69
71
  - sorbet/rbi/annotations/activesupport.rbi
70
72
  - sorbet/rbi/annotations/rainbow.rbi
@@ -116,7 +118,7 @@ licenses:
116
118
  - MIT
117
119
  metadata:
118
120
  rubygems_mfa_required: 'true'
119
- post_install_message:
121
+ post_install_message:
120
122
  rdoc_options: []
121
123
  require_paths:
122
124
  - lib
@@ -124,15 +126,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
126
  requirements:
125
127
  - - ">="
126
128
  - !ruby/object:Gem::Version
127
- version: 2.4.6
129
+ version: 2.6.10
128
130
  required_rubygems_version: !ruby/object:Gem::Requirement
129
131
  requirements:
130
132
  - - ">="
131
133
  - !ruby/object:Gem::Version
132
134
  version: '0'
133
135
  requirements: []
134
- rubygems_version: 3.3.26
135
- signing_key:
136
+ rubygems_version: 3.4.10
137
+ signing_key:
136
138
  specification_version: 4
137
139
  summary: Robust strategy for defining the configuration accross environments, machines,
138
140
  clusters
data/Gemfile.2.4 DELETED
@@ -1,19 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- git_source(:github){|repo_name| "https://github.com/#{repo_name}"}
4
-
5
- # Specify your gem's dependencies in hierarchical_config.gemspec
6
- gemspec
7
-
8
- gem 'bundler'
9
- gem 'pry'
10
- gem 'pry-rescue'
11
- gem 'pry-stack_explorer'
12
- gem 'rake'
13
- gem 'rspec'
14
- gem 'rubocop'
15
- gem 'rubocop-performance'
16
- gem 'rubocop-rake'
17
- gem 'rubocop-rspec'
18
- gem 'sorbet'
19
- gem 'tapioca'
data/Gemfile.2.4.lock DELETED
@@ -1,117 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- hierarchical_config (0.11)
5
- activesupport
6
- sorbet-runtime
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- activesupport (3.1.12)
12
- multi_json (~> 1.0)
13
- ast (2.4.2)
14
- binding_of_caller (0.8.0)
15
- debug_inspector (>= 0.0.1)
16
- coderay (1.1.3)
17
- commander (4.6.0)
18
- highline (~> 2.0.0)
19
- debug_inspector (1.1.0)
20
- diff-lcs (1.5.0)
21
- highline (2.0.3)
22
- interception (0.5)
23
- method_source (1.0.0)
24
- multi_json (1.15.0)
25
- parallel (1.20.1)
26
- parlour (8.1.0)
27
- commander (~> 4.5)
28
- parser
29
- rainbow (~> 3.0)
30
- sorbet-runtime (>= 0.5)
31
- parser (3.2.1.0)
32
- ast (~> 2.4.1)
33
- pry (0.14.2)
34
- coderay (~> 1.1)
35
- method_source (~> 1.0)
36
- pry-rescue (1.5.2)
37
- interception (>= 0.5)
38
- pry (>= 0.12.0)
39
- pry-stack_explorer (0.4.12)
40
- binding_of_caller (~> 0.7)
41
- pry (~> 0.13)
42
- rainbow (3.1.1)
43
- rake (13.0.6)
44
- regexp_parser (2.7.0)
45
- rexml (3.2.5)
46
- rspec (3.12.0)
47
- rspec-core (~> 3.12.0)
48
- rspec-expectations (~> 3.12.0)
49
- rspec-mocks (~> 3.12.0)
50
- rspec-core (3.12.1)
51
- rspec-support (~> 3.12.0)
52
- rspec-expectations (3.12.2)
53
- diff-lcs (>= 1.2.0, < 2.0)
54
- rspec-support (~> 3.12.0)
55
- rspec-mocks (3.12.3)
56
- diff-lcs (>= 1.2.0, < 2.0)
57
- rspec-support (~> 3.12.0)
58
- rspec-support (3.12.0)
59
- rubocop (1.12.1)
60
- parallel (~> 1.10)
61
- parser (>= 3.0.0.0)
62
- rainbow (>= 2.2.2, < 4.0)
63
- regexp_parser (>= 1.8, < 3.0)
64
- rexml
65
- rubocop-ast (>= 1.2.0, < 2.0)
66
- ruby-progressbar (~> 1.7)
67
- unicode-display_width (>= 1.4.0, < 3.0)
68
- rubocop-ast (1.4.1)
69
- parser (>= 2.7.1.5)
70
- rubocop-performance (1.10.2)
71
- rubocop (>= 0.90.0, < 2.0)
72
- rubocop-ast (>= 0.4.0)
73
- rubocop-rake (0.5.1)
74
- rubocop
75
- rubocop-rspec (2.2.0)
76
- rubocop (~> 1.0)
77
- rubocop-ast (>= 1.1.0)
78
- ruby-progressbar (1.11.0)
79
- sorbet (0.5.10461)
80
- sorbet-static (= 0.5.10461)
81
- sorbet-runtime (0.5.10461)
82
- sorbet-static (0.5.10461-universal-darwin-22)
83
- spoom (1.1.11)
84
- sorbet (>= 0.5.9204)
85
- sorbet-runtime (>= 0.5.9204)
86
- thor (>= 0.19.2)
87
- tapioca (0.4.27)
88
- bundler (>= 1.17.3)
89
- parlour (>= 2.1.0)
90
- pry (>= 0.12.2)
91
- sorbet-runtime
92
- sorbet-static (>= 0.4.4471)
93
- spoom
94
- thor (>= 0.19.2)
95
- thor (1.2.1)
96
- unicode-display_width (2.4.2)
97
-
98
- PLATFORMS
99
- x86_64-darwin-22
100
-
101
- DEPENDENCIES
102
- bundler
103
- hierarchical_config!
104
- pry
105
- pry-rescue
106
- pry-stack_explorer
107
- rake
108
- rspec
109
- rubocop
110
- rubocop-performance
111
- rubocop-rake
112
- rubocop-rspec
113
- sorbet
114
- tapioca
115
-
116
- BUNDLED WITH
117
- 2.3.26