confg 3.0.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/.ruby-version +1 -0
- data/lib/confg/configuration.rb +4 -4
- data/lib/confg/version.rb +1 -1
- data/test/confg_test.rb +15 -0
- data/test/example_with_symbols.yml +10 -0
- metadata +5 -2
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/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.0.6
|
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)
|
data/lib/confg/version.rb
CHANGED
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,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Nelson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -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,6 +85,7 @@ 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: []
|
@@ -110,4 +112,5 @@ 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
|