config 3.1.1 → 5.1.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 +37 -2
- data/CONTRIBUTING.md +9 -3
- data/README.md +31 -3
- data/config.gemspec +4 -4
- data/lib/config/options.rb +15 -5
- data/lib/config/sources/yaml_source.rb +4 -4
- data/lib/config/version.rb +1 -1
- data/lib/config.rb +7 -7
- data/lib/generators/config/install_generator.rb +1 -1
- metadata +32 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e7864a2d30e62a39dbeb3c3eff43e07568a844b391e8c5f51f49c0712a2786b
|
4
|
+
data.tar.gz: b79745abcd726d5665aff0069ef3bef63250af5df0157f7515d0f67b65bfc9f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27b2ac548df27cb149bfb6f60753179d36d6bf2fa3caa0cb7a5f5e456450840357272c4c53bba986ad8f62d12f79960e87183faa2cd48f0afecdb695c802730a
|
7
|
+
data.tar.gz: 71c11e19fe808da90a497616ff635e00e0a3a86c971b751cf5e9bdebe34d86272a9197ca1b8104f7a1b0d2d98677ecb56bb681168c7a08d9bbc4e7cf9b914913
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,43 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
##
|
3
|
+
## 5.1.0
|
4
4
|
|
5
|
-
|
5
|
+
* Fix conflicts with Rails 7 active_support methods ([#347](https://github.com/rubyconfig/config/pull/339))
|
6
|
+
|
7
|
+
## 5.0.0
|
8
|
+
|
9
|
+
### BREAKING CHANGES
|
10
|
+
|
11
|
+
* No longer load `deep_merge`'s monkey patch for `Hash#deep_merge` and `Hash#deep_merge!` ([#342](https://github.com/rubyconfig/config/pull/342)). If you rely on those methods and are not using Rails / Active Support, you can load the monkey patch via `require 'deep_merge/deep_merge_hash'`. This change fixes Rails 7.x support.
|
12
|
+
|
13
|
+
## 4.2.1
|
14
|
+
|
15
|
+
### Bug fixes
|
16
|
+
|
17
|
+
* Address edge case with `table` config param ([#339](https://github.com/rubyconfig/config/pull/339))
|
18
|
+
|
19
|
+
## 4.2.0
|
20
|
+
|
21
|
+
### Bug fixes
|
22
|
+
|
23
|
+
* Remove use of method `File.exists?` to fix use in Ruby 3.0 ([#318](https://github.com/rubyconfig/config/pull/318))
|
24
|
+
|
25
|
+
## 4.1.0
|
26
|
+
|
27
|
+
### Bug fixes
|
28
|
+
|
29
|
+
* Only load `Railtie` integration if `Rails::Railtie` is defined ([#319](https://github.com/rubyconfig/config/pull/319))
|
30
|
+
* Fix indentation warning in Ruby 3.1 ([#322](https://github.com/rubyconfig/config/pull/322))
|
31
|
+
|
32
|
+
## 4.0.0
|
33
|
+
|
34
|
+
### BREAKING CHANGES
|
35
|
+
|
36
|
+
* Rails versions `< 5.2` are no longer supported ([#316](https://github.com/rubyconfig/config/pull/316))
|
37
|
+
* Ruby versions `< 2.6` are no longer supported ([#316](https://github.com/rubyconfig/config/pull/316))
|
38
|
+
* 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:
|
39
|
+
* Previously, `Config.load_files` (called from `Config.load_and_set_settings`) would call `.to_s` on each of its arguments. Now, this responsibility is defered 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`.
|
40
|
+
* 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`.
|
6
41
|
|
7
42
|
## 3.1.1
|
8
43
|
|
data/CONTRIBUTING.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Install appraisal
|
4
4
|
|
5
5
|
```bash
|
6
|
-
gem install bundler
|
6
|
+
gem install bundler
|
7
7
|
gem install appraisal
|
8
8
|
```
|
9
9
|
|
@@ -16,13 +16,19 @@ bundle install
|
|
16
16
|
Bootstrap
|
17
17
|
|
18
18
|
```bash
|
19
|
-
appraisal install
|
19
|
+
bundle exec appraisal install
|
20
|
+
```
|
21
|
+
|
22
|
+
If you need to create new test app for specific rails version
|
23
|
+
|
24
|
+
```bash
|
25
|
+
bundle exec appraisal rails-7.0 rails new spec/app/rails_7.0
|
20
26
|
```
|
21
27
|
|
22
28
|
Run the test suite:
|
23
29
|
|
24
30
|
```bash
|
25
|
-
appraisal rspec
|
31
|
+
bundle exec appraisal rspec
|
26
32
|
```
|
27
33
|
|
28
34
|
If you modified any of the documentation files verify their format:
|
data/README.md
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
[](https://rubygems.org/gems/config)
|
4
4
|
[](https://rubygems.org/gems/config)
|
5
|
-
[](https://rubygems.org/gems/config)
|
6
5
|
[](https://github.com/rubyconfig/config/actions?query=branch%3Amaster)
|
7
6
|
[](https://opencollective.com/rubyconfig)
|
8
7
|
|
@@ -24,16 +23,18 @@ Config helps you easily manage environment specific settings in an easy and usab
|
|
24
23
|
Current version supports and is [tested](.github/workflows/tests.yml#L19) for the following interpreters and frameworks:
|
25
24
|
|
26
25
|
* Interpreters
|
27
|
-
* [Ruby](https://www.ruby-lang.org) `>= 2.
|
26
|
+
* [Ruby](https://www.ruby-lang.org) `>= 2.6`
|
28
27
|
* [JRuby](https://www.jruby.org) `>= 9.2`
|
29
28
|
* [TruffleRuby](https://github.com/oracle/truffleruby) `>= 19.3`
|
30
29
|
* Application frameworks
|
31
|
-
* Rails `>=
|
30
|
+
* Rails `>= 5.2`
|
32
31
|
* Padrino
|
33
32
|
* Sinatra
|
34
33
|
|
35
34
|
For Ruby `2.0` to `2.3` or Rails `3` to `4.1` use version `1.x` of this gem. For older versions of Rails or Ruby use [AppConfig](http://github.com/fredwu/app_config).
|
36
35
|
|
36
|
+
For Ruby `2.4` or `2.5` or Rails `4.2`, `5.0`, or `5.1` use version `3.x` of this gem.
|
37
|
+
|
37
38
|
## Installing
|
38
39
|
|
39
40
|
### Installing on Rails
|
@@ -533,6 +534,33 @@ You are very warmly welcome to help. Please follow our [contribution guidelines]
|
|
533
534
|
|
534
535
|
Any and all contributions offered in any form, past present or future are understood to be in complete agreement and acceptance with [MIT](LICENSE) license.
|
535
536
|
|
537
|
+
### Running specs
|
538
|
+
|
539
|
+
Setup
|
540
|
+
|
541
|
+
```sh
|
542
|
+
bundle install
|
543
|
+
bundle exec appraisal install
|
544
|
+
```
|
545
|
+
|
546
|
+
List defined appraisals:
|
547
|
+
|
548
|
+
```sh
|
549
|
+
bundle exec appraisal list
|
550
|
+
```
|
551
|
+
|
552
|
+
Run specs for specific appraisal:
|
553
|
+
|
554
|
+
```sh
|
555
|
+
bundle exec appraisal rails-6.1 rspec
|
556
|
+
```
|
557
|
+
|
558
|
+
Run specs for all appraisals:
|
559
|
+
|
560
|
+
```sh
|
561
|
+
bundle exec appraisal rspec
|
562
|
+
```
|
563
|
+
|
536
564
|
## Authors
|
537
565
|
|
538
566
|
* [Piotr Kuczynski](http://github.com/pkuczynski)
|
data/config.gemspec
CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.date = Time.now.strftime '%F'
|
9
9
|
s.authors = ['Piotr Kuczynski', 'Fred Wu', 'Jacques Crocker']
|
10
10
|
s.email = %w[piotr.kuczynski@gmail.com ifredwu@gmail.com railsjedi@gmail.com]
|
11
|
-
s.summary = 'Effortless multi-environment settings in Rails, Sinatra,
|
11
|
+
s.summary = 'Effortless multi-environment settings in Rails, Sinatra, Padrino and others'
|
12
12
|
s.description = 'Easiest way to manage multi-environment settings in any ruby project or framework: ' +
|
13
|
-
'Rails, Sinatra,
|
13
|
+
'Rails, Sinatra, Padrino and others'
|
14
14
|
s.homepage = 'https://github.com/rubyconfig/config'
|
15
15
|
s.license = 'MIT'
|
16
16
|
s.extra_rdoc_files = %w[README.md CHANGELOG.md CONTRIBUTING.md LICENSE.md]
|
@@ -24,7 +24,7 @@ Donate: \e[34mhttps://opencollective.com/rubyconfig/donate\e[0m\n"
|
|
24
24
|
s.files.select! { |file| /(^lib\/|^\w+.md$|\.gemspec$)/ =~ file }
|
25
25
|
|
26
26
|
s.require_paths = ['lib']
|
27
|
-
s.required_ruby_version = '>= 2.
|
27
|
+
s.required_ruby_version = '>= 2.6.0'
|
28
28
|
|
29
29
|
s.add_dependency 'deep_merge', '~> 1.2', '>= 1.2.1'
|
30
30
|
s.add_dependency 'dry-validation', '~> 1.0', '>= 1.0.0'
|
@@ -32,7 +32,7 @@ Donate: \e[34mhttps://opencollective.com/rubyconfig/donate\e[0m\n"
|
|
32
32
|
s.add_development_dependency 'rake', '~> 12.0', '>= 12.0.0'
|
33
33
|
|
34
34
|
# Testing
|
35
|
-
s.add_development_dependency 'appraisal', '~> 2.
|
35
|
+
s.add_development_dependency 'appraisal', '~> 2.5', '>= 2.5.0'
|
36
36
|
s.add_development_dependency 'rspec', '~> 3.9', '>= 3.9.0'
|
37
37
|
|
38
38
|
# Default RSpec run will test against latest Rails app
|
data/lib/config/options.rb
CHANGED
@@ -16,7 +16,7 @@ module Config
|
|
16
16
|
|
17
17
|
def add_source!(source)
|
18
18
|
# handle yaml file paths
|
19
|
-
source = (Sources::YAMLSource.new(source)) if source.is_a?(String)
|
19
|
+
source = (Sources::YAMLSource.new(source)) if source.is_a?(String) || source.is_a?(Pathname)
|
20
20
|
source = (Sources::HashSource.new(source)) if source.is_a?(Hash)
|
21
21
|
|
22
22
|
@config_sources ||= []
|
@@ -24,7 +24,7 @@ module Config
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def prepend_source!(source)
|
27
|
-
source = (Sources::YAMLSource.new(source)) if source.is_a?(String)
|
27
|
+
source = (Sources::YAMLSource.new(source)) if source.is_a?(String) || source.is_a?(Pathname)
|
28
28
|
source = (Sources::HashSource.new(source)) if source.is_a?(Hash)
|
29
29
|
|
30
30
|
@config_sources ||= []
|
@@ -112,12 +112,16 @@ module Config
|
|
112
112
|
end
|
113
113
|
|
114
114
|
# Some keywords that don't play nicely with OpenStruct
|
115
|
-
SETTINGS_RESERVED_NAMES = %w[select collect test count zip min max exit!].freeze
|
115
|
+
SETTINGS_RESERVED_NAMES = %w[select collect test count zip min max exit! table].freeze
|
116
|
+
|
117
|
+
# Some keywords that don't play nicely with Rails 7.*
|
118
|
+
RAILS_RESERVED_NAMES = %w[maximum minimum].freeze
|
116
119
|
|
117
120
|
# An alternative mechanism for property access.
|
118
121
|
# This let's you do foo['bar'] along with foo.bar.
|
119
122
|
def [](param)
|
120
123
|
return super if SETTINGS_RESERVED_NAMES.include?(param)
|
124
|
+
return super if RAILS_RESERVED_NAMES.include?(param)
|
121
125
|
send("#{param}")
|
122
126
|
end
|
123
127
|
|
@@ -131,12 +135,18 @@ module Config
|
|
131
135
|
end
|
132
136
|
end
|
133
137
|
|
138
|
+
RAILS_RESERVED_NAMES.each do |name|
|
139
|
+
define_method name do
|
140
|
+
self[name]
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
134
144
|
def key?(key)
|
135
|
-
table.key?(key)
|
145
|
+
@table.key?(key)
|
136
146
|
end
|
137
147
|
|
138
148
|
def has_key?(key)
|
139
|
-
table.has_key?(key)
|
149
|
+
@table.has_key?(key)
|
140
150
|
end
|
141
151
|
|
142
152
|
def method_missing(method_name, *args)
|
@@ -22,10 +22,10 @@ module Config
|
|
22
22
|
|
23
23
|
result || {}
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
rescue Psych::SyntaxError => e
|
26
|
+
raise "YAML syntax error occurred while parsing #{@path}. " \
|
27
|
+
"Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
|
28
|
+
"Error: #{e.message}"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/lib/config/version.rb
CHANGED
data/lib/config.rb
CHANGED
@@ -6,7 +6,7 @@ require 'config/sources/yaml_source'
|
|
6
6
|
require 'config/sources/hash_source'
|
7
7
|
require 'config/sources/env_source'
|
8
8
|
require 'config/validation/schema'
|
9
|
-
require 'deep_merge'
|
9
|
+
require 'deep_merge/core'
|
10
10
|
|
11
11
|
module Config
|
12
12
|
extend Config::Validation::Schema
|
@@ -35,12 +35,12 @@ module Config
|
|
35
35
|
|
36
36
|
# Create a populated Options instance from a settings file. If a second file is given, then the sections of that
|
37
37
|
# file will overwrite existing sections of the first file.
|
38
|
-
def self.load_files(*
|
38
|
+
def self.load_files(*sources)
|
39
39
|
config = Options.new
|
40
40
|
|
41
41
|
# add settings sources
|
42
|
-
[
|
43
|
-
config.add_source!(
|
42
|
+
[sources].flatten.compact.each do |source|
|
43
|
+
config.add_source!(source)
|
44
44
|
end
|
45
45
|
|
46
46
|
config.add_source!(Sources::EnvSource.new(ENV)) if Config.use_env
|
@@ -50,10 +50,10 @@ module Config
|
|
50
50
|
end
|
51
51
|
|
52
52
|
# Loads and sets the settings constant!
|
53
|
-
def self.load_and_set_settings(*
|
53
|
+
def self.load_and_set_settings(*sources)
|
54
54
|
name = Config.const_name
|
55
55
|
Object.send(:remove_const, name) if Object.const_defined?(name)
|
56
|
-
Object.const_set(name, Config.load_files(
|
56
|
+
Object.const_set(name, Config.load_files(sources))
|
57
57
|
end
|
58
58
|
|
59
59
|
def self.setting_files(config_root, env)
|
@@ -79,7 +79,7 @@ module Config
|
|
79
79
|
end
|
80
80
|
|
81
81
|
# Rails integration
|
82
|
-
require('config/integrations/rails/railtie') if defined?(::Rails)
|
82
|
+
require('config/integrations/rails/railtie') if defined?(::Rails::Railtie)
|
83
83
|
|
84
84
|
# Sinatra integration
|
85
85
|
require('config/integrations/sinatra') if defined?(::Sinatra)
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Kuczynski
|
8
8
|
- Fred Wu
|
9
9
|
- Jacques Crocker
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-12-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: deep_merge
|
@@ -78,20 +78,20 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '2.
|
81
|
+
version: '2.5'
|
82
82
|
- - ">="
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version: 2.
|
84
|
+
version: 2.5.0
|
85
85
|
type: :development
|
86
86
|
prerelease: false
|
87
87
|
version_requirements: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
89
|
- - "~>"
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: '2.
|
91
|
+
version: '2.5'
|
92
92
|
- - ">="
|
93
93
|
- !ruby/object:Gem::Version
|
94
|
-
version: 2.
|
94
|
+
version: 2.5.0
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
96
|
name: rspec
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,42 +118,56 @@ dependencies:
|
|
118
118
|
requirements:
|
119
119
|
- - ">="
|
120
120
|
- !ruby/object:Gem::Version
|
121
|
-
version: 1.
|
121
|
+
version: 1.16.0
|
122
122
|
type: :development
|
123
123
|
prerelease: false
|
124
124
|
version_requirements: !ruby/object:Gem::Requirement
|
125
125
|
requirements:
|
126
126
|
- - ">="
|
127
127
|
- !ruby/object:Gem::Version
|
128
|
-
version: 1.
|
128
|
+
version: 1.16.0
|
129
129
|
- !ruby/object:Gem::Dependency
|
130
130
|
name: rails
|
131
131
|
requirement: !ruby/object:Gem::Requirement
|
132
132
|
requirements:
|
133
133
|
- - '='
|
134
134
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
135
|
+
version: 7.1.0
|
136
136
|
type: :development
|
137
137
|
prerelease: false
|
138
138
|
version_requirements: !ruby/object:Gem::Requirement
|
139
139
|
requirements:
|
140
140
|
- - '='
|
141
141
|
- !ruby/object:Gem::Version
|
142
|
-
version:
|
142
|
+
version: 7.1.0
|
143
143
|
- !ruby/object:Gem::Dependency
|
144
144
|
name: rspec-rails
|
145
145
|
requirement: !ruby/object:Gem::Requirement
|
146
146
|
requirements:
|
147
147
|
- - "~>"
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version:
|
149
|
+
version: 6.0.3
|
150
150
|
type: :development
|
151
151
|
prerelease: false
|
152
152
|
version_requirements: !ruby/object:Gem::Requirement
|
153
153
|
requirements:
|
154
154
|
- - "~>"
|
155
155
|
- !ruby/object:Gem::Version
|
156
|
-
version:
|
156
|
+
version: 6.0.3
|
157
|
+
- !ruby/object:Gem::Dependency
|
158
|
+
name: sprockets-rails
|
159
|
+
requirement: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - "~>"
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: 3.4.2
|
164
|
+
type: :development
|
165
|
+
prerelease: false
|
166
|
+
version_requirements: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - "~>"
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: 3.4.2
|
157
171
|
- !ruby/object:Gem::Dependency
|
158
172
|
name: psych
|
159
173
|
requirement: !ruby/object:Gem::Requirement
|
@@ -203,7 +217,7 @@ dependencies:
|
|
203
217
|
- !ruby/object:Gem::Version
|
204
218
|
version: 0.85.0
|
205
219
|
description: 'Easiest way to manage multi-environment settings in any ruby project
|
206
|
-
or framework: Rails, Sinatra,
|
220
|
+
or framework: Rails, Sinatra, Padrino and others'
|
207
221
|
email:
|
208
222
|
- piotr.kuczynski@gmail.com
|
209
223
|
- ifredwu@gmail.com
|
@@ -258,15 +272,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
258
272
|
requirements:
|
259
273
|
- - ">="
|
260
274
|
- !ruby/object:Gem::Version
|
261
|
-
version: 2.
|
275
|
+
version: 2.6.0
|
262
276
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
263
277
|
requirements:
|
264
278
|
- - ">="
|
265
279
|
- !ruby/object:Gem::Version
|
266
280
|
version: '0'
|
267
281
|
requirements: []
|
268
|
-
rubygems_version: 3.
|
269
|
-
signing_key:
|
282
|
+
rubygems_version: 3.4.10
|
283
|
+
signing_key:
|
270
284
|
specification_version: 4
|
271
|
-
summary: Effortless multi-environment settings in Rails, Sinatra,
|
285
|
+
summary: Effortless multi-environment settings in Rails, Sinatra, Padrino and others
|
272
286
|
test_files: []
|