confg 2.1.0 → 3.0.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 +4 -4
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/confg.gemspec +2 -2
- data/lib/confg/configuration.rb +6 -6
- data/lib/confg/version.rb +1 -1
- data/lib/confg.rb +3 -3
- data/test/confg_test.rb +15 -0
- data/test/example_with_symbols.yml +10 -0
- metadata +17 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ffa65a341a5ea7d93390edf845981fd50c0df586c6e28b7c8487b035706092a
|
4
|
+
data.tar.gz: c5bba8919704165a458b2509a75f83ef10b1c5eb9056a39aa53368e7f6a19a2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f15b35166baaaf7270a755a6770839c774cb581052004aac9b4f85a1d0e333a52eec9c0a8ea0d577d96bf8028f1c1a63106c0a7cf21eb47016787d5b7d64f53c
|
7
|
+
data.tar.gz: 9b28f027b6aab53c8ff152faafc932ad01767fe64f5de95ec84839956d54e393cf743b92171a0120f36d36f01611b2dc0dc4cb7cd3def5fb68414687d3bfcff2
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.0.6
|
data/confg.gemspec
CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler"
|
21
|
+
spec.add_development_dependency "bundler"
|
22
22
|
spec.add_development_dependency "byebug"
|
23
23
|
spec.add_development_dependency "minitest", "~> 5.0"
|
24
|
-
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "rake"
|
25
25
|
end
|
data/lib/confg/configuration.rb
CHANGED
@@ -71,12 +71,12 @@ module Confg
|
|
71
71
|
set(key, inner)
|
72
72
|
end
|
73
73
|
|
74
|
-
def load_key(key)
|
74
|
+
def load_key(key,yaml_loader_options = {})
|
75
75
|
# loads yaml file with given key
|
76
|
-
load_yaml(key, key: key)
|
76
|
+
load_yaml(key, yaml_loader_options, key: key)
|
77
77
|
end
|
78
78
|
|
79
|
-
def load_yaml(path, key: nil, ignore_env: false)
|
79
|
+
def load_yaml(path, yaml_loader_options = {}, key: nil, ignore_env: false)
|
80
80
|
found_path = find_config_yaml(path)
|
81
81
|
|
82
82
|
raise ArgumentError, "#{path} could not be found" if found_path.nil?
|
@@ -84,7 +84,7 @@ module Confg
|
|
84
84
|
ctxt = ::Confg::ErbContext.new
|
85
85
|
raw_content = ::File.read(found_path)
|
86
86
|
erb_content = ctxt.evaluate(raw_content)
|
87
|
-
yaml_content = ::YAML.
|
87
|
+
yaml_content = ::YAML.safe_load(erb_content, **yaml_loader_options.merge(aliases: true)) # due to shared sections
|
88
88
|
|
89
89
|
unless ignore_env
|
90
90
|
yaml_content = yaml_content[confg_env] if confg_env && yaml_content.is_a?(::Hash) && yaml_content.key?(confg_env)
|
@@ -104,13 +104,13 @@ module Confg
|
|
104
104
|
end
|
105
105
|
alias load_yml load_yaml
|
106
106
|
|
107
|
-
def method_missing(key, *args, &block)
|
107
|
+
def method_missing(key, *args, **kwargs, &block)
|
108
108
|
key = key.to_s
|
109
109
|
return set(key[0...-1], args[0]) if key.end_with?("=")
|
110
110
|
return fetch(key) if key?(key)
|
111
111
|
|
112
112
|
begin
|
113
|
-
confg_data.send(key, *args, &block)
|
113
|
+
confg_data.send(key, *args, **kwargs, &block)
|
114
114
|
rescue NoMethodError => e
|
115
115
|
raise KeyError, "Unrecognized key `#{key}`", e.backtrace
|
116
116
|
end
|
data/lib/confg/version.rb
CHANGED
data/lib/confg.rb
CHANGED
@@ -39,11 +39,11 @@ module Confg
|
|
39
39
|
end
|
40
40
|
alias configure config
|
41
41
|
|
42
|
-
def method_missing(method_name,
|
43
|
-
config.send(method_name,
|
42
|
+
def method_missing(method_name, ...)
|
43
|
+
config.send(method_name, ...)
|
44
44
|
end
|
45
45
|
|
46
|
-
def respond_to_missing?(
|
46
|
+
def respond_to_missing?(...)
|
47
47
|
true
|
48
48
|
end
|
49
49
|
|
data/test/confg_test.rb
CHANGED
@@ -65,6 +65,21 @@ class ConfgTest < Minitest::Test
|
|
65
65
|
}, config.to_h)
|
66
66
|
end
|
67
67
|
|
68
|
+
def test_a_yml_file_doesnt_load_with_additional_permitted_classes
|
69
|
+
assert_raises "Psych::DisallowedClass: Tried to load unspecified class: Symbol" do
|
70
|
+
config.load_yaml("example_with_symbols.yml", ignore_env: true)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_a_yml_file_can_be_loaded_with_additional_permitted_classes
|
75
|
+
config.load_yaml("example_with_symbols.yml", { permitted_classes: [Symbol] }, ignore_env: true)
|
76
|
+
assert_equal({
|
77
|
+
"shared" => { "foo" => :foo },
|
78
|
+
"production" => { "env_setting" => :setting_prod, "foo" => :foo },
|
79
|
+
"test" => { "env_setting" => :setting_test, "foo" => :foo },
|
80
|
+
}, config.to_h)
|
81
|
+
end
|
82
|
+
|
68
83
|
def test_top_level_configs_are_cached_in_root_namespace
|
69
84
|
::Confg.send :reset!
|
70
85
|
assert_equal({}, ::Confg.cache)
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Nelson
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: byebug
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
description: Config the pipes
|
70
70
|
email:
|
71
71
|
- mike@mnelson.io
|
@@ -74,6 +74,7 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
|
+
- ".ruby-version"
|
77
78
|
- Gemfile
|
78
79
|
- README.md
|
79
80
|
- Rakefile
|
@@ -84,11 +85,12 @@ files:
|
|
84
85
|
- lib/confg/version.rb
|
85
86
|
- test/confg_test.rb
|
86
87
|
- test/example.yml
|
88
|
+
- test/example_with_symbols.yml
|
87
89
|
- test/test_helper.rb
|
88
90
|
homepage: ''
|
89
91
|
licenses: []
|
90
92
|
metadata: {}
|
91
|
-
post_install_message:
|
93
|
+
post_install_message:
|
92
94
|
rdoc_options: []
|
93
95
|
require_paths:
|
94
96
|
- lib
|
@@ -103,11 +105,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
105
|
- !ruby/object:Gem::Version
|
104
106
|
version: '0'
|
105
107
|
requirements: []
|
106
|
-
rubygems_version: 3.
|
107
|
-
signing_key:
|
108
|
+
rubygems_version: 3.2.33
|
109
|
+
signing_key:
|
108
110
|
specification_version: 4
|
109
111
|
summary: Sets shared variables for applications
|
110
112
|
test_files:
|
111
113
|
- test/confg_test.rb
|
112
114
|
- test/example.yml
|
115
|
+
- test/example_with_symbols.yml
|
113
116
|
- test/test_helper.rb
|