confg 3.2.0 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5414d73decd949b0890219558f5bf68dfa0508330dc23c01359f10d4b3b5d79
4
- data.tar.gz: 1aa9a65e7565c4cff14621279548500db41205e345152eb2ef0aa9a5f3783137
3
+ metadata.gz: d595c5adad2611cc0c95c536ef1fd3634e5a3e65a8af05f9850c8e1d48602f65
4
+ data.tar.gz: 9c5df61832c56848806b852f13b4caf66224789cebfc96b5985cc01cf7c147db
5
5
  SHA512:
6
- metadata.gz: dfebb4875f179c75bac7cffe6f0793b2a102276736d50dee5cd9af18141f2ff78ad61c88441e2c4365330fde1c86aa1b51a08e65eee7088c19821d85f187167e
7
- data.tar.gz: 9000af2c11b86868d862ea1d0a9c016e28b7f55387ff64348349e3f033170bf0b6f866d2adb48f4c2af4a30c0d071c14bc204ea0626c88416ac8fa276fa5b7be
6
+ metadata.gz: cdb93c72fef940c0250e090212877195bb21e73df498bd20bf563d0bb0678c92aa2e4fbabb2e5ee0802d46bd04b458a535263cc1fe01c0e224ca336ae6c8a066
7
+ data.tar.gz: 83a4972226d74b1eaa5ea195da1f064b0263ca5e6b87ac9d3a3319a93713a96fbe9963b48b1484e4b9670ea3bd6e178dc4abb42ec12a2339aeffa5fe9d75c76b
data/confg.gemspec CHANGED
@@ -15,17 +15,17 @@ Gem::Specification.new do |spec|
15
15
  spec.license = "MIT"
16
16
 
17
17
  # Specify which files should be added to the gem when it is released.
18
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
20
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test)/}) }
21
- end
18
+ spec.files = Dir["lib/**/*"] + Dir["*.gemspec"]
19
+
22
20
  spec.executables = spec.files.grep(%r{^bin/}).map { |f| File.basename(f) }
23
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
21
  spec.require_paths = ["lib"]
25
22
 
23
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
24
+ spec.metadata["rubygems_mfa_required"] = "true"
25
+
26
26
  spec.add_development_dependency "bundler"
27
27
  spec.add_development_dependency "byebug"
28
- spec.add_development_dependency "minitest", "~> 5.0"
28
+ spec.add_development_dependency "minitest", "~> 6.0"
29
29
  spec.add_development_dependency "rake"
30
30
 
31
31
  spec.required_ruby_version = ">= 3.2.0"
@@ -32,6 +32,25 @@ module Confg
32
32
  end
33
33
  alias merge! merge
34
34
 
35
+ def load_env(prefix: "CONFG_", separator: "__")
36
+ overrides = {}
37
+
38
+ ENV.each do |key, value|
39
+ next unless key.start_with?(prefix)
40
+
41
+ segments = key.delete_prefix(prefix).downcase.split(separator)
42
+
43
+ # Build nested hash: ["database", "host"] => { "database" => { "host" => value } }
44
+ current = overrides
45
+ segments[0...-1].each do |segment|
46
+ current = (current[segment] ||= {})
47
+ end
48
+ current[segments.last] = value
49
+ end
50
+
51
+ merge(overrides)
52
+ end
53
+
35
54
  def to_h
36
55
  confg_data.transform_values do |v|
37
56
  v.is_a?(self.class) ? v.to_h : v
@@ -109,10 +128,10 @@ module Confg
109
128
  return set(key[0...-1], args[0]) if key.end_with?("=")
110
129
  return fetch(key) if key?(key)
111
130
 
112
- begin
131
+ if confg_data.respond_to?(key)
113
132
  confg_data.send(key, *args, **kwargs, &block)
114
- rescue NoMethodError => e
115
- raise KeyError, "Unrecognized key `#{key}`", e.backtrace
133
+ else
134
+ raise KeyError, "Unrecognized key `#{key}`"
116
135
  end
117
136
  end
118
137
 
data/lib/confg/version.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  module Confg
4
4
 
5
5
  MAJOR = 3
6
- MINOR = 2
7
- PATCH = 0
6
+ MINOR = 3
7
+ PATCH = 1
8
8
  PRERELEASE = nil
9
9
 
10
10
  VERSION = [MAJOR, MINOR, PATCH, PRERELEASE].compact.join(".")
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: confg
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Nelson
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-03-06 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: bundler
@@ -43,14 +44,14 @@ dependencies:
43
44
  requirements:
44
45
  - - "~>"
45
46
  - !ruby/object:Gem::Version
46
- version: '5.0'
47
+ version: '6.0'
47
48
  type: :development
48
49
  prerelease: false
49
50
  version_requirements: !ruby/object:Gem::Requirement
50
51
  requirements:
51
52
  - - "~>"
52
53
  - !ruby/object:Gem::Version
53
- version: '5.0'
54
+ version: '6.0'
54
55
  - !ruby/object:Gem::Dependency
55
56
  name: rake
56
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,13 +73,6 @@ executables: []
72
73
  extensions: []
73
74
  extra_rdoc_files: []
74
75
  files:
75
- - ".github/dependabot.yml"
76
- - ".github/workflows/build.yml"
77
- - ".gitignore"
78
- - ".ruby-version"
79
- - Gemfile
80
- - README.md
81
- - Rakefile
82
76
  - confg.gemspec
83
77
  - lib/confg.rb
84
78
  - lib/confg/configuration.rb
@@ -87,7 +81,10 @@ files:
87
81
  homepage: https://github.com/guideline-tech/confg
88
82
  licenses:
89
83
  - MIT
90
- metadata: {}
84
+ metadata:
85
+ allowed_push_host: https://rubygems.org
86
+ rubygems_mfa_required: 'true'
87
+ post_install_message:
91
88
  rdoc_options: []
92
89
  require_paths:
93
90
  - lib
@@ -102,7 +99,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
99
  - !ruby/object:Gem::Version
103
100
  version: '0'
104
101
  requirements: []
105
- rubygems_version: 3.6.7
102
+ rubygems_version: 3.5.22
103
+ signing_key:
106
104
  specification_version: 4
107
105
  summary: Sets shared variables for applications
108
106
  test_files: []
@@ -1,24 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: "github-actions"
4
- directory: "/"
5
- open-pull-requests-limit: 20
6
- schedule:
7
- interval: "daily"
8
- time: "09:00"
9
- timezone: "America/New_York"
10
- commit-message:
11
- prefix: "[github-actions] "
12
- - package-ecosystem: "bundler"
13
- directory: "/"
14
- schedule:
15
- interval: "daily"
16
- time: "08:30"
17
- timezone: "America/New_York"
18
- versioning-strategy: increase
19
- open-pull-requests-limit: 20
20
- insecure-external-code-execution: deny
21
- allow:
22
- - dependency-type: "all"
23
- commit-message:
24
- prefix: "[bundler] "
@@ -1,22 +0,0 @@
1
- name: build
2
- on:
3
- pull_request:
4
- push:
5
- branches:
6
- - main
7
- jobs:
8
- build:
9
- runs-on: ubuntu-latest
10
- strategy:
11
- fail-fast: false
12
- matrix:
13
- ruby-version: [3.2, 3.3, 3.4]
14
- steps:
15
- - uses: actions/checkout@v4
16
- with:
17
- show-progress: 'false'
18
- - uses: ruby/setup-ruby@v1
19
- with:
20
- ruby-version: ${{ matrix.ruby-version }}
21
- bundler-cache: true # runs `bundle install` and caches installed gems automatically
22
- - run: bundle exec rake
data/.gitignore DELETED
@@ -1,17 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /Gemfile.lock
9
- /tmp/
10
- *.bundle
11
- *.so
12
- *.o
13
- *.a
14
- mkmf.log
15
- *.gem
16
- .byebug_history
17
- /vendor/
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.3.7
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in config.gemspec
4
- gemspec
data/README.md DELETED
@@ -1,54 +0,0 @@
1
- # Confg
2
-
3
- Provides a utility for loading and managing configurations for your ruby project.
4
-
5
- ## Usage
6
-
7
- Set specific keys:
8
-
9
- Confg.configure do |c|
10
- c.foo_setting = 100
11
- c.bar_setting = "yes"
12
- end
13
-
14
- Supports nesting:
15
-
16
- Confg.configure do |c|
17
- c.api_keys do |a|
18
- a.google = 'xyz'
19
- a.mixpanel = 'abc'
20
- end
21
- end
22
-
23
- Load a yaml file:
24
-
25
- Confg.configure do |c|
26
- c.load_yaml "/path/to/file.yml"
27
- end
28
-
29
- Yaml files can be namespaced by environment and contain ERB.
30
-
31
- ---
32
- development:
33
- thing: <%= ENV["THING"] %>
34
- staging:
35
- thing: 'set value'
36
-
37
- Use the values:
38
-
39
- Confg.foo_setting
40
- #=> 100
41
-
42
- Confg.api_keys
43
- #=> #<Confg::Configuration { "google" => "xyz", "mixpanel" => "abc" }>
44
-
45
- Confg.api_keys.google # => "xyz"'
46
-
47
- Confg.api_keys.to_h
48
- #=> { "google" => "xyz", "mixpanel" => "abc" }
49
-
50
- Confg.missing_key
51
- #=> raises KeyError
52
-
53
- Conf[:missing_key]
54
- #=> nil
data/Rakefile DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rake/testtask"
5
-
6
- Rake::TestTask.new(:test) do |t|
7
- t.libs << "test"
8
- t.libs << "lib"
9
- t.test_files = FileList["test/**/*_test.rb"]
10
- end
11
-
12
- task default: :test