confg 3.2.0 → 3.3.0

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: 1a8d68f7467992b67e6498153d220d203432287054549f768546f70127e6923f
4
+ data.tar.gz: add43866b97a32d137455b63a79778669310fda072ecb79d6f22937fef0b17c6
5
5
  SHA512:
6
- metadata.gz: dfebb4875f179c75bac7cffe6f0793b2a102276736d50dee5cd9af18141f2ff78ad61c88441e2c4365330fde1c86aa1b51a08e65eee7088c19821d85f187167e
7
- data.tar.gz: 9000af2c11b86868d862ea1d0a9c016e28b7f55387ff64348349e3f033170bf0b6f866d2adb48f4c2af4a30c0d071c14bc204ea0626c88416ac8fa276fa5b7be
6
+ metadata.gz: 6203dc566bdfa5bc6c4acc16a8e610384f225d7aa221f26e6f40e71824922b78aa78d9335bbea1755e0bf88831f2b29eb6feca7f96c64a0290e82afe74f36261
7
+ data.tar.gz: f47490f355212bdb0d62cf24440405377f52f99f417d918ca795abdaa408264a87d96d74ee6c01eafade40532e93fd330568d2329b3b3be9fd57311a26aac6e7
data/confg.gemspec CHANGED
@@ -15,14 +15,14 @@ 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
28
  spec.add_development_dependency "minitest", "~> 5.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
data/lib/confg/version.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Confg
4
4
 
5
5
  MAJOR = 3
6
- MINOR = 2
6
+ MINOR = 3
7
7
  PATCH = 0
8
8
  PRERELEASE = nil
9
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Nelson
@@ -72,13 +72,6 @@ executables: []
72
72
  extensions: []
73
73
  extra_rdoc_files: []
74
74
  files:
75
- - ".github/dependabot.yml"
76
- - ".github/workflows/build.yml"
77
- - ".gitignore"
78
- - ".ruby-version"
79
- - Gemfile
80
- - README.md
81
- - Rakefile
82
75
  - confg.gemspec
83
76
  - lib/confg.rb
84
77
  - lib/confg/configuration.rb
@@ -87,7 +80,9 @@ files:
87
80
  homepage: https://github.com/guideline-tech/confg
88
81
  licenses:
89
82
  - MIT
90
- metadata: {}
83
+ metadata:
84
+ allowed_push_host: https://rubygems.org
85
+ rubygems_mfa_required: 'true'
91
86
  rdoc_options: []
92
87
  require_paths:
93
88
  - lib
@@ -102,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
97
  - !ruby/object:Gem::Version
103
98
  version: '0'
104
99
  requirements: []
105
- rubygems_version: 3.6.7
100
+ rubygems_version: 3.7.2
106
101
  specification_version: 4
107
102
  summary: Sets shared variables for applications
108
103
  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