secret_config 0.10.4 → 1.0.0

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: 1c448ac94d8b53e13027c3b4df10eaea31720ee069f50c3fa6f7feae5743c8b5
4
- data.tar.gz: c20fb32c6915115055e2cb651efcac8cfc69d1da88c957f9cf539486174e8d14
3
+ metadata.gz: f6aad3d7382cdcfce816fb2f045f134cfd8235df19ff66eb35e50030141cd864
4
+ data.tar.gz: c8538b3208265fa99ea8d6cd26b1e39da4ea26ed8919af56c3e2658811690b12
5
5
  SHA512:
6
- metadata.gz: 12605771be0a30e288d9a4155259207cebf68865cc62b7407bd2174e6303cae095e3ad5b9e50bf02cd7fa9bcce0a3a80454bc2af9629b38316a85e069fa8e7e3
7
- data.tar.gz: a002a780853f22cc9919da018f7fd54678121f83e1663cf767e150f4cefcf54c6b1d96c5a15601ee688c8c2d062ae9883edafa5070d5faefd234b6f8d913ee2d
6
+ metadata.gz: 40c6e537b1098a0f977c73ffce4ddada21dd415053789861a4ab5489118cd86b912d6a4444250e7b5eefe5997079b36a0f12d127e743572958fe816afaf85dce
7
+ data.tar.gz: 59423883acb034d91392d79e512513a9d058e5bff590fe16b8e9385c76f6371bfe491483f2c273d9f70efc73abaae6e06aa177be94a87b37a48db85de9ab9b15
@@ -31,11 +31,17 @@ module SecretConfig
31
31
  private
32
32
 
33
33
  def fetch_path(path)
34
- config = YAML.load(ERB.new(::File.new(file_name).read).result)
34
+ config = load_yaml(ERB.new(::File.new(file_name).read).result)
35
35
 
36
36
  paths = path.sub(%r{\A/*}, "").sub(%r{/*\Z}, "").split("/")
37
37
  config.dig(*paths)
38
38
  end
39
+
40
+ def load_yaml(src)
41
+ return YAML.safe_load(src, permitted_classes: [Symbol], aliases: true) if Psych::VERSION > "4.0"
42
+
43
+ YAML.load(src)
44
+ end
39
45
  end
40
46
  end
41
47
  end
@@ -154,7 +154,7 @@ module SecretConfig
154
154
  def convert_type(type, value)
155
155
  case type
156
156
  when :string
157
- value.to_s
157
+ value.nil? ? nil : value.to_s
158
158
  when :integer
159
159
  value.to_i
160
160
  when :float
@@ -1,3 +1,3 @@
1
1
  module SecretConfig
2
- VERSION = "0.10.4".freeze
2
+ VERSION = "1.0.0".freeze
3
3
  end
@@ -47,6 +47,14 @@ class SecretConfigTest < Minitest::Test
47
47
  assert_equal "secret_config_test", SecretConfig.fetch("mysql/database")
48
48
  end
49
49
 
50
+ it "fetches with default" do
51
+ assert_equal "default", SecretConfig.fetch("mysql/unknown", default: "default")
52
+ end
53
+
54
+ it "fetches with default of nil" do
55
+ assert_nil SecretConfig.fetch("mysql/unknown", default: nil)
56
+ end
57
+
50
58
  it "can be overridden by an environment variable" do
51
59
  ENV["MYSQL_DATABASE"] = "other"
52
60
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: secret_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reid Morrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-06 00:00:00.000000000 Z
11
+ date: 2022-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  requirements: []
80
- rubygems_version: 3.2.22
80
+ rubygems_version: 3.3.7
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: Centralized Configuration and Secrets Management for Ruby and Rails applications.