confg 3.0.0 → 3.0.1

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: a22c813a8d81e3381f37ac6a2e98863c363091fc2cca5e35d8d4b81dae51d9d7
4
- data.tar.gz: 03b2fb1a7415571f1062c0a493fa4b1bd1fa130692ee59b0e926dab1641adf4f
3
+ metadata.gz: 2ffa65a341a5ea7d93390edf845981fd50c0df586c6e28b7c8487b035706092a
4
+ data.tar.gz: c5bba8919704165a458b2509a75f83ef10b1c5eb9056a39aa53368e7f6a19a2a
5
5
  SHA512:
6
- metadata.gz: 3da4ee7440ff963e2d760e7eb342f83bef36acab2bfd286a43b4e2645afb0947f19e34c2f0b0e7d6ab6013711c00cecc99132b29468e2bfeca7b93c5ad261c7d
7
- data.tar.gz: 9b5962463d289b4872911e3c7cbad774f0d127613bc06780b6fb3102c2751f89c3bf418bb8bfeab2e9add483c8edd25c27006300361d51c5e12cd73bda18fbb5
6
+ metadata.gz: f15b35166baaaf7270a755a6770839c774cb581052004aac9b4f85a1d0e333a52eec9c0a8ea0d577d96bf8028f1c1a63106c0a7cf21eb47016787d5b7d64f53c
7
+ data.tar.gz: 9b28f027b6aab53c8ff152faafc932ad01767fe64f5de95ec84839956d54e393cf743b92171a0120f36d36f01611b2dc0dc4cb7cd3def5fb68414687d3bfcff2
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.0.6
@@ -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.send :safe_load, erb_content, aliases: true # due to shared sections
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Confg
4
4
 
5
- VERSION = "3.0.0"
5
+ VERSION = "3.0.1"
6
6
 
7
7
  end
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)
@@ -0,0 +1,10 @@
1
+ shared: &shared
2
+ foo: :foo
3
+
4
+ production:
5
+ <<: *shared
6
+ env_setting: :setting_prod
7
+
8
+ test:
9
+ <<: *shared
10
+ env_setting: :setting_test
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.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-12 00:00:00.000000000 Z
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