anyway_config 2.0.6 → 2.1.0

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: b3fcc40e50bfd285e686ca346ff5ddb3f4039104f1b5a79a8a4dd305d5d53707
4
- data.tar.gz: 1f43073daee8706d7c9be2161bd226cb07f04a92929e6cdd81d64c8303f029da
3
+ metadata.gz: ae67246988f82692f84ae07b01642fbca38c9f1593b0e4292b335e08654bbf7e
4
+ data.tar.gz: 045f36927093f3e7929889918dff12d63c61ef58ffcb5fc5793f017dd2da1c5e
5
5
  SHA512:
6
- metadata.gz: 8125fbf4c4c592f673eca184d74ec3e02e1217016e4fa5a5d6371a24d13b9b092c48220dcd0bc57e33cbf7b0b28f0a1f5d2b9ce4c2f33aba42506e3444855bc9
7
- data.tar.gz: 5076ec06d2dd7acbcb8a002653eb5e8df80a666ef83e7820d9ba9dd19103ac70db9560c818774bc8d8a26ea5f4b67b929c9e192c487f3e1785a5ed3f0d85b00a
6
+ metadata.gz: de0f8281daad0d2da4ad557f7099602a46d7fa4476f0a3adfb5b7f14c3abcd44fd020a89fd661a4c9ebeb9b5e70550d37f1b16d01bf68d535ab63877b9ae1661
7
+ data.tar.gz: 04de1b39c49b4dc39faa12ee199143ca64b3722cbc547e8c41b41bc3e7e365848bae2f06dfc9f99db5693782df4239cd5bbdca99cf2e58e50f38147b2b5dc95e
@@ -1,5 +1,37 @@
1
1
  # Change log
2
2
 
3
+ ## master
4
+
5
+ ## 2.1.0 (2020-12-29)
6
+
7
+ - Drop deprecated `attr_config` instance variables support.
8
+
9
+ Config setters no longer write instance variables.
10
+
11
+ - Add `config.anyway_config.future` to allow enabling upcoming features. ([@palkan][])
12
+
13
+ For smoother upgrades, we provide a mechanism to opt-out to the new defaults beforehand.
14
+ Currently, only `:unwrap_known_environments` feature could be enabled (see below):
15
+
16
+ ```ruby
17
+ config.anyway_config.future.use :unwrap_known_environments
18
+ ```
19
+
20
+ - Allow to skip environment keys completely (e.g., `development:`, `test:`) in a config YML when used with Rails. In that case same config is loaded in all known environments (same mechanism as for non-Rails applications)
21
+
22
+ - Add the `known_environments` property to Anyway::Settings under Rails. Use `config.anyway_config.known_environments << "staging"` to make the gem aware of custom environments. ([@progapandist][])
23
+
24
+ - Make it possible to specify default YML configs directory. ([@palkan][])
25
+
26
+ For example:
27
+
28
+ ```ruby
29
+ Anyway::Settings.default_config_path = "path/to/configs"
30
+
31
+ # or in Rails
32
+ config.anyway_config.default_config_path = Rails.root.join("my/configs")
33
+ ```
34
+
3
35
  ## 2.0.6 (2020-07-7)
4
36
 
5
37
  - Fix Ruby 2.7 warnings. ([@palkan][])
@@ -20,13 +52,13 @@
20
52
 
21
53
  - Make sure configs are eager loaded in Rails when `config.eager_load = true`. ([@palkan][])
22
54
 
23
- Fixes [#58](https://github.com/palkan/anyway_config/issues/58).
55
+ Fixes [#58](https://github.com/palkan/anyway_config/issues/58).
24
56
 
25
57
  ## 2.0.1 (2020-04-15)
26
58
 
27
59
  - Fix loading Railtie when application has been already initialized. ([@palkan][])
28
60
 
29
- Fixes [#56](https://github.com/palkan/anyway_config/issues/56).
61
+ Fixes [#56](https://github.com/palkan/anyway_config/issues/56).
30
62
 
31
63
  ## 2.0.0 (2020-04-14)
32
64
 
@@ -36,166 +68,166 @@
36
68
 
37
69
  - Add predicate methods for attributes with boolean defaults. ([@palkan][])
38
70
 
39
- For example:
71
+ For example:
40
72
 
41
- ```ruby
42
- class MyConfig < Anyway::Config
43
- attr_config :key, :secret, debug: false
44
- end
73
+ ```ruby
74
+ class MyConfig < Anyway::Config
75
+ attr_config :key, :secret, debug: false
76
+ end
45
77
 
46
- MyConfig.new.debug? #=> false
47
- MyConfig.new(debug: true).debug? #=> true
48
- ```
78
+ MyConfig.new.debug? #=> false
79
+ MyConfig.new(debug: true).debug? #=> true
80
+ ```
49
81
 
50
82
  - Add `Config#deconstruct_keys`. ([@palkan][])
51
83
 
52
- Now you can use configs in pattern matching:
84
+ Now you can use configs in pattern matching:
53
85
 
54
- ```ruby
55
- case AWSConfig.new
56
- in bucket:, region: "eu-west-1"
57
- setup_eu_storage(bucket)
58
- in bucket:, region: "us-east-1"
59
- setup_us_storage(bucket)
60
- end
61
- ```
86
+ ```ruby
87
+ case AWSConfig.new
88
+ in bucket:, region: "eu-west-1"
89
+ setup_eu_storage(bucket)
90
+ in bucket:, region: "us-east-1"
91
+ setup_us_storage(bucket)
92
+ end
93
+ ```
62
94
 
63
95
  - Add pretty_print support. ([@palkan][])
64
96
 
65
- Whenever you use `pp`, the output would contain pretty formatted config information
66
- including the sources.
97
+ Whenever you use `pp`, the output would contain pretty formatted config information
98
+ including the sources.
67
99
 
68
- Example:
100
+ Example:
69
101
 
70
- ```ruby
71
- pp CoolConfig.new
102
+ ```ruby
103
+ pp CoolConfig.new
72
104
 
73
- # #<CoolConfig
74
- # config_name="cool"
75
- # env_prefix="COOL"
76
- # values:
77
- # port => 3334 (type=load),
78
- # host => "test.host" (type=yml path=./config/cool.yml),
79
- # user =>
80
- # name => "john" (type=env key=COOL_USER__NAME),
81
- # password => "root" (type=yml path=./config/cool.yml)>
82
- ```
105
+ # #<CoolConfig
106
+ # config_name="cool"
107
+ # env_prefix="COOL"
108
+ # values:
109
+ # port => 3334 (type=load),
110
+ # host => "test.host" (type=yml path=./config/cool.yml),
111
+ # user =>
112
+ # name => "john" (type=env key=COOL_USER__NAME),
113
+ # password => "root" (type=yml path=./config/cool.yml)>
114
+ ```
83
115
 
84
116
  - Add source tracing support. ([@palkan][])
85
117
 
86
- You can get the information on where a particular parameter value came from
87
- (which loader) through via `#to_source_trace` method:
88
-
89
- ```ruby
90
- conf = MyConfig.new
91
- conf.to_source_trace
92
- # {
93
- # "host" => {value: "test.host", source: {type: :user, called_from: "/rails/root/config/application.rb:21"}},
94
- # "user" => {
95
- # "name" => {value: "john", source: {type: :env, key: "COOL_USER__NAME"}},
96
- # "password" => {value: "root", source: {type: :yml, path: "config/cool.yml"}}
97
- # },
98
- # "port" => {value: 9292, source: {type: :defaults}}
99
- # }
100
- ```
118
+ You can get the information on where a particular parameter value came from
119
+ (which loader) through via `#to_source_trace` method:
120
+
121
+ ```ruby
122
+ conf = MyConfig.new
123
+ conf.to_source_trace
124
+ # {
125
+ # "host" => {value: "test.host", source: {type: :user, called_from: "/rails/root/config/application.rb:21"}},
126
+ # "user" => {
127
+ # "name" => {value: "john", source: {type: :env, key: "COOL_USER__NAME"}},
128
+ # "password" => {value: "root", source: {type: :yml, path: "config/cool.yml"}}
129
+ # },
130
+ # "port" => {value: 9292, source: {type: :defaults}}
131
+ # }
132
+ ```
101
133
 
102
134
  - Change the way Rails configs autoloading works. ([@palkan][])
103
135
 
104
- In Rails 6, autoloading before initialization is [deprecated](https://github.com/rails/rails/commit/3e66ba91d511158e22f90ff96b594d61f40eda01). We can still
105
- make it work by using our own autoloading mechanism (custom Zeitwerk loader).
136
+ In Rails 6, autoloading before initialization is [deprecated](https://github.com/rails/rails/commit/3e66ba91d511158e22f90ff96b594d61f40eda01). We can still
137
+ make it work by using our own autoloading mechanism (custom Zeitwerk loader).
106
138
 
107
- This forces us to use a custom directory (not `app/`) for configs required at the boot time.
108
- By default, we put _static_ configs into `config/configs` but you can still use `app/configs` for
109
- _dynamic_ (runtime) configs.
139
+ This forces us to use a custom directory (not `app/`) for configs required at the boot time.
140
+ By default, we put _static_ configs into `config/configs` but you can still use `app/configs` for
141
+ _dynamic_ (runtime) configs.
110
142
 
111
- **NOTE:** if you used `app/configs` with 2.0.0.preX and relied on configs during initialization,
112
- you can set static configs path to `app/configs`:
143
+ **NOTE:** if you used `app/configs` with 2.0.0.preX and relied on configs during initialization,
144
+ you can set static configs path to `app/configs`:
113
145
 
114
- ```ruby
115
- config.anyway_config.autoload_static_config_path = "app/configs"
116
- ```
146
+ ```ruby
147
+ config.anyway_config.autoload_static_config_path = "app/configs"
148
+ ```
117
149
 
118
- You can do this by running the generator:
150
+ You can do this by running the generator:
119
151
 
120
- ```sh
121
- rails g anyway:install --configs-path=app/configs
122
- ```
152
+ ```sh
153
+ rails g anyway:install --configs-path=app/configs
154
+ ```
123
155
 
124
156
  - Add Rails generators. ([@palkan][])
125
157
 
126
- You can create config classes with the predefined attributes like this:
158
+ You can create config classes with the predefined attributes like this:
127
159
 
128
- ```sh
129
- rails generate config aws access_key_id secret_access_key region
130
- ```
160
+ ```sh
161
+ rails generate config aws access_key_id secret_access_key region
162
+ ```
131
163
 
132
164
  - **BREAKING** The accessors generated by `attr_config` are not longer `attr_accessor`-s. ([@palkan][])
133
165
 
134
- You cannot rely on instance variables anymore. Instead, you can use `super` when overriding accessors or
135
- `values[name]`:
166
+ You cannot rely on instance variables anymore. Instead, you can use `super` when overriding accessors or
167
+ `values[name]`:
136
168
 
137
- ```ruby
138
- attr_config :host, :port, :url, :meta
169
+ ```ruby
170
+ attr_config :host, :port, :url, :meta
139
171
 
140
- # override writer to handle type coercion
141
- def meta=(val)
142
- super JSON.parse(val)
143
- end
172
+ # override writer to handle type coercion
173
+ def meta=(val)
174
+ super JSON.parse(val)
175
+ end
144
176
 
145
- # or override reader to handle missing values
146
- def url
147
- values[:url] ||= "#{host}:#{port}"
148
- end
177
+ # or override reader to handle missing values
178
+ def url
179
+ values[:url] ||= "#{host}:#{port}"
180
+ end
149
181
 
150
- # in <2.1 it's still possible to read instance variables,
151
- # i.e. the following would also work
152
- def url
153
- @url ||= "#{host}:#{port}"
154
- end
155
- ```
182
+ # in <2.1 it's still possible to read instance variables,
183
+ # i.e. the following would also work
184
+ def url
185
+ @url ||= "#{host}:#{port}"
186
+ end
187
+ ```
156
188
 
157
- **NOTE**: we still set instance variables in writers (for backward compatibility), but that would
158
- be removed in 2.1.
189
+ **NOTE**: we still set instance variables in writers (for backward compatibility), but that would
190
+ be removed in 2.1.
159
191
 
160
192
  - Add `Config#dig` method. ([@palkan][])
161
193
 
162
194
  - Add ability to specify types for OptionParser options. ([@palkan][])
163
195
 
164
- ```ruby
165
- describe_options(
166
- concurrency: {
167
- desc: "number of threads to use",
168
- type: String
169
- }
170
- )
171
- ```
196
+ ```ruby
197
+ describe_options(
198
+ concurrency: {
199
+ desc: "number of threads to use",
200
+ type: String
201
+ }
202
+ )
203
+ ```
172
204
 
173
205
  - Add param presence validation. ([@palkan][])
174
206
 
175
- You can specify some params as required, and the validation
176
- error would be raised if they're missing or empty (only for strings):
207
+ You can specify some params as required, and the validation
208
+ error would be raised if they're missing or empty (only for strings):
177
209
 
178
- ```ruby
179
- class MyConfig < Anyway::Config
180
- attr_config :api_key, :api_secret, :debug
210
+ ```ruby
211
+ class MyConfig < Anyway::Config
212
+ attr_config :api_key, :api_secret, :debug
181
213
 
182
- required :api_key, :api_secret
183
- end
214
+ required :api_key, :api_secret
215
+ end
184
216
 
185
- MyConfig.new(api_secret: "") #=> raises Anyway::Config::ValidationError
186
- ```
217
+ MyConfig.new(api_secret: "") #=> raises Anyway::Config::ValidationError
218
+ ```
187
219
 
188
- You can change the validation behaviour by overriding the `#validate!` method in your config class.
220
+ You can change the validation behaviour by overriding the `#validate!` method in your config class.
189
221
 
190
222
  - Validate config attribute names. ([@palkan][])
191
223
 
192
- Do not allow using reserved names (`Anyway::Config` method names).
193
- Allow only alphanumeric names (matching `/^[a-z_]([\w]+)?$/`).
224
+ Do not allow using reserved names (`Anyway::Config` method names).
225
+ Allow only alphanumeric names (matching `/^[a-z_]([\w]+)?$/`).
194
226
 
195
227
  - Add Loaders API. ([@palkan][])
196
228
 
197
- All config sources have standardized via _loaders_ API. It's possible to define
198
- custom loaders or change the sources order.
229
+ All config sources have standardized via _loaders_ API. It's possible to define
230
+ custom loaders or change the sources order.
199
231
 
200
232
  ## 2.0.0.pre2 (2019-04-26)
201
233
 
@@ -205,73 +237,58 @@
205
237
 
206
238
  - **BREAKING** Changed the way of providing explicit values. ([@palkan][])
207
239
 
208
- ```ruby
209
- # BEFORE
210
- Config.new(overrides: data)
240
+ ```ruby
241
+ # BEFORE
242
+ Config.new(overrides: data)
211
243
 
212
- # AFTER
213
- Config.new(data)
214
- ```
244
+ # AFTER
245
+ Config.new(data)
246
+ ```
215
247
 
216
248
  - Add Railtie. ([@palkan][])
217
249
 
218
- `Anyway::Railtie` provides `Anyway::Settings` access via `Rails.applicaiton.configuration.anyway_config`.
250
+ `Anyway::Railtie` provides `Anyway::Settings` access via `Rails.applicaiton.configuration.anyway_config`.
219
251
 
220
- It also adds `app/configs` path to autoload paths (low-level, `ActiveSupport::Dependencies`) to
221
- make it possible to use configs in the app configuration files.
252
+ It also adds `app/configs` path to autoload paths (low-level, `ActiveSupport::Dependencies`) to
253
+ make it possible to use configs in the app configuration files.
222
254
 
223
255
  - Add test helpers. ([@palkan][])
224
256
 
225
- Added `with_env` helper to test code in the context of the specified
226
- environment variables.
257
+ Added `with_env` helper to test code in the context of the specified
258
+ environment variables.
227
259
 
228
- Included automatically in RSpec for examples with the `type: :config` meta
229
- or with the `spec/configs` path.
260
+ Included automatically in RSpec for examples with the `type: :config` meta
261
+ or with the `spec/configs` path.
230
262
 
231
263
  - Add support for _local_ files. ([@palkan][])
232
264
 
233
- Now users can store their personal configurations in _local_ files:
234
- - `<config_name>.local.yml`
235
- - `config/credentials/local.yml.enc` (for Rails 6).
265
+ Now users can store their personal configurations in _local_ files:
236
266
 
237
- Local configs are meant for using in development and only loaded if
238
- `Anyway::Settings.use_local_files` is `true` (which is true by default if
239
- `RACK_ENV` or `RAILS_ENV` env variable is equal to `"development"`).
267
+ - `<config_name>.local.yml`
268
+ - `config/credentials/local.yml.enc` (for Rails 6).
269
+
270
+ Local configs are meant for using in development and only loaded if
271
+ `Anyway::Settings.use_local_files` is `true` (which is true by default if
272
+ `RACK_ENV` or `RAILS_ENV` env variable is equal to `"development"`).
240
273
 
241
274
  - Add Rails credentials support. ([@palkan][])
242
275
 
243
- The data from credentials is loaded after the data from YAML config and secrets,
244
- but before environmental variables (i.e. env variables are _stronger_)
276
+ The data from credentials is loaded after the data from YAML config and secrets,
277
+ but before environmental variables (i.e. env variables are _stronger_)
245
278
 
246
279
  - Update config name inference logic. ([@palkan][])
247
280
 
248
- Config name is automatically inferred only if:
249
- - the class name has a form of `<Module>::Config` (`SomeModule::Config => "some_module"`)
250
- - the class name has a form of `<Something>Config` (`SomeConfig => "some"`)
251
-
252
- - Fix config classes inheritance. ([@palkan][])
253
-
254
- Previously, inheritance didn't work due to the lack of proper handling of class-level
255
- configuration (naming, option parses settings, defaults).
256
-
257
- Now it's possible to extend config classes without breaking the original classes functionality.
281
+ Config name is automatically inferred only if:
258
282
 
259
- Noticeable features:
260
- - if `config_name` is explicitly defined on class, it's inherited by subclasses:
283
+ - the class name has a form of `<Module>::Config` (`SomeModule::Config => "some_module"`)
284
+ - the class name has a form of `<Something>Config` (`SomeConfig => "some"`)
261
285
 
262
- ```ruby
263
- class MyAppBaseConfig < Anyway::Config
264
- config_name :my_app
265
- end
266
-
267
- class MyServiceConfig < MyAppBaseConfig
268
- end
286
+ - Fix config classes inheritance. ([@palkan][])
269
287
 
270
- MyServiceConfig.config_name #=> "my_app"
271
- ```
288
+ Previously, inheritance didn't work due to the lack of proper handling of class-level
289
+ configuration (naming, option parses settings, defaults).
272
290
 
273
- - defaults are merged leaving the parent class defaults unchanged
274
- - option parse extension are not overriden, but added to the parent class extensions
291
+ Now it's possible to extend config classes without breaking the original classes functionality.
275
292
 
276
293
  - **Require Ruby >= 2.5.0.**
277
294
 
@@ -291,26 +308,26 @@
291
308
 
292
309
  - Add OptionParse integration ([@jastkand][])
293
310
 
294
- See more [PR#18](https://github.com/palkan/anyway_config/pull/18).
311
+ See more [PR#18](https://github.com/palkan/anyway_config/pull/18).
295
312
 
296
313
  - Use underscored config name as an env prefix. ([@palkan][])
297
314
 
298
- For a config class:
315
+ For a config class:
299
316
 
300
- ```ruby
301
- class MyApp < Anyway::Config
302
- end
303
- ```
317
+ ```ruby
318
+ class MyApp < Anyway::Config
319
+ end
320
+ ```
304
321
 
305
- Before this change we use `MYAPP_` prefix, now it's `MY_APP_`.
322
+ Before this change we use `MYAPP_` prefix, now it's `MY_APP_`.
306
323
 
307
- You can specify the prefix explicitly:
324
+ You can specify the prefix explicitly:
308
325
 
309
- ```ruby
310
- class MyApp < Anyway::Config
311
- env_prefix "MYAPP_"
312
- end
313
- ```
326
+ ```ruby
327
+ class MyApp < Anyway::Config
328
+ env_prefix "MYAPP_"
329
+ end
330
+ ```
314
331
 
315
332
  ## 1.3.0 (2018-06-15)
316
333
 
@@ -326,18 +343,18 @@ Now works on JRuby 9.1+.
326
343
 
327
344
  - Allow to pass raw hash with explicit values to `Config.new`. ([@dsalahutdinov][])
328
345
 
329
- Example:
346
+ Example:
330
347
 
331
- ```ruby
332
- Sniffer::Config.new(
333
- overrides: {
334
- enabled: true,
335
- storage: {capacity: 500}
336
- }
337
- )
338
- ```
348
+ ```ruby
349
+ Sniffer::Config.new(
350
+ overrides: {
351
+ enabled: true,
352
+ storage: {capacity: 500}
353
+ }
354
+ )
355
+ ```
339
356
 
340
- See more [PR#10](https://github.com/palkan/anyway_config/pull/10).
357
+ See more [PR#10](https://github.com/palkan/anyway_config/pull/10).
341
358
 
342
359
  ## 1.1.2 (2017-11-19)
343
360
 
@@ -351,7 +368,7 @@ Now works on JRuby 9.1+.
351
368
 
352
369
  - Add `#to_h` method. ([@palkan][])
353
370
 
354
- See [#4](https://github.com/palkan/anyway_config/issues/4).
371
+ See [#4](https://github.com/palkan/anyway_config/issues/4).
355
372
 
356
373
  - Make it possible to extend configuration parameters. ([@palkan][])
357
374
 
@@ -365,17 +382,18 @@ Now works on JRuby 9.1+.
365
382
 
366
383
  - Drop `active_support` dependency. ([@palkan][])
367
384
 
368
- Use custom refinements instead of requiring `active_support`.
385
+ Use custom refinements instead of requiring `active_support`.
369
386
 
370
- No we're dependency-free!
387
+ No we're dependency-free!
371
388
 
372
389
  ## 0.1.0 (2015-01-20)
373
390
 
374
- Initial version.
391
+ - Initial version.
375
392
 
376
393
  [@palkan]: https://github.com/palkan
377
394
  [@onemanstartup]: https://github.com/onemanstartup
378
395
  [@dsalahutdinov]: https://github.com/dsalahutdinov
379
396
  [@charlie-wasp]: https://github.com/charlie-wasp
380
397
  [@jastkand]: https://github.com/jastkand
381
- [@Envek]: https://github.com/Envek
398
+ [@envek]: https://github.com/Envek
399
+ [@progapandist]: https://github.com/progapandist