config 1.7.2 → 2.2.3

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: 7819e4fb603d2c59c34576f17235be6467fcd3b7d50776b2c2f3956364af15db
4
- data.tar.gz: 3eb676c4b9e5fdf8f87e366d694f736370d8f6959206c4b8820c4d889e329cb9
3
+ metadata.gz: 2212e68e8bb8e15f821b9420db10ec3111edcaa43bffe5450ae850d5228b3107
4
+ data.tar.gz: de9c513f5a6450a95e113071adf79c3d3b3e2f3485a018e14ab72241a2f419e0
5
5
  SHA512:
6
- metadata.gz: 0a663e08ad559ac60dffe8bed4a085da7630e4b8412db5e4300adad325dc32d82085336ffaf274e529c1d891a46dc9bcee91c1684b0c43668318882ecdc9a1f7
7
- data.tar.gz: e03f1dc386dffedaadc56b6428611c4a0f2d292383b552f4240fe0b0fc5f15a10474f6538c0a1831757031782a2507f1e6c126732d633a0abd79887b799a6e0e
6
+ metadata.gz: ae72b6c10869bbca57d7c476e5ba7b48637b6c94c083176b2c7321710bd4daebe5f41c03d3daf69157dd3f599f63f11d74e19141e98716ae3ef20c8c33469ba3
7
+ data.tar.gz: 07e79c9a667587218a3370c03e912c113795fa00a9f50350065834c91b9d858e03ee1447da078e6ec5af19c32faa5317f3a94b071478d4b96397317504891ac7
@@ -2,94 +2,178 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ...
6
+
7
+ ## 2.2.3
8
+
9
+ ### Bug fixes
10
+
11
+ * Revert added alias to_h for to_hash ([#277](https://github.com/railsconfig/config/issues/277))
12
+
13
+ ### Changes
14
+
15
+ * Raise explicit error on environment variable conflicts ([#293](https://github.com/railsconfig/config/issues/293))
16
+
17
+ ## 2.2.2
18
+
19
+ ### Bug fixes
20
+
21
+ * Added alias to_h for to_hash ([#277](https://github.com/railsconfig/config/issues/277))
22
+ * Prevent unnecessary doubled loading of environment variables ([#291](https://github.com/rubyconfig/config/pull/291))
23
+ * Return `Hash` from `Config::Options#as_json` instead of `Array` of pairs when using ActiveSupport Core Extensions ([#292](https://github.com/rubyconfig/config/pull/292))
24
+
25
+ ### Changes
26
+
27
+ * Add JRuby 9.2 to the test matrix ([#228](https://github.com/railsconfig/config/issues/228))
28
+ * Add exit! to reserved keywords ([#289](https://github.com/railsconfig/config/issues/289))
29
+
30
+ ## 2.2.1
31
+
32
+ ### Performance improvements
33
+
34
+ * Get rid of unused Rails Engine class definition ([#247](https://github.com/rubyconfig/config/pull/247))
35
+ * Require dry-validation only when schema is specified ([#253](https://github.com/rubyconfig/config/pull/253))
36
+ * Defer modification of `ActionController::Base` to when it is loaded in Rails integration ([#250](https://github.com/rubyconfig/config/pull/250))
37
+
38
+ ### Bug fixes
39
+
40
+ * Fix missing new_ostruct_member in Ruby 2.7 ([#255](https://github.com/rubyconfig/config/pull/255))
41
+ * Fix validation contract documentation ([#260](https://github.com/rubyconfig/config/pull/260))
42
+ * Excluded test application's *.md files from the gem build ([#267](https://github.com/rubyconfig/config/pull/267))
43
+
44
+ ### Changes
45
+
46
+ * Use sprockets 3.x when running unit tests for Rails 4.2 ([#256](https://github.com/rubyconfig/config/pull/256))
47
+ * Cleanup example Rails application used for testing ([#263](https://github.com/rubyconfig/config/pull/263))
48
+ * Upgrade markdown linter and fix errors ([#265](https://github.com/rubyconfig/config/pull/265))
49
+ * Upgrade development dependencies and test matrix with latest Ruby and Rails versions ([#264](https://github.com/rubyconfig/config/pull/264))
50
+ * Replace Travis CI with GitHub Actions ([#266](https://github.com/rubyconfig/config/pull/266))
51
+ * Add Rails 6.0 to the test matrix ([#258](https://github.com/rubyconfig/config/pull/258))
52
+ * Rename GitHub organization name from `railsconfig` to `rubyconfig` ([#268](https://github.com/rubyconfig/config/pull/268))
53
+
54
+ ## 2.1.0
55
+
56
+ ### New features
57
+
58
+ * Add dry-validation contract support ([#238](https://github.com/rubyconfig/config/pull/238))
59
+
60
+ ### Changes
61
+
62
+ * Get rid of activesupport dependency ([#230](https://github.com/rubyconfig/config/pull/230))
63
+ * Ignore .local files in test environment ([#135](https://github.com/rubyconfig/config/issues/135), [#233](https://github.com/rubyconfig/config/pull/233))
64
+ * Execute default rspec against latest Rails app and load appropriate development dependencies dynamically ([#241](https://github.com/rubyconfig/config/pull/241))
65
+ * Fix inconsistent documentation for ENV prefix and default value in generator ([#246](https://github.com/rubyconfig/config/pull/246))
66
+
67
+ ### Bug fixes
68
+
69
+ * Fix warnings when running tests in Rails 5 scope ([#240](https://github.com/rubyconfig/config/issues/240)
70
+ * Do not run incompatible code coverage on truffleruby ([#242](https://github.com/rubyconfig/config/issues/242)
71
+
72
+ ## 2.0.0
73
+
74
+ ### BREAKING CHANGES
75
+
76
+ After upgrade to dry-schema 1.0 we had to drop support for Rails `< 4.2` and Ruby `< 2.4`.
77
+ If you need older version of Ruby or Rails, please stick to 1.x version of this gem.
78
+
79
+ ### New features
80
+
81
+ * Add `merge_hash_arrays` as a configuration option ([#214](https://github.com/rubyconfig/config/pull/214))
82
+
83
+ ### Changes
84
+
85
+ * Upgraded dry-validation dependency to dry-schema 1.0 ([#224](https://github.com/rubyconfig/config/pull/224))
86
+ * Moved constant to be defined on `Object` instead of `Kernel` ([#227](https://github.com/rubyconfig/config/issues/227))
87
+ * Add TruffleRuby to the test matrix ([#229](https://github.com/rubyconfig/config/issues/229))
88
+
5
89
  ## 1.7.2
6
90
 
7
91
  ### Bug fixes
8
92
 
9
- * Lock max version of dry-validation depending on the ruby version ([#223](https://github.com/railsconfig/config/pull/223))
93
+ * Lock max version of dry-validation depending on the ruby version ([#223](https://github.com/rubyconfig/config/pull/223))
10
94
 
11
95
  ## 1.7.1
12
96
 
13
97
  ### New features
14
98
 
15
- * Upgrade dependencies ([#211](https://github.com/railsconfig/config/pull/211))
99
+ * Upgrade dependencies ([#211](https://github.com/rubyconfig/config/pull/211))
16
100
 
17
101
  ### Changes
18
102
 
19
- * Add Ruby 2.5 and Rails 5.1 to the testing matrix on Travis ([#201](https://github.com/railsconfig/config/pull/201))
20
- * Add Ruby 2.6 tto the test matrix ([#210](https://github.com/railsconfig/config/pull/210))
21
- * Add Rails 5.2 to the test matrix ([#212](https://github.com/railsconfig/config/pull/212))
103
+ * Add Ruby 2.5 and Rails 5.1 to the testing matrix on Travis ([#201](https://github.com/rubyconfig/config/pull/201))
104
+ * Add Ruby 2.6 to the test matrix ([#210](https://github.com/rubyconfig/config/pull/210))
105
+ * Add Rails 5.2 to the test matrix ([#212](https://github.com/rubyconfig/config/pull/212))
22
106
 
23
107
  ## 1.7.0
24
108
 
25
109
  ### New features
26
110
 
27
- * **WARNING:** `nil` values will from now on overwrite an existing value when merging configs! This change of behavior can be reverted via `config.merge_nil_values = false` in your Config initializer ([#196](https://github.com/railsconfig/config/pull/196))
111
+ * **WARNING:** `nil` values will from now on overwrite an existing value when merging configs! This change of behavior can be reverted via `config.merge_nil_values = false` in your Config initializer ([#196](https://github.com/rubyconfig/config/pull/196))
28
112
 
29
113
  ## 1.6.1
30
114
 
31
115
  ### Bug fixes
32
116
 
33
- * Make dry-validation dependency less strict allowing to use newer versions ([#183](https://github.com/railsconfig/config/pull/183))
34
- * Fix `key?` and `has_key?`, which raise NoMethodError in non Rails environment, by using ActiveSupport `#delegate` implicitly ([#185](https://github.com/railsconfig/config/pull/185))
35
- * Update `deep_merge` dependency to latest version (v1.2.1) ([#191](https://github.com/railsconfig/config/pull/191))
36
- * Upgrade `rubocop` to version 0.52.1 ([#193](https://github.com/railsconfig/config/pull/193))
37
- * Add `zip` to the list of reserved keywords ([#197](https://github.com/railsconfig/config/pull/197))
117
+ * Make dry-validation dependency less strict allowing to use newer versions ([#183](https://github.com/rubyconfig/config/pull/183))
118
+ * Fix `key?` and `has_key?`, which raise NoMethodError in non Rails environment, by using ActiveSupport `#delegate` implicitly ([#185](https://github.com/rubyconfig/config/pull/185))
119
+ * Update `deep_merge` dependency to latest version (v1.2.1) ([#191](https://github.com/rubyconfig/config/pull/191))
120
+ * Upgrade `rubocop` to version 0.52.1 ([#193](https://github.com/rubyconfig/config/pull/193))
121
+ * Add `zip` to the list of reserved keywords ([#197](https://github.com/rubyconfig/config/pull/197))
38
122
 
39
123
  ## 1.6.0
40
124
 
41
125
  ### New features
42
126
 
43
127
  * `Config#fail_on_missing` option (default `false`) to raise a `KeyError` exception when accessing a non-existing key
44
- * Add ability to test if a value was set for a given key with `key?` and `has_key?` ([#182](https://github.com/railsconfig/config/pull/182))
128
+ * Add ability to test if a value was set for a given key with `key?` and `has_key?` ([#182](https://github.com/rubyconfig/config/pull/182))
45
129
 
46
130
  ## 1.5.1
47
131
 
48
132
  ### New features
49
133
 
50
- * Add parsing of ENV variable values to Boolean type ([#180](https://github.com/railsconfig/config/pull/180))
134
+ * Add parsing of ENV variable values to Boolean type ([#180](https://github.com/rubyconfig/config/pull/180))
51
135
 
52
136
  ## 1.5.0
53
137
 
54
138
  ### New features
55
139
 
56
- * Add ability to validate config schema ([#155](https://github.com/railsconfig/config/pull/155) thanks to [@ok32](https://github.com/ok32))
57
- * Add count to the reserved names list ([#167](https://github.com/railsconfig/config/pull/167) thanks to [@carbonin](https://github.com/carbonin))
140
+ * Add ability to validate config schema ([#155](https://github.com/rubyconfig/config/pull/155) thanks to [@ok32](https://github.com/ok32))
141
+ * Add count to the reserved names list ([#167](https://github.com/rubyconfig/config/pull/167) thanks to [@carbonin](https://github.com/carbonin))
58
142
 
59
143
  ### Bug fixes
60
144
 
61
- * Correctly parse `env_prefix`, which contains `env_separator` ([#177](https://github.com/railsconfig/config/pull/177) thanks to [@rdodson41](https://github.com/rdodson41))
145
+ * Correctly parse `env_prefix`, which contains `env_separator` ([#177](https://github.com/rubyconfig/config/pull/177) thanks to [@rdodson41](https://github.com/rdodson41))
62
146
 
63
147
  ## 1.4.0
64
148
 
65
149
  ### New features
66
150
 
67
- * Added support for passing a raw ruby hash into to both `Settings.add_source!` and `Settings.prepend_source!` ([#108](https://github.com/railsconfig/config/pull/159) thanks to [@halloffame](https://github.com/halloffame))
151
+ * Added support for passing a raw ruby hash into to both `Settings.add_source!` and `Settings.prepend_source!` ([#108](https://github.com/rubyconfig/config/pull/159) thanks to [@halloffame](https://github.com/halloffame))
68
152
 
69
153
  ### Bug fixes
70
154
 
71
- * Added new reserved name `test` ([#158](https://github.com/railsconfig/config/pull/158) thanks to [@milushov](https://github.com/milushov))
72
- * `to_hash` should not replace nested config objects with Hash ([#160](https://github.com/railsconfig/config/issues/160) thanks to [@seikichi](https://github.com/seikichi))
155
+ * Added new reserved name `test` ([#158](https://github.com/rubyconfig/config/pull/158) thanks to [@milushov](https://github.com/milushov))
156
+ * `to_hash` should not replace nested config objects with Hash ([#160](https://github.com/rubyconfig/config/issues/160) thanks to [@seikichi](https://github.com/seikichi))
73
157
 
74
158
  ## 1.3.0
75
159
 
76
- * **WARNING:** Overwrite arrays found in previously loaded settings file ([#137](https://github.com/railsconfig/config/pull/137) thanks to [@Fryguy](https://github.com/Fryguy) and [@dtaniwaki](https://github.com/dtaniwaki)) - this is a change breaking previous behaviour. If you want to keep Config to work as before, which is merging arrays found in following loaded settings file, please add `config.overwrite_arrays = false` to your Config initializer
160
+ * **WARNING:** Overwrite arrays found in previously loaded settings file ([#137](https://github.com/rubyconfig/config/pull/137) thanks to [@Fryguy](https://github.com/Fryguy) and [@dtaniwaki](https://github.com/dtaniwaki)) - this is a change breaking previous behaviour. If you want to keep Config to work as before, which is merging arrays found in following loaded settings file, please add `config.overwrite_arrays = false` to your Config initializer
77
161
  * Changed default ENV variables loading settings to downcase variable names and parse values
78
162
  * Added parsing ENV variables values to Float type
79
- * Change method definition order in Rails integration module to prevent undefined method `preload` error (based on [@YaroSpace](https://github.com/YaroSpace) suggestion in [#111](https://github.com/railsconfig/config/issues/111)
163
+ * Change method definition order in Rails integration module to prevent undefined method `preload` error (based on [@YaroSpace](https://github.com/YaroSpace) suggestion in [#111](https://github.com/rubyconfig/config/issues/111)
80
164
 
81
165
  ## 1.2.1
82
166
 
83
- * Fixed support for multilevel settings loaded from ENV variables (inspired by [@cbeer](https://github.com/cbeer) in [#144](https://github.com/railsconfig/config/pull/144))
167
+ * Fixed support for multilevel settings loaded from ENV variables (inspired by [@cbeer](https://github.com/cbeer) in [#144](https://github.com/rubyconfig/config/pull/144))
84
168
 
85
169
  ## 1.2.0
86
170
 
87
- * Add ability to load settings from ENV variables ([#108](https://github.com/railsconfig/config/issues/108) thanks to [@vinceve](https://github.com/vinceve) and [@spalladino](https://github.com/spalladino))
88
- * Removed Rails 5 deprecation warnings for prepend_before_filter ([#141](https://github.com/railsconfig/config/pull/141))
171
+ * Add ability to load settings from ENV variables ([#108](https://github.com/rubyconfig/config/issues/108) thanks to [@vinceve](https://github.com/vinceve) and [@spalladino](https://github.com/spalladino))
172
+ * Removed Rails 5 deprecation warnings for prepend_before_filter ([#141](https://github.com/rubyconfig/config/pull/141))
89
173
 
90
174
  ## 1.1.1
91
175
 
92
- * Downgrade minimum ruby version to 2.0.0 ([#136](https://github.com/railsconfig/config/issues/136))
176
+ * Downgrade minimum ruby version to 2.0.0 ([#136](https://github.com/rubyconfig/config/issues/136))
93
177
 
94
178
  ## 1.1.0
95
179
 
@@ -98,12 +182,12 @@
98
182
 
99
183
  ## 1.0.0
100
184
 
101
- * `RailsConfig` is now officially renamed to `Config`
102
- * Fixed array descent when converting to hash ([#89](https://github.com/railsconfig/config/pull/89))
103
- * Catch OpenStruct reserved keywords ([#95](https://github.com/railsconfig/config/pull/95) by [@dudo](https://github.com/dudo))
104
- * Allows loading before app configuration process ([#107](https://github.com/railsconfig/config/pull/107) by [@Antiarchitect](https://github.com/Antiarchitect))
105
- * `deep_merge` is now properly managed via gemspec ([#110](https://github.com/railsconfig/config/pull/110))
106
- * Added `prepend_source!` ([#102](https://github.com/railsconfig/config/pull/102))
185
+ * `rubyconfig` is now officially renamed to `Config`
186
+ * Fixed array descent when converting to hash ([#89](https://github.com/rubyconfig/config/pull/89))
187
+ * Catch OpenStruct reserved keywords ([#95](https://github.com/rubyconfig/config/pull/95) by [@dudo](https://github.com/dudo))
188
+ * Allows loading before app configuration process ([#107](https://github.com/rubyconfig/config/pull/107) by [@Antiarchitect](https://github.com/Antiarchitect))
189
+ * `deep_merge` is now properly managed via gemspec ([#110](https://github.com/rubyconfig/config/pull/110))
190
+ * Added `prepend_source!` ([#102](https://github.com/rubyconfig/config/pull/102))
107
191
 
108
192
  ## 0.99
109
193
 
@@ -0,0 +1,32 @@
1
+ # Contributing
2
+
3
+ Install appraisal
4
+
5
+ ```bash
6
+ gem install bundler -v 1.17.3
7
+ gem install appraisal
8
+ ```
9
+
10
+ Bundle
11
+
12
+ ```bash
13
+ bundle install
14
+ ```
15
+
16
+ Bootstrap
17
+
18
+ ```bash
19
+ appraisal install
20
+ ```
21
+
22
+ Run the test suite:
23
+
24
+ ```bash
25
+ appraisal rspec
26
+ ```
27
+
28
+ If you modified any of the documentation files verify their format:
29
+
30
+ ```bash
31
+ mdl *.md
32
+ ```
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Config
2
2
 
3
- [![Build Status](https://api.travis-ci.org/railsconfig/config.svg?branch=master)](http://travis-ci.org/railsconfig/config)
4
3
  [![Gem Version](https://badge.fury.io/rb/config.svg)](http://badge.fury.io/rb/config)
5
- [![Dependency Status](https://gemnasium.com/railsconfig/config.svg)](https://gemnasium.com/railsconfig/config)
6
- [![Maintainability](https://api.codeclimate.com/v1/badges/85c206c13dce7de090af/maintainability)](https://codeclimate.com/github/railsconfig/config/maintainability)
7
- [![Test Coverage](https://api.codeclimate.com/v1/badges/85c206c13dce7de090af/test_coverage)](https://codeclimate.com/github/railsconfig/config/test_coverage)
4
+ [![Tests](https://github.com/rubyconfig/config/workflows/tests/badge.svg)](https://github.com/rubyconfig/config/actions?query=branch%3Amaster)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/85c206c13dce7de090af/maintainability)](https://codeclimate.com/github/rubyconfig/config/maintainability)
6
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/85c206c13dce7de090af/test_coverage)](https://codeclimate.com/github/rubyconfig/config/test_coverage)
7
+ [![Financial Contributors on Open Collective](https://opencollective.com/rubyconfig/all/badge.svg?label=backers)](https://opencollective.com/rubyconfig)
8
8
 
9
9
  ## Summary
10
10
 
@@ -21,16 +21,22 @@ Config helps you easily manage environment specific settings in an easy and usab
21
21
 
22
22
  ## Compatibility
23
23
 
24
- * Ruby `2.x`
25
- * Rails `>= 3.1`, `4` and `5`
26
- * Padrino
27
- * Sinatra
24
+ Current version supports and is [tested](.github/workflows/tests.yml#L19) for the following interpreters and frameworks:
28
25
 
29
- For older versions of Rails or Ruby use [AppConfig](http://github.com/fredwu/app_config).
26
+ * Interpreters
27
+ * [Ruby](https://www.ruby-lang.org) `>= 2.4`
28
+ * [JRuby](https://www.jruby.org) `>= 9.2`
29
+ * [TruffleRuby](https://github.com/oracle/truffleruby) `>= 19.3`
30
+ * Application frameworks
31
+ * Rails `>= 4.2`, `5` and `6`
32
+ * Padrino
33
+ * Sinatra
34
+
35
+ 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).
30
36
 
31
37
  ## Installing
32
38
 
33
- ### Installing on Rails 3, 4 or 5
39
+ ### Installing on Rails
34
40
 
35
41
  Add `gem 'config'` to your `Gemfile` and run `bundle install` to install it. Then run
36
42
 
@@ -39,6 +45,7 @@ Add `gem 'config'` to your `Gemfile` and run `bundle install` to install it. The
39
45
  which will generate customizable config file `config/initializers/config.rb` and set of default settings files:
40
46
 
41
47
  config/settings.yml
48
+ config/settings.local.yml
42
49
  config/settings/development.yml
43
50
  config/settings/production.yml
44
51
  config/settings/test.yml
@@ -55,8 +62,7 @@ register Config
55
62
 
56
63
  ### Installing on Sinatra
57
64
 
58
- Add the gem to your `Gemfile` and run `bundle install` to install it. Afterwards in need to register `Config` in your
59
- app and give it a root so it can find the config files.
65
+ Add the gem to your `Gemfile` and run `bundle install` to install it. Afterwards in need to register `Config` in your app and give it a root so it can find the config files.
60
66
 
61
67
  ```ruby
62
68
  set :root, File.dirname(__FILE__)
@@ -65,15 +71,13 @@ register Config
65
71
 
66
72
  ### Installing on other ruby projects
67
73
 
68
- Add the gem to your `Gemfile` and run `bundle install` to install it.
69
- Then initialize `Config` manually within your configure block.
74
+ Add the gem to your `Gemfile` and run `bundle install` to install it. Then initialize `Config` manually within your configure block.
70
75
 
71
76
  ```ruby
72
77
  Config.load_and_set_settings(Config.setting_files("/path/to/config_root", "your_project_environment"))
73
78
  ```
74
79
 
75
- It's also possible to initialize `Config` manually within your configure block if you want to just give it some yml
76
- paths to load from.
80
+ It's also possible to initialize `Config` manually within your configure block if you want to just give it some yml paths to load from.
77
81
 
78
82
  ```ruby
79
83
  Config.load_and_set_settings("/path/to/yaml1", "/path/to/yaml2", ...)
@@ -81,8 +85,7 @@ Config.load_and_set_settings("/path/to/yaml1", "/path/to/yaml2", ...)
81
85
 
82
86
  ## Accessing the Settings object
83
87
 
84
- After installing the gem, `Settings` object will become available globally and by default will be compiled from the
85
- files listed below. Settings defined in files that are lower in the list override settings higher.
88
+ After installing the gem, `Settings` object will become available globally and by default will be compiled from the files listed below. Settings defined in files that are lower in the list override settings higher.
86
89
 
87
90
  config/settings.yml
88
91
  config/settings/#{environment}.yml
@@ -134,8 +137,7 @@ Settings.reload_from_files(
134
137
 
135
138
  ### Environment specific config files
136
139
 
137
- You can have environment specific config files. Environment specific config entries take precedence over common config
138
- entries.
140
+ You can have environment specific config files. Environment specific config entries take precedence over common config entries.
139
141
 
140
142
  Example development environment config file:
141
143
 
@@ -151,8 +153,7 @@ Example production environment config file:
151
153
 
152
154
  ### Developer specific config files
153
155
 
154
- If you want to have local settings, specific to your machine or development environment,
155
- you can use the following files, which are automatically `.gitignore` :
156
+ If you want to have local settings, specific to your machine or development environment, you can use the following files, which are automatically `.gitignore` :
156
157
 
157
158
  ```ruby
158
159
  Rails.root.join("config", "settings.local.yml").to_s,
@@ -160,6 +161,8 @@ Rails.root.join("config", "settings", "#{Rails.env}.local.yml").to_s,
160
161
  Rails.root.join("config", "environments", "#{Rails.env}.local.yml").to_s
161
162
  ```
162
163
 
164
+ **NOTE:** The file `settings.local.yml` will not be loaded in tests to prevent local configuration from causing flaky or non-deterministic tests. Environment-specific files (e.g. `settings/test.local.yml`) will still be loaded to allow test-specific credentials.
165
+
163
166
  ### Adding sources at runtime
164
167
 
165
168
  You can add new YAML config files at runtime. Just use:
@@ -178,19 +181,18 @@ Settings.prepend_source!("/path/to/source.yml")
178
181
  Settings.reload!
179
182
  ```
180
183
 
181
- This will do the same as `add_source`, but the given YML file will be loaded first (instead of last) and its settings
182
- will be overwritten by any other configuration file. This is especially useful if you want to define defaults.
184
+ This will do the same as `add_source`, but the given YML file will be loaded first (instead of last) and its settings will be overwritten by any other configuration file. This is especially useful if you want to define defaults.
183
185
 
184
- One thing I like to do for my Rails projects is provide a local.yml config file that is .gitignored (so its independent
185
- per developer). Then I create a new initializer in `config/initializers/add_local_config.rb` with the contents
186
+ One thing I like to do for my Rails projects is provide a local.yml config file that is .gitignored (so its independent per developer). Then I create a new initializer in `config/initializers/add_local_config.rb` with the contents
186
187
 
187
188
  ```ruby
188
189
  Settings.add_source!("#{Rails.root}/config/settings/local.yml")
189
190
  Settings.reload!
190
191
  ```
191
192
 
192
- > Note: this is an example usage, it is easier to just use the default local files `settings.local.yml,
193
- settings/#{Rails.env}.local.yml and environments/#{Rails.env}.local.yml` for your developer specific settings.
193
+ > Note: this is an example usage, it is easier to just use the default local
194
+ > files `settings.local.yml`, `settings/#{Rails.env}.local.yml` and
195
+ > `environments/#{Rails.env}.local.yml` for your developer specific settings.
194
196
 
195
197
  You also have the option to add a raw hash as a source. One use case might be storing settings in the database or in environment variables that overwrite what is in the YML files.
196
198
 
@@ -250,18 +252,16 @@ Settings.section.servers[1].name # => amazon.com
250
252
 
251
253
  ## Configuration
252
254
 
253
- There are multiple configuration options available, however you can customize `Config` only once, preferably during
254
- application initialization phase:
255
+ There are multiple configuration options available, however you can customize `Config` only once, preferably during application initialization phase:
255
256
 
256
257
  ```ruby
257
258
  Config.setup do |config|
258
259
  config.const_name = 'Settings'
259
- ...
260
+ # ...
260
261
  end
261
262
  ```
262
263
 
263
- After installing `Config` in Rails, you will find automatically generated file that contains default configuration
264
- located at `config/initializers/config.rb`.
264
+ After installing `Config` in Rails, you will find automatically generated file that contains default configuration located at `config/initializers/config.rb`.
265
265
 
266
266
  ### General
267
267
 
@@ -270,6 +270,7 @@ located at `config/initializers/config.rb`.
270
270
  ### Merge customization
271
271
 
272
272
  * `overwrite_arrays` - overwrite arrays found in previously loaded settings file. Default: `true`
273
+ * `merge_hash_arrays` - merge hashes inside of arrays from previously loaded settings files. Makes sense only when `overwrite_arrays = false`. Default: `false`
273
274
  * `knockout_prefix` - ability to remove elements of the array set in earlier loaded settings file. Makes sense only when `overwrite_arrays = false`, otherwise array settings would be overwritten by default. Default: `nil`
274
275
  * `merge_nil_values` - `nil` values will overwrite an existing value when merging configs. Default: `true`.
275
276
 
@@ -297,12 +298,52 @@ Check [Deep Merge](https://github.com/danielsdeleo/deep_merge) for more details.
297
298
 
298
299
  ### Validation
299
300
 
300
- With Ruby 2.1 or newer, you can optionally define a schema to validate presence (and type) of specific config values:
301
+ With Ruby 2.1 or newer, you can optionally define a [schema](https://github.com/dry-rb/dry-schema) or [contract](https://github.com/dry-rb/dry-validation) (added in `config-2.1`) using [dry-rb](https://github.com/dry-rb) to validate presence (and type) of specific config values. Generally speaking contracts allow to describe more complex validations with depencecies between fields.
302
+
303
+ If you provide either validation option (or both) it will automatically be used to validate your config. If validation fails it will raise a `Config::Validation::Error` containing information about all the mismatches between the schema and your config.
304
+
305
+ Both examples below demonstrates how to ensure that the configuration has an optional `email` and the `youtube` structure with the `api_key` field filled. The contract adds an additional rule.
306
+
307
+ #### Contract
308
+
309
+ Leverage dry-validation, you can create a contract with a params schema and rules:
310
+
311
+ ```ruby
312
+ class ConfigContract < Dry::Validation::Contract
313
+ params do
314
+ optional(:email).maybe(:str?)
315
+
316
+ required(:youtube).schema do
317
+ required(:api_key).filled
318
+ end
319
+ end
320
+
321
+ rule(:email) do
322
+ unless /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i.match?(value)
323
+ key.failure('has invalid format')
324
+ end
325
+ end
326
+ end
327
+
328
+ Config.setup do |config|
329
+ config.validation_contract = ConfigContract.new
330
+ end
331
+ ```
332
+
333
+ The above example adds a rule to ensure the `email` is valid by matching it against the provided regular expression.
334
+
335
+ Check [dry-validation](https://github.com/dry-rb/dry-validation) for more details.
336
+
337
+ #### Schema
338
+
339
+ You may also specify a schema using [dry-schema](https://github.com/dry-rb/dry-schema):
301
340
 
302
341
  ```ruby
303
342
  Config.setup do |config|
304
343
  # ...
305
344
  config.schema do
345
+ optional(:email).maybe(:str?)
346
+
306
347
  required(:youtube).schema do
307
348
  required(:api_key).filled
308
349
  end
@@ -310,14 +351,7 @@ Config.setup do |config|
310
351
  end
311
352
  ```
312
353
 
313
- The above example demonstrates how to ensure that the configuration has the `youtube` structure
314
- with the `api_key` field filled.
315
-
316
- If you define a schema it will automatically be used to validate your config. If validation fails it will
317
- raise a `Config::Validation::Error` containing a nice message with information about all the mismatches
318
- between the schema and your config.
319
-
320
- Check [dry-validation](https://github.com/dry-rb/dry-validation) for more details.
354
+ Check [dry-schema](https://github.com/dry-rb/dry-schema) for more details.
321
355
 
322
356
  ### Missing keys
323
357
 
@@ -368,8 +402,7 @@ See section below for more details.
368
402
 
369
403
  ## Working with environment variables
370
404
 
371
- To load environment variables from the `ENV` object, that will override any settings defined in files, set the `use_env`
372
- to true in your `config/initializers/config.rb` file:
405
+ To load environment variables from the `ENV` object, that will override any settings defined in files, set the `use_env` to true in your `config/initializers/config.rb` file:
373
406
 
374
407
  ```ruby
375
408
  Config.setup do |config|
@@ -378,8 +411,7 @@ Config.setup do |config|
378
411
  end
379
412
  ```
380
413
 
381
- Now config would read values from the ENV object to the settings. For the example above it would look for keys starting
382
- with `Settings`:
414
+ Now config would read values from the ENV object to the settings. For the example above it would look for keys starting with `Settings`:
383
415
 
384
416
  ```ruby
385
417
  ENV['Settings.section.size'] = 1
@@ -388,11 +420,24 @@ ENV['Settings.section.server'] = 'google.com'
388
420
 
389
421
  It won't work with arrays, though.
390
422
 
423
+ It is considered an error to use environment variables to simutaneously assign a "flat" value and a multi-level value to a key.
424
+
425
+ ```ruby
426
+ # Raises an error when settings are loaded
427
+ ENV['BACKEND_DATABASE'] = 'development'
428
+ ENV['BACKEND_DATABASE_USER'] = 'postgres'
429
+ ```
430
+
431
+ Instead, specify keys of equal depth in the environment variable names:
432
+
433
+ ```ruby
434
+ ENV['BACKEND_DATABASE_NAME'] = 'development'
435
+ ENV['BACKEND_DATABASE_USER'] = 'postgres'
436
+ ```
437
+
391
438
  ### Working with Heroku
392
439
 
393
- Heroku uses ENV object to store sensitive settings. You cannot upload such files to Heroku because it's ephemeral
394
- filesystem gets recreated from the git sources on each instance refresh. To use config with Heroku just set the
395
- `use_env` var to `true` as mentioned above.
440
+ Heroku uses ENV object to store sensitive settings. You cannot upload such files to Heroku because it's ephemeral filesystem gets recreated from the git sources on each instance refresh. To use config with Heroku just set the `use_env` var to `true` as mentioned above.
396
441
 
397
442
  To upload your local values to Heroku you could ran `bundle exec rake config:heroku`.
398
443
 
@@ -400,10 +445,8 @@ To upload your local values to Heroku you could ran `bundle exec rake config:her
400
445
 
401
446
  You can customize how environment variables are processed:
402
447
 
403
- * `env_prefix` (default: `SETTINGS`) - which ENV variables to load into config
404
- * `env_separator` (default: `.`) - what string to use as level separator - default value of `.` works well with
405
- Heroku, but you might want to change it for example for `__` to easy override settings from command line, where using
406
- dots in variable names might not be allowed (eg. Bash)
448
+ * `env_prefix` (default: `const_name`) - load only ENV variables starting with this prefix (case-sensitive)
449
+ * `env_separator` (default: `'.'`) - what string to use as level separator - default value of `.` works well with Heroku, but you might want to change it for example for `__` to easy override settings from command line, where using dots in variable names might not be allowed (eg. Bash)
407
450
  * `env_converter` (default: `:downcase`) - how to process variables names:
408
451
  * `nil` - no change
409
452
  * `:downcase` - convert to lower case
@@ -439,38 +482,39 @@ Settings.section.ssl_enabled # => false
439
482
 
440
483
  ## Contributing
441
484
 
442
- Install appraisal
485
+ You are very warmly welcome to help. Please follow our [contribution guidelines](CONTRIBUTING.md)
443
486
 
444
- ```bash
445
- gem install bundler -v 1.17.3
446
- gem install appraisal
447
- ```
487
+ 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.
448
488
 
449
- Bootstrap
489
+ ## Authors
450
490
 
451
- ```bash
452
- appraisal install
453
- ```
491
+ * [Piotr Kuczynski](http://github.com/pkuczynski)
492
+ * [Fred Wu](http://github.com/fredwu)
493
+ * [Jacques Crocker](http://github.com/railsjedi)
494
+ * Inherited from [AppConfig](http://github.com/cjbottaro/app_config) by [Christopher J. Bottaro](http://github.com/cjbottaro)
454
495
 
455
- Run the test suite:
496
+ ## Contributors
456
497
 
457
- ```bash
458
- appraisal rspec
459
- ```
498
+ ### Code Contributors
460
499
 
461
- If you modified any of the documentation files verify their format:
500
+ This project exists thanks to all the people who contribute and you are very warmly welcome to help. Please follow our [contribution guidelines](CONTRIBUTING.md).
462
501
 
463
- ```bash
464
- mdl --style .mdlstyle.rb *.md
465
- ```
502
+ Any and all contributions offered in any form, past present or future are understood to be in complete agreement and acceptance with the [MIT](LICENSE) license.
466
503
 
467
- ## Authors
504
+ [![Contributors](https://opencollective.com/rubyconfig/contributors.svg?width=890&button=false)](https://github.com/rubyconfig/config/graphs/contributors)
468
505
 
469
- * [Piotr Kuczynski](http://github.com/pkuczynski)
470
- * [Fred Wu](http://github.com/fredwu)
471
- * [Jacques Crocker](http://github.com/railsjedi)
472
- * Inherited from [AppConfig](http://github.com/cjbottaro/app_config) by [Christopher J. Bottaro](http://github.com/cjbottaro)
506
+ ### Financial Contributors
507
+
508
+ [Become a backer](https://opencollective.com/rubyconfig#backer) and support us with a small monthly donation to help us continue our activities. Thank you if you already one! 🙏
509
+
510
+ [![Backers](https://opencollective.com/rubyconfig/backers.svg?width=890)](https://opencollective.com/rubyconfig)
511
+
512
+ #### Sponsors
513
+
514
+ Support this project by becoming a [sponsor](https://opencollective.com/rubyconfig#sponsor). Your logo will show up here with a link to your website.
515
+
516
+ [![Sponsors](https://opencollective.com/rubyconfig/sponsors.svg?width=890)](https://opencollective.com/rubyconfig)
473
517
 
474
518
  ## License
475
519
 
476
- Config is released under the [MIT License](http://www.opensource.org/licenses/MIT).
520
+ Copyright (C) Piotr Kuczynski. Released under the [MIT License](LICENSE.md).