config 5.4.0 → 5.5.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/CHANGELOG.md +18 -1
- data/README.md +1 -1
- data/config.gemspec +1 -4
- data/lib/config/sources/env_source.rb +23 -2
- data/lib/config/version.rb +1 -1
- data/lib/config.rb +1 -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: 7d45b7406d553675ee52e72b0844d60c2bf2f1f27bc8c29fb1833cbe86ca92d3
|
4
|
+
data.tar.gz: 234c1d664bc25031df364c3a8a3384544862cfb39b838c6c1b39e5d28687ea70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a107c67a53f64d1a4af4694d38355a028af0caee739ea640f32f03343f06a850b70bb64a580dcfdae2576e413cc83898f613fe196e8065ec36edc40712e02cf6
|
7
|
+
data.tar.gz: 2a24721b6a2e355c482659a6d76d657fc1b67fb3390fabffafeb9433bceb80423e0254aa972052a237f4f277815ea17442fa3ab86b3ce9521953c8ffab277de8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 5.5.1
|
4
|
+
|
5
|
+
### Documentation
|
6
|
+
|
7
|
+
* Fix funding_url to funding_uri in gemspec ([#361](https://github.com/rubyconfig/config/pull/361))
|
8
|
+
|
9
|
+
## 5.5.0
|
10
|
+
|
11
|
+
### New features
|
12
|
+
|
13
|
+
* Allow arrays to be passed through env variables ([#354](https://github.com/rubyconfig/config/pull/354))
|
14
|
+
|
15
|
+
### Documentation
|
16
|
+
|
17
|
+
* Use funding_url rather than post_install_message ([#360](https://github.com/rubyconfig/config/pull/360))
|
18
|
+
* Fix typos in the tests and documentation ([#359](https://github.com/rubyconfig/config/pull/359))
|
19
|
+
|
3
20
|
## 5.4.0
|
4
21
|
|
5
22
|
### New features
|
@@ -56,7 +73,7 @@
|
|
56
73
|
* Rails versions `< 5.2` are no longer supported ([#316](https://github.com/rubyconfig/config/pull/316))
|
57
74
|
* Ruby versions `< 2.6` are no longer supported ([#316](https://github.com/rubyconfig/config/pull/316))
|
58
75
|
* 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:
|
59
|
-
* Previously, `Config.load_files` (called from `Config.load_and_set_settings`) would call `.to_s` on each of its arguments. Now, this responsibility is
|
76
|
+
* 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`.
|
60
77
|
* 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`.
|
61
78
|
|
62
79
|
## 3.1.1
|
data/README.md
CHANGED
@@ -428,7 +428,7 @@ ENV['Settings.section.server'] = 'google.com'
|
|
428
428
|
|
429
429
|
It won't work with arrays, though.
|
430
430
|
|
431
|
-
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.
|
432
432
|
|
433
433
|
```ruby
|
434
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_uri' => '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
|
}
|
@@ -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
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.1
|
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-30 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_uri: 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
|