config 5.3.0 → 5.5.0
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/CHANGELOG.md +18 -1
- data/README.md +3 -1
- data/config.gemspec +1 -4
- data/lib/config/integrations/rails/railtie.rb +1 -1
- data/lib/config/sources/env_source.rb +23 -2
- data/lib/config/version.rb +1 -1
- data/lib/config.rb +3 -1
- data/lib/generators/config/templates/config.rb +5 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8c55570ed35c36e29bb0e7fd02b4aa449fb1edf17b5c43739526d33c68bc67b
|
4
|
+
data.tar.gz: 0cdf118110c9761a24944e2cb810123ec26242efc820e8b47545ff2cc6219f86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f698950933d9c7830b10d6849c8b249df8ea63ef2b8ddc6111c5dfc5f47f7173ef3049744cbbf30c95660b5b3caa98ababd61f269f1bc74be7227a15be244797
|
7
|
+
data.tar.gz: 6078e1863615b7115af836136dc3759cc62815a85ea23a3a8f9a9ff671f2246b5059bcec0549ed61398c863ea834d861741890c55fac5e31f091d3c3ab438af5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 5.5.0
|
4
|
+
|
5
|
+
### New features
|
6
|
+
|
7
|
+
* Allow arrays to be passed through env variables ([#354](https://github.com/rubyconfig/config/pull/354))
|
8
|
+
|
9
|
+
### Documentation
|
10
|
+
|
11
|
+
* Use funding_url rather than post_install_message ([#360](https://github.com/rubyconfig/config/pull/360))
|
12
|
+
* Fix typos in the tests and documentation ([#359](https://github.com/rubyconfig/config/pull/359))
|
13
|
+
|
14
|
+
## 5.4.0
|
15
|
+
|
16
|
+
### New features
|
17
|
+
|
18
|
+
* Add configuration option `environment` to override the use of `Rails.env` ([#356](https://github.com/rubyconfig/config/pull/356))
|
19
|
+
|
3
20
|
## 5.3.0
|
4
21
|
|
5
22
|
* Remove `dry-validation` from dependencies ([#333](https://github.com/rubyconfig/config/pull/333))
|
@@ -50,7 +67,7 @@
|
|
50
67
|
* Rails versions `< 5.2` are no longer supported ([#316](https://github.com/rubyconfig/config/pull/316))
|
51
68
|
* Ruby versions `< 2.6` are no longer supported ([#316](https://github.com/rubyconfig/config/pull/316))
|
52
69
|
* Support `HashSource` and `EnvSource` instances in `Config.load_files` and `Config.load_and_set_settings`. ([#315](https://github.com/rubyconfig/config/pull/315)). There are a few subtle breaking changes:
|
53
|
-
* Previously, `Config.load_files` (called from `Config.load_and_set_settings`) would call `.to_s` on each of its arguments. Now, this responsibility is
|
70
|
+
* Previously, `Config.load_files` (called from `Config.load_and_set_settings`) would call `.to_s` on each of its arguments. Now, this responsibility is deferred to YAMLSource. In effect, if your application passes String or Pathname objects to `Config.load_files`, no changes are necessary, but if you were somehow relying on the `.to_s` call for some other type of object, you'll now need to call `.to_s` on that object before passing it to `Config`.
|
54
71
|
* Before this change, `Config.load_files` would call `uniq` on its argument array. This call has been removed, so duplicate file paths are not removed before further processing. In some cases, this can cause differences in behavior since later config files override the values in earlier ones. In most cases, it's best to ensure that duplicate paths are not passed to `Config.load_files`.
|
55
72
|
|
56
73
|
## 3.1.1
|
data/README.md
CHANGED
@@ -53,6 +53,8 @@ which will generate customizable config file `config/initializers/config.rb` and
|
|
53
53
|
|
54
54
|
You can now edit them to adjust to your needs.
|
55
55
|
|
56
|
+
> Note: By default, the config environment will match the Rails environment (`Rails.env`). This can be changed by setting `config.environment`.
|
57
|
+
|
56
58
|
### Installing on Padrino
|
57
59
|
|
58
60
|
Add the gem to your `Gemfile` and run `bundle install` to install it. Then edit `app.rb` and register `Config`
|
@@ -426,7 +428,7 @@ ENV['Settings.section.server'] = 'google.com'
|
|
426
428
|
|
427
429
|
It won't work with arrays, though.
|
428
430
|
|
429
|
-
It is considered an error to use environment variables to
|
431
|
+
It is considered an error to use environment variables to simultaneously assign a "flat" value and a multi-level value to a key.
|
430
432
|
|
431
433
|
```ruby
|
432
434
|
# Raises an error when settings are loaded
|
data/config.gemspec
CHANGED
@@ -14,13 +14,10 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.license = 'MIT'
|
15
15
|
s.extra_rdoc_files = %w[README.md CHANGELOG.md CONTRIBUTING.md LICENSE.md]
|
16
16
|
s.rdoc_options = ['--charset=UTF-8']
|
17
|
-
s.post_install_message = "\n\e[33mThanks for installing Config\e[0m
|
18
|
-
Please consider donating to our open collective to help us maintain this project.
|
19
|
-
\n
|
20
|
-
Donate: \e[34mhttps://opencollective.com/rubyconfig/donate\e[0m\n"
|
21
17
|
|
22
18
|
s.metadata = {
|
23
19
|
'changelog_uri' => "https://github.com/rubyconfig/config/blob/master/CHANGELOG.md",
|
20
|
+
'funding_url' => 'https://opencollective.com/rubyconfig/donate',
|
24
21
|
'source_code_uri' => 'https://github.com/rubyconfig/config',
|
25
22
|
'bug_tracker_uri' => 'https://github.com/rubyconfig/config/issues'
|
26
23
|
}
|
@@ -9,7 +9,7 @@ module Config
|
|
9
9
|
|
10
10
|
# Parse the settings before any of the initializers
|
11
11
|
Config.load_and_set_settings(
|
12
|
-
Config.setting_files(::Rails.root.join('config'), ::Rails.env)
|
12
|
+
Config.setting_files(::Rails.root.join('config'), Config.environment.nil? ? ::Rails.env : Config.environment.to_sym)
|
13
13
|
)
|
14
14
|
end
|
15
15
|
|
@@ -6,17 +6,20 @@ module Config
|
|
6
6
|
attr_reader :separator
|
7
7
|
attr_reader :converter
|
8
8
|
attr_reader :parse_values
|
9
|
+
attr_reader :parse_arrays
|
9
10
|
|
10
11
|
def initialize(env,
|
11
12
|
prefix: Config.env_prefix || Config.const_name,
|
12
13
|
separator: Config.env_separator,
|
13
14
|
converter: Config.env_converter,
|
14
|
-
parse_values: Config.env_parse_values
|
15
|
+
parse_values: Config.env_parse_values,
|
16
|
+
parse_arrays: Config.env_parse_arrays)
|
15
17
|
@env = env
|
16
18
|
@prefix = prefix.to_s.split(separator)
|
17
19
|
@separator = separator
|
18
20
|
@converter = converter
|
19
21
|
@parse_values = parse_values
|
22
|
+
@parse_arrays = parse_arrays
|
20
23
|
end
|
21
24
|
|
22
25
|
def load
|
@@ -52,10 +55,28 @@ module Config
|
|
52
55
|
leaf[keys.last] = parse_values ? __value(value) : value
|
53
56
|
end
|
54
57
|
|
55
|
-
hash
|
58
|
+
parse_arrays ? convert_hashes_to_arrays(hash) : hash
|
56
59
|
end
|
57
60
|
|
58
61
|
private
|
62
|
+
def convert_hashes_to_arrays(hash)
|
63
|
+
hash.each_with_object({}) do |(key, value), new_hash|
|
64
|
+
if value.is_a?(Hash)
|
65
|
+
value = convert_hashes_to_arrays(value)
|
66
|
+
if consecutive_numeric_keys?(value.keys)
|
67
|
+
new_hash[key] = value.keys.sort_by(&:to_i).map { |k| value[k] }
|
68
|
+
else
|
69
|
+
new_hash[key] = value
|
70
|
+
end
|
71
|
+
else
|
72
|
+
new_hash[key] = value
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def consecutive_numeric_keys?(keys)
|
78
|
+
keys.map(&:to_i).sort == (0...keys.size).to_a && keys.all? { |k| k == k.to_i.to_s }
|
79
|
+
end
|
59
80
|
|
60
81
|
# Try to convert string to a correct type
|
61
82
|
def __value(v)
|
data/lib/config/version.rb
CHANGED
data/lib/config.rb
CHANGED
@@ -18,6 +18,7 @@ module Config
|
|
18
18
|
env_separator: '.',
|
19
19
|
env_converter: :downcase,
|
20
20
|
env_parse_values: true,
|
21
|
+
env_parse_arrays: false,
|
21
22
|
fail_on_missing: false,
|
22
23
|
file_name: 'settings',
|
23
24
|
dir_name: 'settings',
|
@@ -27,7 +28,8 @@ module Config
|
|
27
28
|
overwrite_arrays: true,
|
28
29
|
merge_hash_arrays: false,
|
29
30
|
validation_contract: nil,
|
30
|
-
evaluate_erb_in_yaml: true
|
31
|
+
evaluate_erb_in_yaml: true,
|
32
|
+
environment: nil
|
31
33
|
)
|
32
34
|
|
33
35
|
def self.setup
|
@@ -15,6 +15,11 @@ Config.setup do |config|
|
|
15
15
|
#
|
16
16
|
# config.overwrite_arrays = true
|
17
17
|
|
18
|
+
# Defines current environment, affecting which settings file will be loaded.
|
19
|
+
# Default: `Rails.env`
|
20
|
+
#
|
21
|
+
# config.environment = ENV.fetch('ENVIRONMENT', :development)
|
22
|
+
|
18
23
|
# Load environment variables from the `ENV` object and override any settings defined in files.
|
19
24
|
#
|
20
25
|
# config.use_env = false
|
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: 5.
|
4
|
+
version: 5.5.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: 2024-
|
13
|
+
date: 2024-05-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: deep_merge
|
@@ -264,10 +264,10 @@ licenses:
|
|
264
264
|
- MIT
|
265
265
|
metadata:
|
266
266
|
changelog_uri: https://github.com/rubyconfig/config/blob/master/CHANGELOG.md
|
267
|
+
funding_url: https://opencollective.com/rubyconfig/donate
|
267
268
|
source_code_uri: https://github.com/rubyconfig/config
|
268
269
|
bug_tracker_uri: https://github.com/rubyconfig/config/issues
|
269
|
-
post_install_message:
|
270
|
-
donating to our open collective to help us maintain this project.\n\n\nDonate: \e[34mhttps://opencollective.com/rubyconfig/donate\e[0m\n"
|
270
|
+
post_install_message:
|
271
271
|
rdoc_options:
|
272
272
|
- "--charset=UTF-8"
|
273
273
|
require_paths:
|
@@ -283,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
283
283
|
- !ruby/object:Gem::Version
|
284
284
|
version: '0'
|
285
285
|
requirements: []
|
286
|
-
rubygems_version: 3.4
|
286
|
+
rubygems_version: 3.5.4
|
287
287
|
signing_key:
|
288
288
|
specification_version: 4
|
289
289
|
summary: Effortless multi-environment settings in Rails, Sinatra, Padrino and others
|