config 3.0.0 → 3.1.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: a9553d786b6f2a87d956e85494f9f8fd083e42076989e7c8217b84f72b1d6469
4
- data.tar.gz: 592b1002dd18e793f444c2b4d00220c4cbbaf2f1e850d33c0d6c5bc5c41ae236
3
+ metadata.gz: ee641c05cf97c8e76b7076ba7b9c66e490999d307cf4be1b6c404f5cabfc38a5
4
+ data.tar.gz: 9c9b4f47ca0259234082bd4339df446370e0f8cda3be6e8dfb25aff347c2ac75
5
5
  SHA512:
6
- metadata.gz: 80c5e1c7de910d8f7592b0bf2d1ad322dbf8aa6565617ca1f5d0bdede78316073aa5afb5bf6e7cb33ce42bace7770f4cb8f8a86d4fd13a31fc0e900e58c6ae9c
7
- data.tar.gz: 8fe4ecdb8069e910c36f68cb3a55863182797539638be36f7be622057174a45f4605427aaa0f145fd399a518131310059408812e9ff5dd391a1c7691b45624a7
6
+ metadata.gz: 374734550ff18a367d2932d10601dda32cfd29640b7ce7e647c00b11b5f3dbd85afbcb57d9e3dd369cbd5d9b1c44e66af4ed7b4c5bc438136ed9474d9797741f
7
+ data.tar.gz: '093ca60e0208e03bd6b4cf624084c2eeead073b531c702196d325aff5f9d48bfaf1da326d3725bb7d79702ff66a6332942e478a553e14b02dea54cc6a491619a'
data/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@
4
4
 
5
5
  ...
6
6
 
7
+ ## 3.1.0
8
+
9
+ ### New features
10
+
11
+ * Evaluating ERB in YAML files can now be disabled with `Config.evaluate_erb_in_yaml = false`. The default value for this option is `true` for backwards-compatibility. ([#303](https://github.com/rubyconfig/config/pull/303))
12
+
7
13
  ## 3.0.0
8
14
 
9
15
  ### BREAKING CHANGES
@@ -17,7 +23,7 @@
17
23
 
18
24
  ### Changes
19
25
 
20
- * Add `Config::Sources::EnvSource` for loading settings from flat `Hash`es with `String` keys and `String` values ([#299](https://github.com/railsconfig/config/pull/299))
26
+ * Add `Config::Sources::EnvSource` for loading settings from flat `Hash`es with `String` keys and `String` values, such as from AWS SecretsManager ([#299](https://github.com/railsconfig/config/pull/299))
21
27
 
22
28
  ## 2.2.3
23
29
 
data/README.md CHANGED
@@ -205,7 +205,9 @@ You may pass a hash to `prepend_source!` as well.
205
205
 
206
206
  ## Embedded Ruby (ERB)
207
207
 
208
- Embedded Ruby is allowed in the configuration files. Consider the two following config files.
208
+ Embedded Ruby is allowed in the YAML configuration files. ERB will be evaluated at load time by default, and when the `evaluate_erb_in_yaml` configuration is set to `true`.
209
+
210
+ Consider the two following config files.
209
211
 
210
212
  * ```#{Rails.root}/config/settings.yml```
211
213
 
@@ -266,6 +268,7 @@ After installing `Config` in Rails, you will find automatically generated file t
266
268
  ### General
267
269
 
268
270
  * `const_name` - name of the object holing you settings. Default: `'Settings'`
271
+ * `evaluate_erb_in_yaml` - evaluate ERB in YAML config files. Set to false if the config file contains ERB that should not be evaluated at load time. Default: `true`
269
272
 
270
273
  ### Merge customization
271
274
 
data/lib/config.rb CHANGED
@@ -24,7 +24,8 @@ module Config
24
24
  merge_nil_values: true,
25
25
  overwrite_arrays: true,
26
26
  merge_hash_arrays: false,
27
- validation_contract: nil
27
+ validation_contract: nil,
28
+ evaluate_erb_in_yaml: true
28
29
  )
29
30
 
30
31
  def self.setup
@@ -5,14 +5,20 @@ module Config
5
5
  module Sources
6
6
  class YAMLSource
7
7
  attr_accessor :path
8
+ attr_reader :evaluate_erb
8
9
 
9
- def initialize(path)
10
+ def initialize(path, evaluate_erb: Config.evaluate_erb_in_yaml)
10
11
  @path = path.to_s
12
+ @evaluate_erb = !!evaluate_erb
11
13
  end
12
14
 
13
15
  # returns a config hash from the YML file
14
16
  def load
15
- result = YAML.load(ERB.new(IO.read(@path)).result) if @path and File.exist?(@path)
17
+ if @path and File.exist?(@path)
18
+ file_contents = IO.read(@path)
19
+ file_contents = ERB.new(file_contents).result if evaluate_erb
20
+ result = YAML.load(file_contents)
21
+ end
16
22
 
17
23
  result || {}
18
24
 
@@ -1,3 +1,3 @@
1
1
  module Config
2
- VERSION = '3.0.0'.freeze
2
+ VERSION = '3.1.0'.freeze
3
3
  end
@@ -52,4 +52,7 @@ Config.setup do |config|
52
52
  # required(:email).filled(format?: EMAIL_REGEX)
53
53
  # end
54
54
 
55
+ # Evaluate ERB in YAML config files at load time.
56
+ #
57
+ # config.evaluate_erb_yaml = true
55
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Kuczynski
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-02-24 00:00:00.000000000 Z
13
+ date: 2021-04-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: deep_merge