anyway_config 2.5.1 → 2.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +21 -9
- data/lib/.rbnext/2.7/anyway/config.rb +2 -1
- data/lib/.rbnext/2.7/anyway/loaders/yaml.rb +1 -1
- data/lib/.rbnext/2.7/anyway/settings.rb +1 -1
- data/lib/.rbnext/3.0/anyway/config.rb +2 -1
- data/lib/.rbnext/3.1/anyway/config.rb +2 -1
- data/lib/anyway/config.rb +2 -1
- data/lib/anyway/loaders/yaml.rb +1 -1
- data/lib/anyway/rails/autoload.rb +7 -4
- data/lib/anyway/rails.rb +7 -2
- data/lib/anyway/settings.rb +1 -1
- data/lib/anyway/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6fee4af14bfa83eab99562506f1dbeaf3826f3da3f204f3f117787aa5b04b9c
|
4
|
+
data.tar.gz: 16f081b27030e63ef69ad58a3fae0029fe6c983c2056574b73ef86d9dbb249a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c07338e57bdac6d238e848901c91aabf38011dd7dc4a9c0d39be8a582c5814da411e310f9f7f58d75de06ef2458eb92255bd4889f6f7e0d98b14416cfbcbe35
|
7
|
+
data.tar.gz: a51191c4933cac6c78530e7b0f1f3b8c43a5dc8414a1758544ab7f1ebba708e01e99789d0383df365bb0ba9eb71e7137b16a3efc564329f4cd1e2e5bbb70e73a
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 2.5.4 (2023-09-12)
|
6
|
+
|
7
|
+
- Do not activate Rails secrets loaders in 7.1+. ([@palkan][])
|
8
|
+
|
9
|
+
- Set `use_local_files` depending on `Rails.env`. ([@marshall-lee][])
|
10
|
+
|
11
|
+
## 2.5.2 (2023-08-23)
|
12
|
+
|
13
|
+
- Disable Rails post-load detection in TruffleRuby. ([@palkan][])
|
14
|
+
|
5
15
|
## 2.5.1 (2023-08-04)
|
6
16
|
|
7
17
|
- Fix Rails detection. ([@palkan][])
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
[![Cult Of Martians](http://cultofmartians.com/assets/badges/badge.svg)](https://cultofmartians.com/tasks/anyway-config-options-parse.html#task)
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/anyway_config.svg)](https://rubygems.org/gems/anyway_config) [![Build](https://github.com/palkan/anyway_config/workflows/Build/badge.svg)](https://github.com/palkan/anyway_config/actions)
|
3
3
|
[![JRuby Build](https://github.com/palkan/anyway_config/workflows/JRuby%20Build/badge.svg)](https://github.com/palkan/anyway_config/actions)
|
4
|
+
[![TruffleRuby Build](https://github.com/palkan/anyway_config/workflows/TruffleRuby%20Build/badge.svg)](https://github.com/palkan/anyway_config/actions)
|
4
5
|
|
5
6
|
# Anyway Config
|
6
7
|
|
@@ -433,7 +434,7 @@ config.anyway_config.default_config_path = ->(name) { Rails.root.join("data", "c
|
|
433
434
|
|
434
435
|
- By overriding a specific config YML file path via the `<NAME>_CONF` env variable, e.g., `MYCOOLGEM_CONF=path/to/cool.yml`
|
435
436
|
|
436
|
-
2) **Rails secrets**: `Rails.application.secrets.my_cool_gem` (if `secrets.yml` present).
|
437
|
+
2) (Rails <7.1) **Rails secrets**: `Rails.application.secrets.my_cool_gem` (if `secrets.yml` present).
|
437
438
|
|
438
439
|
```yml
|
439
440
|
# config/secrets.yml
|
@@ -442,6 +443,8 @@ development:
|
|
442
443
|
port: 4444
|
443
444
|
```
|
444
445
|
|
446
|
+
**NOTE:** If you want to use secrets with Rails 7.1 (still supported, but deprecated) you must add the corresponding loader manually: `Anyway.loaders.insert_after :yml, :secrets, Anyway::Rails::Loaders::Secrets`.
|
447
|
+
|
445
448
|
3) **Rails credentials**: `Rails.application.credentials.my_cool_gem` (if supported):
|
446
449
|
|
447
450
|
```yml
|
@@ -614,14 +617,14 @@ Environmental variables for your config should start with your config name, uppe
|
|
614
617
|
|
615
618
|
For example, if your config name is "mycoolgem", then the env var "MYCOOLGEM_PASSWORD" is used as `config.password`.
|
616
619
|
|
617
|
-
By default, environment variables are automatically type cast
|
620
|
+
By default, environment variables are automatically type cast (rules are case-insensitive):
|
618
621
|
|
619
|
-
- `"
|
620
|
-
- `"
|
622
|
+
- `"true"`, `"t"`, `"yes"` and `"y"` to `true`;
|
623
|
+
- `"false"`, `"f"`, `"no"` and `"n"` to `false`;
|
621
624
|
- `"nil"` and `"null"` to `nil` (do you really need it?);
|
622
|
-
- `"123"` to 123 and `"3.14"` to 3.14
|
625
|
+
- `"123"` to `123` and `"3.14"` to `3.14`.
|
623
626
|
|
624
|
-
|
627
|
+
Type coercion can be [customized or disabled](#type-coercion).
|
625
628
|
|
626
629
|
*Anyway Config* supports nested (_hashed_) env variables—just separate keys with double-underscore.
|
627
630
|
|
@@ -847,11 +850,17 @@ You can use `Anyway::Loaders::Base` as a base class for your loader and define a
|
|
847
850
|
For example, the [Chamber](https://github.com/thekompanee/chamber) loader could be written as follows:
|
848
851
|
|
849
852
|
```ruby
|
850
|
-
class ChamberConfigLoader <
|
853
|
+
class ChamberConfigLoader < Base
|
851
854
|
def call(name:, **_opts)
|
852
|
-
Chamber.
|
855
|
+
Chamber.to_hash[name] || {}
|
856
|
+
rescue Chamber::Errors::DecryptionFailure => e
|
857
|
+
warn "Couldn't decrypt Chamber settings: #{e.message}"
|
858
|
+
{}
|
853
859
|
end
|
854
860
|
end
|
861
|
+
|
862
|
+
# Don't forget to register it
|
863
|
+
Anyway.loaders.insert_before :env, :chamber, ChamberConfigLoader
|
855
864
|
```
|
856
865
|
|
857
866
|
In order to support [source tracing](#tracing), you need to wrap the resulting Hash via the `#trace!` method with metadata:
|
@@ -859,7 +868,10 @@ In order to support [source tracing](#tracing), you need to wrap the resulting H
|
|
859
868
|
```ruby
|
860
869
|
def call(name:, **_opts)
|
861
870
|
trace!(:chamber) do
|
862
|
-
Chamber.
|
871
|
+
Chamber.to_hash[name] || {}
|
872
|
+
rescue Chamber::Errors::DecryptionFailure => e
|
873
|
+
warn "Couldn't decrypt Chamber settings: #{e.message}"
|
874
|
+
{}
|
863
875
|
end
|
864
876
|
end
|
865
877
|
```
|
@@ -217,7 +217,8 @@ module Anyway # :nodoc:
|
|
217
217
|
Utils.deep_merge!(coercion_mapping, mapping)
|
218
218
|
|
219
219
|
mapping.each do |key, val|
|
220
|
-
|
220
|
+
type = val.is_a?(::Hash) ? val[:type] : val
|
221
|
+
next if type != :boolean
|
221
222
|
|
222
223
|
alias_method :"#{key}?", :"#{key}"
|
223
224
|
end
|
@@ -100,7 +100,7 @@ module Anyway
|
|
100
100
|
self.current_environment = ENV["ANYWAY_ENV"]
|
101
101
|
|
102
102
|
# By default, use local files only in development (that's the purpose if the local files)
|
103
|
-
self.use_local_files = (ENV["ANYWAY_ENV"] == "development" || ENV["RACK_ENV"] == "development" || ENV["RAILS_ENV"] == "development")
|
103
|
+
self.use_local_files = (ENV["ANYWAY_ENV"] == "development" || ENV["RACK_ENV"] == "development" || ENV["RAILS_ENV"] == "development" || (defined?(Rails) && Rails.env.development?))
|
104
104
|
|
105
105
|
# By default, consider configs are stored in the ./config folder
|
106
106
|
self.default_config_path = ->(name) { "./config/#{name}.yml" }
|
@@ -217,7 +217,8 @@ module Anyway # :nodoc:
|
|
217
217
|
Utils.deep_merge!(coercion_mapping, mapping)
|
218
218
|
|
219
219
|
mapping.each do |key, val|
|
220
|
-
|
220
|
+
type = val.is_a?(::Hash) ? val[:type] : val
|
221
|
+
next if type != :boolean
|
221
222
|
|
222
223
|
alias_method :"#{key}?", :"#{key}"
|
223
224
|
end
|
@@ -217,7 +217,8 @@ module Anyway # :nodoc:
|
|
217
217
|
Utils.deep_merge!(coercion_mapping, mapping)
|
218
218
|
|
219
219
|
mapping.each do |key, val|
|
220
|
-
|
220
|
+
type = val.is_a?(::Hash) ? val[:type] : val
|
221
|
+
next if type != :boolean
|
221
222
|
|
222
223
|
alias_method :"#{key}?", :"#{key}"
|
223
224
|
end
|
data/lib/anyway/config.rb
CHANGED
@@ -217,7 +217,8 @@ module Anyway # :nodoc:
|
|
217
217
|
Utils.deep_merge!(coercion_mapping, mapping)
|
218
218
|
|
219
219
|
mapping.each do |key, val|
|
220
|
-
|
220
|
+
type = val.is_a?(::Hash) ? val[:type] : val
|
221
|
+
next if type != :boolean
|
221
222
|
|
222
223
|
alias_method :"#{key}?", :"#{key}"
|
223
224
|
end
|
data/lib/anyway/loaders/yaml.rb
CHANGED
@@ -31,9 +31,12 @@ module Anyway
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
# TruffleRuby doesn't support TracePoint's end event
|
35
|
+
unless defined?(::TruffleRuby)
|
36
|
+
@tracer = TracePoint.new(:end, &method(:tracepoint_class_callback))
|
37
|
+
@tracer.enable
|
38
|
+
# Use `Module#name` instead of `self.name` to handle overwritten `name` method
|
39
|
+
@name_method = Module.instance_method(:name)
|
40
|
+
end
|
38
41
|
end
|
39
42
|
end
|
data/lib/anyway/rails.rb
CHANGED
@@ -11,8 +11,13 @@ require "anyway/rails/loaders"
|
|
11
11
|
|
12
12
|
# Configure Rails loaders
|
13
13
|
Anyway.loaders.override :yml, Anyway::Rails::Loaders::YAML
|
14
|
-
|
15
|
-
|
14
|
+
|
15
|
+
if Rails::VERSION::MAJOR >= 7 && Rails::VERSION::MINOR >= 1
|
16
|
+
Anyway.loaders.insert_after :yml, :credentials, Anyway::Rails::Loaders::Credentials
|
17
|
+
else
|
18
|
+
Anyway.loaders.insert_after :yml, :secrets, Anyway::Rails::Loaders::Secrets
|
19
|
+
Anyway.loaders.insert_after :secrets, :credentials, Anyway::Rails::Loaders::Credentials
|
20
|
+
end
|
16
21
|
|
17
22
|
# Load Railties after configuring loaders.
|
18
23
|
# The application could be already initialized, and that would make `Anyway.loaders` frozen
|
data/lib/anyway/settings.rb
CHANGED
@@ -100,7 +100,7 @@ module Anyway
|
|
100
100
|
self.current_environment = ENV["ANYWAY_ENV"]
|
101
101
|
|
102
102
|
# By default, use local files only in development (that's the purpose if the local files)
|
103
|
-
self.use_local_files = (ENV["ANYWAY_ENV"] == "development" || ENV["RACK_ENV"] == "development" || ENV["RAILS_ENV"] == "development")
|
103
|
+
self.use_local_files = (ENV["ANYWAY_ENV"] == "development" || ENV["RACK_ENV"] == "development" || ENV["RAILS_ENV"] == "development" || (defined?(Rails) && Rails.env.development?))
|
104
104
|
|
105
105
|
# By default, consider configs are stored in the ./config folder
|
106
106
|
self.default_config_path = ->(name) { "./config/#{name}.yml" }
|
data/lib/anyway/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anyway_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-next-core
|