config 4.2.1 → 5.6.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 +60 -1
- data/CONTRIBUTING.md +9 -3
- data/README.md +22 -2
- data/config.gemspec +19 -11
- data/lib/config/dry_validation_requirements.rb +25 -0
- data/lib/config/error.rb +4 -0
- data/lib/config/integrations/heroku.rb +2 -2
- data/lib/config/integrations/rails/railtie.rb +1 -1
- data/lib/config/options.rb +11 -1
- data/lib/config/sources/env_source.rb +23 -2
- data/lib/config/sources/yaml_source.rb +1 -1
- data/lib/config/validation/error.rb +3 -1
- data/lib/config/validation/schema.rb +4 -1
- data/lib/config/validation/validate.rb +4 -0
- data/lib/config/version.rb +1 -1
- data/lib/config.rb +16 -8
- data/lib/generators/config/install_generator.rb +6 -6
- data/lib/generators/config/templates/config.rb +19 -0
- metadata +72 -29
- data/lib/config/compatibility.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2cd615486e9e4f65f2c542ad5112f0bedbf744a6413f15d157a62c6b2b798a0
|
4
|
+
data.tar.gz: 492dc3f5194934a08586b3a3f2b24bf5c1d7572ea2a97aafc0a0bd882a806d43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16737e3afd9def484dc34d92661acef67452274841bb7ae74cb68992b8e857a5735b5d6692cdc31a42d460fb623385eef0aed5ff7c364d4f49226aa1ae5259f8
|
7
|
+
data.tar.gz: b6fa89e593d1997d29c56be704a148ea9591dbf11e723980966af4bfc109c9a3aa16e1c3192d865e43f5188bae815bab5e5012ee14e686e809ece99d2b358a6b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,64 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 5.6.1
|
4
|
+
|
5
|
+
* fix(security): replace IO.read with File.read [#378](https://github.com/rubyconfig/config/pull/378)
|
6
|
+
|
7
|
+
## 5.6.0
|
8
|
+
|
9
|
+
* Added `extra_sources` in initializer ([#366](https://github.com/rubyconfig/config/pull/366))
|
10
|
+
|
11
|
+
## 5.5.2
|
12
|
+
|
13
|
+
* Fix warning: ostruct was loaded from the standard library with Ruby 3.3.5 and 3.4+ ([#363](https://github.com/rubyconfig/config/pull/363))
|
14
|
+
|
15
|
+
## 5.5.1
|
16
|
+
|
17
|
+
### Documentation
|
18
|
+
|
19
|
+
* Fix funding_url to funding_uri in gemspec ([#361](https://github.com/rubyconfig/config/pull/361))
|
20
|
+
|
21
|
+
## 5.5.0
|
22
|
+
|
23
|
+
### New features
|
24
|
+
|
25
|
+
* Allow arrays to be passed through env variables ([#354](https://github.com/rubyconfig/config/pull/354))
|
26
|
+
|
27
|
+
### Documentation
|
28
|
+
|
29
|
+
* Use funding_url rather than post_install_message ([#360](https://github.com/rubyconfig/config/pull/360))
|
30
|
+
* Fix typos in the tests and documentation ([#359](https://github.com/rubyconfig/config/pull/359))
|
31
|
+
|
32
|
+
## 5.4.0
|
33
|
+
|
34
|
+
### New features
|
35
|
+
|
36
|
+
* Add configuration option `environment` to override the use of `Rails.env` ([#356](https://github.com/rubyconfig/config/pull/356))
|
37
|
+
|
38
|
+
## 5.3.0
|
39
|
+
|
40
|
+
* Remove `dry-validation` from dependencies ([#333](https://github.com/rubyconfig/config/pull/333))
|
41
|
+
|
42
|
+
## 5.2.0
|
43
|
+
|
44
|
+
### New features
|
45
|
+
|
46
|
+
* Allow to use custom filename && directory name to store configs ([#341](https://github.com/rubyconfig/config/pull/341))
|
47
|
+
|
48
|
+
### Bug fixes
|
49
|
+
|
50
|
+
* Prevent name collision with private methods from ancestors ([#351](https://github.com/rubyconfig/config/pull/351))
|
51
|
+
|
52
|
+
## 5.1.0
|
53
|
+
|
54
|
+
* Fix conflicts with Rails 7 active_support methods ([#347](https://github.com/rubyconfig/config/pull/347))
|
55
|
+
|
56
|
+
## 5.0.0
|
57
|
+
|
58
|
+
### BREAKING CHANGES
|
59
|
+
|
60
|
+
* 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.
|
61
|
+
|
3
62
|
## 4.2.1
|
4
63
|
|
5
64
|
### Bug fixes
|
@@ -26,7 +85,7 @@
|
|
26
85
|
* Rails versions `< 5.2` are no longer supported ([#316](https://github.com/rubyconfig/config/pull/316))
|
27
86
|
* Ruby versions `< 2.6` are no longer supported ([#316](https://github.com/rubyconfig/config/pull/316))
|
28
87
|
* 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:
|
29
|
-
* Previously, `Config.load_files` (called from `Config.load_and_set_settings`) would call `.to_s` on each of its arguments. Now, this responsibility is
|
88
|
+
* 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`.
|
30
89
|
* 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`.
|
31
90
|
|
32
91
|
## 3.1.1
|
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
@@ -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`
|
@@ -152,6 +154,22 @@ Example production environment config file:
|
|
152
154
|
#{Rails.root}/config/environments/production.yml
|
153
155
|
```
|
154
156
|
|
157
|
+
### Extra sources
|
158
|
+
|
159
|
+
You can load extra sources during initialization by setting the `extra_sources` configuration option.
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
Config.setup do |config|
|
163
|
+
config.extra_sources = [
|
164
|
+
'path/to/extra_source.yml', # String: loads extra_source.yml
|
165
|
+
{ api_key: ENV['API_KEY'] }, # Hash: direct hash source
|
166
|
+
MyCustomSource.new, # Object: custom source object that responds to `load`
|
167
|
+
]
|
168
|
+
end
|
169
|
+
```
|
170
|
+
|
171
|
+
This will also overwrite the same config entries from the main file.
|
172
|
+
|
155
173
|
### Developer specific config files
|
156
174
|
|
157
175
|
If you want to have local settings, specific to your machine or development environment, you can use the following files, which are automatically `.gitignore` :
|
@@ -268,8 +286,10 @@ After installing `Config` in Rails, you will find automatically generated file t
|
|
268
286
|
|
269
287
|
### General
|
270
288
|
|
271
|
-
* `const_name` - name of the object
|
289
|
+
* `const_name` - name of the object holding your settings. Default: `'Settings'`
|
272
290
|
* `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`
|
291
|
+
* `file_name` - name of the file to store general keys accessible in all environments. Default: `'settings'` - located at `config/settings.yml`
|
292
|
+
* `dir_name` - name of the directory to store environment-specific files. Default: `'settings'` - located at `config/settings/`
|
273
293
|
|
274
294
|
### Merge customization
|
275
295
|
|
@@ -424,7 +444,7 @@ ENV['Settings.section.server'] = 'google.com'
|
|
424
444
|
|
425
445
|
It won't work with arrays, though.
|
426
446
|
|
427
|
-
It is considered an error to use environment variables to
|
447
|
+
It is considered an error to use environment variables to simultaneously assign a "flat" value and a multi-level value to a key.
|
428
448
|
|
429
449
|
```ruby
|
430
450
|
# Raises an error when settings are loaded
|
data/config.gemspec
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'config/version'
|
1
|
+
require_relative 'lib/config/version'
|
2
|
+
require_relative 'lib/config/dry_validation_requirements'
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
6
5
|
s.name = 'config'
|
@@ -15,11 +14,13 @@ Gem::Specification.new do |s|
|
|
15
14
|
s.license = 'MIT'
|
16
15
|
s.extra_rdoc_files = %w[README.md CHANGELOG.md CONTRIBUTING.md LICENSE.md]
|
17
16
|
s.rdoc_options = ['--charset=UTF-8']
|
18
|
-
s.post_install_message = "\n\e[33mThanks for installing Config\e[0m
|
19
|
-
Please consider donating to our open collective to help us maintain this project.
|
20
|
-
\n
|
21
|
-
Donate: \e[34mhttps://opencollective.com/rubyconfig/donate\e[0m\n"
|
22
17
|
|
18
|
+
s.metadata = {
|
19
|
+
'changelog_uri' => "https://github.com/rubyconfig/config/blob/master/CHANGELOG.md",
|
20
|
+
'funding_uri' => 'https://opencollective.com/rubyconfig/donate',
|
21
|
+
'source_code_uri' => 'https://github.com/rubyconfig/config',
|
22
|
+
'bug_tracker_uri' => 'https://github.com/rubyconfig/config/issues'
|
23
|
+
}
|
23
24
|
s.files = `git ls-files`.split($/)
|
24
25
|
s.files.select! { |file| /(^lib\/|^\w+.md$|\.gemspec$)/ =~ file }
|
25
26
|
|
@@ -27,19 +28,26 @@ Donate: \e[34mhttps://opencollective.com/rubyconfig/donate\e[0m\n"
|
|
27
28
|
s.required_ruby_version = '>= 2.6.0'
|
28
29
|
|
29
30
|
s.add_dependency 'deep_merge', '~> 1.2', '>= 1.2.1'
|
30
|
-
s.add_dependency '
|
31
|
+
s.add_dependency 'ostruct'
|
31
32
|
|
32
33
|
s.add_development_dependency 'rake', '~> 12.0', '>= 12.0.0'
|
33
34
|
|
34
35
|
# Testing
|
35
|
-
s.add_development_dependency 'appraisal', '~> 2.
|
36
|
+
s.add_development_dependency 'appraisal', '~> 2.5', '>= 2.5.0'
|
37
|
+
s.add_development_dependency 'dry-validation', *Config::DryValidationRequirements::VERSIONS
|
36
38
|
s.add_development_dependency 'rspec', '~> 3.9', '>= 3.9.0'
|
37
39
|
|
38
40
|
# Default RSpec run will test against latest Rails app
|
39
41
|
unless ENV['APPRAISAL_INITIALIZED'] || ENV['GITHUB_ACTIONS']
|
40
42
|
gems_to_install = /gem "(.*?)", "(.*?)"(?!, platform: (?!\[:ruby\]))/
|
41
|
-
|
42
|
-
|
43
|
+
|
44
|
+
if Dir.exist?('gemfiles')
|
45
|
+
rails_gemfiles = Dir['gemfiles/rails*.gemfile'].sort
|
46
|
+
unless rails_gemfiles.empty?
|
47
|
+
File.read(rails_gemfiles.last).scan(gems_to_install) do |name, version|
|
48
|
+
s.add_development_dependency name, version
|
49
|
+
end
|
50
|
+
end
|
43
51
|
end
|
44
52
|
end
|
45
53
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Config
|
4
|
+
module DryValidationRequirements
|
5
|
+
VERSIONS = ['~> 1.0', '>= 1.0.0'].freeze
|
6
|
+
|
7
|
+
def self.load_dry_validation!
|
8
|
+
return if defined?(@load_dry_validation)
|
9
|
+
|
10
|
+
begin
|
11
|
+
require 'dry/validation/version'
|
12
|
+
version = Gem::Version.new(Dry::Validation::VERSION)
|
13
|
+
unless VERSIONS.all? { |req| Gem::Requirement.new(req).satisfied_by?(version) }
|
14
|
+
raise LoadError
|
15
|
+
end
|
16
|
+
rescue LoadError
|
17
|
+
raise ::Config::Error, "Could not find a dry-validation version matching requirements (#{VERSIONS.map(&:inspect) * ','})"
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'dry/validation'
|
21
|
+
@load_dry_validation = true
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/config/error.rb
ADDED
@@ -14,8 +14,8 @@ module Config
|
|
14
14
|
def vars
|
15
15
|
# Load only local options to Heroku
|
16
16
|
Config.load_and_set_settings(
|
17
|
-
Rails.root.join("config", "
|
18
|
-
Rails.root.join("config",
|
17
|
+
Rails.root.join("config", "#{Config.file_name}.local.yml").to_s,
|
18
|
+
Rails.root.join("config", Config.dir_name, "#{environment}.local.yml").to_s,
|
19
19
|
Rails.root.join("config", "environments", "#{environment}.local.yml").to_s
|
20
20
|
)
|
21
21
|
|
@@ -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
|
|
data/lib/config/options.rb
CHANGED
@@ -114,11 +114,15 @@ module Config
|
|
114
114
|
# Some keywords that don't play nicely with OpenStruct
|
115
115
|
SETTINGS_RESERVED_NAMES = %w[select collect test count zip min max exit! table].freeze
|
116
116
|
|
117
|
+
# Some keywords that don't play nicely with Rails 7.*
|
118
|
+
RAILS_RESERVED_NAMES = %w[maximum minimum].freeze
|
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)
|
121
|
-
|
124
|
+
return super if RAILS_RESERVED_NAMES.include?(param)
|
125
|
+
public_send("#{param}")
|
122
126
|
end
|
123
127
|
|
124
128
|
def []=(param, value)
|
@@ -131,6 +135,12 @@ 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
145
|
@table.key?(key)
|
136
146
|
end
|
@@ -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)
|
@@ -15,7 +15,7 @@ module Config
|
|
15
15
|
# returns a config hash from the YML file
|
16
16
|
def load
|
17
17
|
if @path and File.exist?(@path)
|
18
|
-
file_contents =
|
18
|
+
file_contents = File.read(@path)
|
19
19
|
file_contents = ERB.new(file_contents).result if evaluate_erb
|
20
20
|
result = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(file_contents) : YAML.load(file_contents)
|
21
21
|
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
require_relative '../dry_validation_requirements'
|
2
|
+
require_relative '../error'
|
3
|
+
|
1
4
|
module Config
|
2
5
|
module Validation
|
3
6
|
module Schema
|
@@ -9,7 +12,7 @@ module Config
|
|
9
12
|
def schema(&block)
|
10
13
|
if block_given?
|
11
14
|
# Delay require until optional schema validation is requested
|
12
|
-
|
15
|
+
Config::DryValidationRequirements.load_dry_validation!
|
13
16
|
@schema = Dry::Schema.define(&block)
|
14
17
|
else
|
15
18
|
@schema
|
@@ -4,6 +4,10 @@ module Config
|
|
4
4
|
module Validation
|
5
5
|
module Validate
|
6
6
|
def validate!
|
7
|
+
return unless Config.validation_contract || Config.schema
|
8
|
+
|
9
|
+
Config::DryValidationRequirements.load_dry_validation!
|
10
|
+
|
7
11
|
validate_using!(Config.validation_contract)
|
8
12
|
validate_using!(Config.schema)
|
9
13
|
end
|
data/lib/config/version.rb
CHANGED
data/lib/config.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require 'config/compatibility'
|
2
1
|
require 'config/options'
|
3
2
|
require 'config/configuration'
|
3
|
+
require 'config/dry_validation_requirements'
|
4
4
|
require 'config/version'
|
5
5
|
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
|
@@ -18,14 +18,19 @@ 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,
|
23
|
+
file_name: 'settings',
|
24
|
+
dir_name: 'settings',
|
22
25
|
# deep_merge options
|
23
26
|
knockout_prefix: nil,
|
24
27
|
merge_nil_values: true,
|
25
28
|
overwrite_arrays: true,
|
26
29
|
merge_hash_arrays: false,
|
27
30
|
validation_contract: nil,
|
28
|
-
evaluate_erb_in_yaml: true
|
31
|
+
evaluate_erb_in_yaml: true,
|
32
|
+
environment: nil,
|
33
|
+
extra_sources: []
|
29
34
|
)
|
30
35
|
|
31
36
|
def self.setup
|
@@ -53,13 +58,16 @@ module Config
|
|
53
58
|
def self.load_and_set_settings(*sources)
|
54
59
|
name = Config.const_name
|
55
60
|
Object.send(:remove_const, name) if Object.const_defined?(name)
|
56
|
-
|
61
|
+
|
62
|
+
# Include extra sources in the loading process
|
63
|
+
all_sources = [sources, Config.extra_sources].flatten.compact
|
64
|
+
Object.const_set(name, Config.load_files(*all_sources))
|
57
65
|
end
|
58
66
|
|
59
67
|
def self.setting_files(config_root, env)
|
60
68
|
[
|
61
|
-
File.join(config_root,
|
62
|
-
File.join(config_root,
|
69
|
+
File.join(config_root, "#{Config.file_name}.yml").to_s,
|
70
|
+
File.join(config_root, Config.dir_name, "#{env}.yml").to_s,
|
63
71
|
File.join(config_root, 'environments', "#{env}.yml").to_s,
|
64
72
|
*local_setting_files(config_root, env)
|
65
73
|
].freeze
|
@@ -67,8 +75,8 @@ module Config
|
|
67
75
|
|
68
76
|
def self.local_setting_files(config_root, env)
|
69
77
|
[
|
70
|
-
(File.join(config_root,
|
71
|
-
File.join(config_root,
|
78
|
+
(File.join(config_root, "#{Config.file_name}.local.yml").to_s if env != 'test'),
|
79
|
+
File.join(config_root, Config.dir_name, "#{env}.local.yml").to_s,
|
72
80
|
File.join(config_root, 'environments', "#{env}.local.yml").to_s
|
73
81
|
].compact
|
74
82
|
end
|
@@ -12,18 +12,18 @@ module Config
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def copy_settings
|
15
|
-
template "settings.yml", "config
|
16
|
-
template "settings.local.yml", "config
|
17
|
-
directory "settings", "config
|
15
|
+
template "settings.yml", "config/#{Config.file_name}.yml"
|
16
|
+
template "settings.local.yml", "config/#{Config.file_name}.local.yml"
|
17
|
+
directory "settings", "config/#{Config.dir_name}"
|
18
18
|
end
|
19
19
|
|
20
20
|
def modify_gitignore
|
21
21
|
create_file '.gitignore' unless File.exist? '.gitignore'
|
22
22
|
|
23
23
|
append_to_file '.gitignore' do
|
24
|
-
"\n"
|
25
|
-
"config
|
26
|
-
"config
|
24
|
+
"\n" +
|
25
|
+
"config/#{Config.file_name}.local.yml\n" +
|
26
|
+
"config/#{Config.dir_name}/*.local.yml\n" +
|
27
27
|
"config/environments/*.local.yml\n"
|
28
28
|
end
|
29
29
|
end
|
@@ -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
|
@@ -55,4 +60,18 @@ Config.setup do |config|
|
|
55
60
|
# Evaluate ERB in YAML config files at load time.
|
56
61
|
#
|
57
62
|
# config.evaluate_erb_in_yaml = true
|
63
|
+
|
64
|
+
# Name of directory and file to store config keys
|
65
|
+
#
|
66
|
+
# config.file_name = 'settings'
|
67
|
+
# config.dir_name = 'settings'
|
68
|
+
|
69
|
+
# Load extra sources from a path. These can be file paths (strings),
|
70
|
+
# hashes, or custom source objects that respond to 'load'
|
71
|
+
#
|
72
|
+
# config.extra_sources = [
|
73
|
+
# 'path/to/extra_source.yml', # String: loads extra_source.yml
|
74
|
+
# { api_key: ENV['API_KEY'] }, # Hash: direct hash source
|
75
|
+
# MyCustomSource.new, # Custom source object
|
76
|
+
# ]
|
58
77
|
end
|
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Kuczynski
|
8
8
|
- Fred Wu
|
9
9
|
- Jacques Crocker
|
10
|
-
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2025-07-11 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: deep_merge
|
@@ -33,25 +32,19 @@ dependencies:
|
|
33
32
|
- !ruby/object:Gem::Version
|
34
33
|
version: 1.2.1
|
35
34
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
35
|
+
name: ostruct
|
37
36
|
requirement: !ruby/object:Gem::Requirement
|
38
37
|
requirements:
|
39
|
-
- - "~>"
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '1.0'
|
42
38
|
- - ">="
|
43
39
|
- !ruby/object:Gem::Version
|
44
|
-
version:
|
40
|
+
version: '0'
|
45
41
|
type: :runtime
|
46
42
|
prerelease: false
|
47
43
|
version_requirements: !ruby/object:Gem::Requirement
|
48
44
|
requirements:
|
49
|
-
- - "~>"
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
version: '1.0'
|
52
45
|
- - ">="
|
53
46
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
47
|
+
version: '0'
|
55
48
|
- !ruby/object:Gem::Dependency
|
56
49
|
name: rake
|
57
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,20 +71,40 @@ dependencies:
|
|
78
71
|
requirements:
|
79
72
|
- - "~>"
|
80
73
|
- !ruby/object:Gem::Version
|
81
|
-
version: '2.
|
74
|
+
version: '2.5'
|
82
75
|
- - ">="
|
83
76
|
- !ruby/object:Gem::Version
|
84
|
-
version: 2.
|
77
|
+
version: 2.5.0
|
85
78
|
type: :development
|
86
79
|
prerelease: false
|
87
80
|
version_requirements: !ruby/object:Gem::Requirement
|
88
81
|
requirements:
|
89
82
|
- - "~>"
|
90
83
|
- !ruby/object:Gem::Version
|
91
|
-
version: '2.
|
84
|
+
version: '2.5'
|
92
85
|
- - ">="
|
93
86
|
- !ruby/object:Gem::Version
|
94
|
-
version: 2.
|
87
|
+
version: 2.5.0
|
88
|
+
- !ruby/object:Gem::Dependency
|
89
|
+
name: dry-validation
|
90
|
+
requirement: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '1.0'
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 1.0.0
|
98
|
+
type: :development
|
99
|
+
prerelease: false
|
100
|
+
version_requirements: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '1.0'
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: 1.0.0
|
95
108
|
- !ruby/object:Gem::Dependency
|
96
109
|
name: rspec
|
97
110
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,42 +131,56 @@ dependencies:
|
|
118
131
|
requirements:
|
119
132
|
- - ">="
|
120
133
|
- !ruby/object:Gem::Version
|
121
|
-
version: 1.
|
134
|
+
version: 1.16.0
|
122
135
|
type: :development
|
123
136
|
prerelease: false
|
124
137
|
version_requirements: !ruby/object:Gem::Requirement
|
125
138
|
requirements:
|
126
139
|
- - ">="
|
127
140
|
- !ruby/object:Gem::Version
|
128
|
-
version: 1.
|
141
|
+
version: 1.16.0
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: kamal
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - "~>"
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: 2.7.0
|
149
|
+
type: :development
|
150
|
+
prerelease: false
|
151
|
+
version_requirements: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - "~>"
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: 2.7.0
|
129
156
|
- !ruby/object:Gem::Dependency
|
130
157
|
name: rails
|
131
158
|
requirement: !ruby/object:Gem::Requirement
|
132
159
|
requirements:
|
133
160
|
- - '='
|
134
161
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
162
|
+
version: 8.0.2
|
136
163
|
type: :development
|
137
164
|
prerelease: false
|
138
165
|
version_requirements: !ruby/object:Gem::Requirement
|
139
166
|
requirements:
|
140
167
|
- - '='
|
141
168
|
- !ruby/object:Gem::Version
|
142
|
-
version:
|
169
|
+
version: 8.0.2
|
143
170
|
- !ruby/object:Gem::Dependency
|
144
171
|
name: rspec-rails
|
145
172
|
requirement: !ruby/object:Gem::Requirement
|
146
173
|
requirements:
|
147
174
|
- - "~>"
|
148
175
|
- !ruby/object:Gem::Version
|
149
|
-
version:
|
176
|
+
version: 8.0.1
|
150
177
|
type: :development
|
151
178
|
prerelease: false
|
152
179
|
version_requirements: !ruby/object:Gem::Requirement
|
153
180
|
requirements:
|
154
181
|
- - "~>"
|
155
182
|
- !ruby/object:Gem::Version
|
156
|
-
version:
|
183
|
+
version: 8.0.1
|
157
184
|
- !ruby/object:Gem::Dependency
|
158
185
|
name: psych
|
159
186
|
requirement: !ruby/object:Gem::Requirement
|
@@ -168,6 +195,20 @@ dependencies:
|
|
168
195
|
- - ">="
|
169
196
|
- !ruby/object:Gem::Version
|
170
197
|
version: '4'
|
198
|
+
- !ruby/object:Gem::Dependency
|
199
|
+
name: sprockets-rails
|
200
|
+
requirement: !ruby/object:Gem::Requirement
|
201
|
+
requirements:
|
202
|
+
- - "~>"
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: 3.5.2
|
205
|
+
type: :development
|
206
|
+
prerelease: false
|
207
|
+
version_requirements: !ruby/object:Gem::Requirement
|
208
|
+
requirements:
|
209
|
+
- - "~>"
|
210
|
+
- !ruby/object:Gem::Version
|
211
|
+
version: 3.5.2
|
171
212
|
- !ruby/object:Gem::Dependency
|
172
213
|
name: mdl
|
173
214
|
requirement: !ruby/object:Gem::Requirement
|
@@ -211,10 +252,10 @@ email:
|
|
211
252
|
executables: []
|
212
253
|
extensions: []
|
213
254
|
extra_rdoc_files:
|
214
|
-
- README.md
|
215
255
|
- CHANGELOG.md
|
216
256
|
- CONTRIBUTING.md
|
217
257
|
- LICENSE.md
|
258
|
+
- README.md
|
218
259
|
files:
|
219
260
|
- CHANGELOG.md
|
220
261
|
- CONTRIBUTING.md
|
@@ -222,8 +263,9 @@ files:
|
|
222
263
|
- README.md
|
223
264
|
- config.gemspec
|
224
265
|
- lib/config.rb
|
225
|
-
- lib/config/compatibility.rb
|
226
266
|
- lib/config/configuration.rb
|
267
|
+
- lib/config/dry_validation_requirements.rb
|
268
|
+
- lib/config/error.rb
|
227
269
|
- lib/config/integrations/heroku.rb
|
228
270
|
- lib/config/integrations/rails/railtie.rb
|
229
271
|
- lib/config/integrations/sinatra.rb
|
@@ -247,9 +289,11 @@ files:
|
|
247
289
|
homepage: https://github.com/rubyconfig/config
|
248
290
|
licenses:
|
249
291
|
- MIT
|
250
|
-
metadata:
|
251
|
-
|
252
|
-
|
292
|
+
metadata:
|
293
|
+
changelog_uri: https://github.com/rubyconfig/config/blob/master/CHANGELOG.md
|
294
|
+
funding_uri: https://opencollective.com/rubyconfig/donate
|
295
|
+
source_code_uri: https://github.com/rubyconfig/config
|
296
|
+
bug_tracker_uri: https://github.com/rubyconfig/config/issues
|
253
297
|
rdoc_options:
|
254
298
|
- "--charset=UTF-8"
|
255
299
|
require_paths:
|
@@ -265,8 +309,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
265
309
|
- !ruby/object:Gem::Version
|
266
310
|
version: '0'
|
267
311
|
requirements: []
|
268
|
-
rubygems_version: 3.
|
269
|
-
signing_key:
|
312
|
+
rubygems_version: 3.6.9
|
270
313
|
specification_version: 4
|
271
314
|
summary: Effortless multi-environment settings in Rails, Sinatra, Padrino and others
|
272
315
|
test_files: []
|
data/lib/config/compatibility.rb
DELETED