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