anyway_config 2.5.4 → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +8 -2
- data/lib/.rbnext/2.7/anyway/auto_cast.rb +2 -2
- data/lib/.rbnext/2.7/anyway/config.rb +5 -5
- data/lib/.rbnext/2.7/anyway/tracing.rb +10 -10
- data/lib/.rbnext/2.7/anyway/type_casting.rb +1 -1
- data/lib/.rbnext/3.0/anyway/auto_cast.rb +2 -2
- data/lib/.rbnext/3.0/anyway/config.rb +5 -5
- data/lib/.rbnext/3.0/anyway/loaders/base.rb +2 -2
- data/lib/.rbnext/3.0/anyway/tracing.rb +10 -10
- data/lib/.rbnext/3.1/anyway/config.rb +5 -5
- data/lib/.rbnext/3.1/anyway/loaders/base.rb +2 -2
- data/lib/.rbnext/3.1/anyway/tracing.rb +10 -10
- data/lib/.rbnext/3.2/anyway/config.rb +473 -0
- data/lib/.rbnext/3.2/anyway/loaders/base.rb +21 -0
- data/lib/.rbnext/3.2/anyway/tracing.rb +188 -0
- data/lib/.rbnext/3.4/anyway/auto_cast.rb +53 -0
- data/lib/.rbnext/3.4/anyway/config.rb +473 -0
- data/lib/.rbnext/3.4/anyway/tracing.rb +188 -0
- data/lib/.rbnext/3.4/anyway/type_casting.rb +144 -0
- data/lib/anyway/auto_cast.rb +2 -2
- data/lib/anyway/config.rb +5 -5
- data/lib/anyway/loaders/base.rb +2 -2
- data/lib/anyway/tracing.rb +10 -10
- data/lib/anyway/type_casting.rb +1 -1
- data/lib/anyway/version.rb +1 -1
- data/lib/rails/commands/local_credentials/local_credentials_command.rb +24 -0
- metadata +19 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddc4b1bdc750d6aa71030a8140e25127d20ec041254bdf79e239c44d1804d5eb
|
4
|
+
data.tar.gz: 42be794c396f2c861707560b8d63e6d51350f458c4da10e650006f2e6b6cbf0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a8ef640dd47a01fa5bf5fb6d755b46996286ab772ae094e3ccc1bede6156f16259296e9f2a48766c1debc7052e83c8ffd3ed1de329642264295bcb0b934b5bc
|
7
|
+
data.tar.gz: 1822daadbcb3ffcfdf4cae76bf306396aa794d2fbea2f13191e76b0320443a839af5aeeab3cfd44077a327ddc8d21fb3710adc81947bb8df9e551a9b09e8691d
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 2.6.1 (2023-12-22)
|
6
|
+
|
7
|
+
- Fix Ruby Next version requirements. ([@palkan][])
|
8
|
+
|
9
|
+
## 2.6.0 (2023-12-18)
|
10
|
+
|
11
|
+
- Add `rails local_credentials:edit` command to manipulate local credentials in Rails 7.1+. ([@palkan][])
|
12
|
+
|
5
13
|
## 2.5.4 (2023-10-15)
|
6
14
|
|
7
15
|
- Fix tracing with empty config keys. ([@palkan][])
|
data/README.md
CHANGED
@@ -738,7 +738,7 @@ It's useful to have a personal, user-specific configuration in development, whic
|
|
738
738
|
We support this by looking at _local_ files when loading the configuration data:
|
739
739
|
|
740
740
|
- `<config_name>.local.yml` files (next to\* the _global_ `<config_name>.yml`)
|
741
|
-
- `config/credentials/local.yml.enc` (for Rails >=
|
741
|
+
- `config/credentials/local.yml.enc` (for Rails >= 7.1, generate it via `rails local_credentials:edit`; for Rails >= 6.0, <7.1 you can also use `rails credentials:edit -e local`).
|
742
742
|
|
743
743
|
\* If the YAML config path is not a default one (i.e., set via `<CONFIG_NAME>_CONF`), we look up the local
|
744
744
|
config at this location, too.
|
@@ -1054,7 +1054,13 @@ describe_options(
|
|
1054
1054
|
|
1055
1055
|
Anyway Config comes with Ruby type signatures (RBS).
|
1056
1056
|
|
1057
|
-
To use them with Steep, add
|
1057
|
+
To use them with Steep, add the following your `Steepfile`:
|
1058
|
+
|
1059
|
+
```ruby
|
1060
|
+
library "pathname"
|
1061
|
+
library "optparse"
|
1062
|
+
library "anyway_config"
|
1063
|
+
```
|
1058
1064
|
|
1059
1065
|
We also provide an API to generate a type signature for your config class:
|
1060
1066
|
|
@@ -13,9 +13,9 @@ module Anyway
|
|
13
13
|
|
14
14
|
case val
|
15
15
|
when Hash
|
16
|
-
val.transform_values { |_1| call(
|
16
|
+
val.transform_values { |_1| it = _1;call(it) }
|
17
17
|
when ARRAY_RXP
|
18
|
-
val.split(/\s*,\s*/).map { |_1| call(
|
18
|
+
val.split(/\s*,\s*/).map { |_1| it = _1;call(it) }
|
19
19
|
when /\A(true|t|yes|y)\z/i
|
20
20
|
true
|
21
21
|
when /\A(false|f|no|n)\z/i
|
@@ -154,7 +154,7 @@ module Anyway # :nodoc:
|
|
154
154
|
if block
|
155
155
|
load_callbacks << BlockCallback.new(block)
|
156
156
|
else
|
157
|
-
load_callbacks.push(*names.map { |_1| NamedCallback.new(
|
157
|
+
load_callbacks.push(*names.map { |_1| it = _1;NamedCallback.new(it) })
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
@@ -380,7 +380,7 @@ module Anyway # :nodoc:
|
|
380
380
|
trace&.keep_if { |key| self.class.config_attributes.include?(key.to_sym) }
|
381
381
|
|
382
382
|
# Run on_load callbacks
|
383
|
-
self.class.load_callbacks.each { |_1| _1.apply_to(self) }
|
383
|
+
self.class.load_callbacks.each { |_1| it = _1;it.apply_to(self) }
|
384
384
|
|
385
385
|
# Set trace after we write all the values to
|
386
386
|
# avoid changing the source to accessor
|
@@ -389,14 +389,14 @@ module Anyway # :nodoc:
|
|
389
389
|
self
|
390
390
|
end
|
391
391
|
|
392
|
-
def load_from_sources(base_config, **
|
392
|
+
def load_from_sources(base_config, **__kwrest__)
|
393
393
|
Anyway.loaders.each do |(_id, loader)|
|
394
|
-
Utils.deep_merge!(base_config, loader.call(**
|
394
|
+
Utils.deep_merge!(base_config, loader.call(**__kwrest__))
|
395
395
|
end
|
396
396
|
base_config
|
397
397
|
end
|
398
398
|
|
399
|
-
def dig(*
|
399
|
+
def dig(*__rest__) ; values.dig(*__rest__); end
|
400
400
|
|
401
401
|
def to_h() ; values.deep_dup.deep_freeze; end
|
402
402
|
|
@@ -26,12 +26,12 @@ module Anyway
|
|
26
26
|
value.dig(*__rest__, &__block__)
|
27
27
|
end; respond_to?(:ruby2_keywords, true) && (ruby2_keywords :dig)
|
28
28
|
|
29
|
-
def record_value(val, *path, **
|
29
|
+
def record_value(val, *path, **__kwrest__)
|
30
30
|
key = path.pop
|
31
31
|
trace = if val.is_a?(Hash)
|
32
|
-
Trace.new.tap { |_1| _1.merge_values(val, **
|
32
|
+
Trace.new.tap { |_1| it = _1;it.merge_values(val, **__kwrest__) }
|
33
33
|
else
|
34
|
-
Trace.new(:value, val, **
|
34
|
+
Trace.new(:value, val, **__kwrest__)
|
35
35
|
end
|
36
36
|
|
37
37
|
target_trace = path.empty? ? self : value.dig(*path)
|
@@ -40,14 +40,14 @@ module Anyway
|
|
40
40
|
val
|
41
41
|
end
|
42
42
|
|
43
|
-
def merge_values(hash, **
|
43
|
+
def merge_values(hash, **__kwrest__)
|
44
44
|
return hash unless hash
|
45
45
|
|
46
46
|
hash.each do |key, val|
|
47
47
|
if val.is_a?(Hash)
|
48
|
-
value[key.to_s].merge_values(val, **
|
48
|
+
value[key.to_s].merge_values(val, **__kwrest__)
|
49
49
|
else
|
50
|
-
value[key.to_s] = Trace.new(:value, val, **
|
50
|
+
value[key.to_s] = Trace.new(:value, val, **__kwrest__)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -84,7 +84,7 @@ module Anyway
|
|
84
84
|
|
85
85
|
def to_h
|
86
86
|
if trace?
|
87
|
-
value.transform_values(&:to_h).tap { |_1| _1.default_proc = nil }
|
87
|
+
value.transform_values(&:to_h).tap { |_1| it = _1;it.default_proc = nil }
|
88
88
|
else
|
89
89
|
{value: value, source: source}
|
90
90
|
end
|
@@ -174,13 +174,13 @@ module Anyway
|
|
174
174
|
|
175
175
|
module_function
|
176
176
|
|
177
|
-
def trace!(type, *path, **
|
177
|
+
def trace!(type, *path, **__kwrest__)
|
178
178
|
return yield unless Tracing.tracing?
|
179
179
|
val = yield
|
180
180
|
if val.is_a?(Hash)
|
181
|
-
Tracing.current_trace.merge_values(val, type: type, **
|
181
|
+
Tracing.current_trace.merge_values(val, type: type, **__kwrest__)
|
182
182
|
elsif !path.empty?
|
183
|
-
Tracing.current_trace.record_value(val, *path, type: type, **
|
183
|
+
Tracing.current_trace.record_value(val, *path, type: type, **__kwrest__)
|
184
184
|
end
|
185
185
|
val
|
186
186
|
end
|
@@ -13,9 +13,9 @@ module Anyway
|
|
13
13
|
|
14
14
|
case val
|
15
15
|
when Hash
|
16
|
-
val.transform_values { call(
|
16
|
+
val.transform_values { it = _1;call(it) }
|
17
17
|
when ARRAY_RXP
|
18
|
-
val.split(/\s*,\s*/).map { call(
|
18
|
+
val.split(/\s*,\s*/).map { it = _1;call(it) }
|
19
19
|
when /\A(true|t|yes|y)\z/i
|
20
20
|
true
|
21
21
|
when /\A(false|f|no|n)\z/i
|
@@ -154,7 +154,7 @@ module Anyway # :nodoc:
|
|
154
154
|
if block
|
155
155
|
load_callbacks << BlockCallback.new(block)
|
156
156
|
else
|
157
|
-
load_callbacks.push(*names.map { NamedCallback.new(
|
157
|
+
load_callbacks.push(*names.map { it = _1;NamedCallback.new(it) })
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
@@ -380,7 +380,7 @@ module Anyway # :nodoc:
|
|
380
380
|
trace&.keep_if { |key| self.class.config_attributes.include?(key.to_sym) }
|
381
381
|
|
382
382
|
# Run on_load callbacks
|
383
|
-
self.class.load_callbacks.each { _1.apply_to(self) }
|
383
|
+
self.class.load_callbacks.each { it = _1;it.apply_to(self) }
|
384
384
|
|
385
385
|
# Set trace after we write all the values to
|
386
386
|
# avoid changing the source to accessor
|
@@ -389,14 +389,14 @@ module Anyway # :nodoc:
|
|
389
389
|
self
|
390
390
|
end
|
391
391
|
|
392
|
-
def load_from_sources(base_config, **
|
392
|
+
def load_from_sources(base_config, **__kwrest__)
|
393
393
|
Anyway.loaders.each do |(_id, loader)|
|
394
|
-
Utils.deep_merge!(base_config, loader.call(**
|
394
|
+
Utils.deep_merge!(base_config, loader.call(**__kwrest__))
|
395
395
|
end
|
396
396
|
base_config
|
397
397
|
end
|
398
398
|
|
399
|
-
def dig(*
|
399
|
+
def dig(*__rest__) ; values.dig(*__rest__); end
|
400
400
|
|
401
401
|
def to_h() ; values.deep_dup.deep_freeze; end
|
402
402
|
|
@@ -6,8 +6,8 @@ module Anyway
|
|
6
6
|
include Tracing
|
7
7
|
|
8
8
|
class << self
|
9
|
-
def call(local: Anyway::Settings.use_local_files, **
|
10
|
-
new(local: local).call(**
|
9
|
+
def call(local: Anyway::Settings.use_local_files, **__kwrest__)
|
10
|
+
new(local: local).call(**__kwrest__)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -26,12 +26,12 @@ module Anyway
|
|
26
26
|
value.dig(...)
|
27
27
|
end; respond_to?(:ruby2_keywords, true) && (ruby2_keywords :dig)
|
28
28
|
|
29
|
-
def record_value(val, *path, **
|
29
|
+
def record_value(val, *path, **__kwrest__)
|
30
30
|
key = path.pop
|
31
31
|
trace = if val.is_a?(Hash)
|
32
|
-
Trace.new.tap { _1.merge_values(val, **
|
32
|
+
Trace.new.tap { it = _1;it.merge_values(val, **__kwrest__) }
|
33
33
|
else
|
34
|
-
Trace.new(:value, val, **
|
34
|
+
Trace.new(:value, val, **__kwrest__)
|
35
35
|
end
|
36
36
|
|
37
37
|
target_trace = path.empty? ? self : value.dig(*path)
|
@@ -40,14 +40,14 @@ module Anyway
|
|
40
40
|
val
|
41
41
|
end
|
42
42
|
|
43
|
-
def merge_values(hash, **
|
43
|
+
def merge_values(hash, **__kwrest__)
|
44
44
|
return hash unless hash
|
45
45
|
|
46
46
|
hash.each do |key, val|
|
47
47
|
if val.is_a?(Hash)
|
48
|
-
value[key.to_s].merge_values(val, **
|
48
|
+
value[key.to_s].merge_values(val, **__kwrest__)
|
49
49
|
else
|
50
|
-
value[key.to_s] = Trace.new(:value, val, **
|
50
|
+
value[key.to_s] = Trace.new(:value, val, **__kwrest__)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -84,7 +84,7 @@ module Anyway
|
|
84
84
|
|
85
85
|
def to_h
|
86
86
|
if trace?
|
87
|
-
value.transform_values(&:to_h).tap { _1.default_proc = nil }
|
87
|
+
value.transform_values(&:to_h).tap { it = _1;it.default_proc = nil }
|
88
88
|
else
|
89
89
|
{value: value, source: source}
|
90
90
|
end
|
@@ -174,13 +174,13 @@ module Anyway
|
|
174
174
|
|
175
175
|
module_function
|
176
176
|
|
177
|
-
def trace!(type, *path, **
|
177
|
+
def trace!(type, *path, **__kwrest__)
|
178
178
|
return yield unless Tracing.tracing?
|
179
179
|
val = yield
|
180
180
|
if val.is_a?(Hash)
|
181
|
-
Tracing.current_trace.merge_values(val, type: type, **
|
181
|
+
Tracing.current_trace.merge_values(val, type: type, **__kwrest__)
|
182
182
|
elsif !path.empty?
|
183
|
-
Tracing.current_trace.record_value(val, *path, type: type, **
|
183
|
+
Tracing.current_trace.record_value(val, *path, type: type, **__kwrest__)
|
184
184
|
end
|
185
185
|
val
|
186
186
|
end
|
@@ -154,7 +154,7 @@ module Anyway # :nodoc:
|
|
154
154
|
if block
|
155
155
|
load_callbacks << BlockCallback.new(block)
|
156
156
|
else
|
157
|
-
load_callbacks.push(*names.map { NamedCallback.new(
|
157
|
+
load_callbacks.push(*names.map { it = _1;NamedCallback.new(it) })
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
@@ -380,7 +380,7 @@ module Anyway # :nodoc:
|
|
380
380
|
trace&.keep_if { |key| self.class.config_attributes.include?(key.to_sym) }
|
381
381
|
|
382
382
|
# Run on_load callbacks
|
383
|
-
self.class.load_callbacks.each { _1.apply_to(self) }
|
383
|
+
self.class.load_callbacks.each { it = _1;it.apply_to(self) }
|
384
384
|
|
385
385
|
# Set trace after we write all the values to
|
386
386
|
# avoid changing the source to accessor
|
@@ -389,14 +389,14 @@ module Anyway # :nodoc:
|
|
389
389
|
self
|
390
390
|
end
|
391
391
|
|
392
|
-
def load_from_sources(base_config, **
|
392
|
+
def load_from_sources(base_config, **__kwrest__)
|
393
393
|
Anyway.loaders.each do |(_id, loader)|
|
394
|
-
Utils.deep_merge!(base_config, loader.call(**
|
394
|
+
Utils.deep_merge!(base_config, loader.call(**__kwrest__))
|
395
395
|
end
|
396
396
|
base_config
|
397
397
|
end
|
398
398
|
|
399
|
-
def dig(*
|
399
|
+
def dig(*__rest__) ; values.dig(*__rest__); end
|
400
400
|
|
401
401
|
def to_h() = values.deep_dup.deep_freeze
|
402
402
|
|
@@ -6,8 +6,8 @@ module Anyway
|
|
6
6
|
include Tracing
|
7
7
|
|
8
8
|
class << self
|
9
|
-
def call(local: Anyway::Settings.use_local_files, **
|
10
|
-
new(local: local).call(**
|
9
|
+
def call(local: Anyway::Settings.use_local_files, **__kwrest__)
|
10
|
+
new(local: local).call(**__kwrest__)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -26,12 +26,12 @@ module Anyway
|
|
26
26
|
value.dig(...)
|
27
27
|
end
|
28
28
|
|
29
|
-
def record_value(val, *path, **
|
29
|
+
def record_value(val, *path, **__kwrest__)
|
30
30
|
key = path.pop
|
31
31
|
trace = if val.is_a?(Hash)
|
32
|
-
Trace.new.tap { _1.merge_values(val, **
|
32
|
+
Trace.new.tap { it = _1;it.merge_values(val, **__kwrest__) }
|
33
33
|
else
|
34
|
-
Trace.new(:value, val, **
|
34
|
+
Trace.new(:value, val, **__kwrest__)
|
35
35
|
end
|
36
36
|
|
37
37
|
target_trace = path.empty? ? self : value.dig(*path)
|
@@ -40,14 +40,14 @@ module Anyway
|
|
40
40
|
val
|
41
41
|
end
|
42
42
|
|
43
|
-
def merge_values(hash, **
|
43
|
+
def merge_values(hash, **__kwrest__)
|
44
44
|
return hash unless hash
|
45
45
|
|
46
46
|
hash.each do |key, val|
|
47
47
|
if val.is_a?(Hash)
|
48
|
-
value[key.to_s].merge_values(val, **
|
48
|
+
value[key.to_s].merge_values(val, **__kwrest__)
|
49
49
|
else
|
50
|
-
value[key.to_s] = Trace.new(:value, val, **
|
50
|
+
value[key.to_s] = Trace.new(:value, val, **__kwrest__)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -84,7 +84,7 @@ module Anyway
|
|
84
84
|
|
85
85
|
def to_h
|
86
86
|
if trace?
|
87
|
-
value.transform_values(&:to_h).tap { _1.default_proc = nil }
|
87
|
+
value.transform_values(&:to_h).tap { it = _1;it.default_proc = nil }
|
88
88
|
else
|
89
89
|
{value: value, source: source}
|
90
90
|
end
|
@@ -174,13 +174,13 @@ module Anyway
|
|
174
174
|
|
175
175
|
module_function
|
176
176
|
|
177
|
-
def trace!(type, *path, **
|
177
|
+
def trace!(type, *path, **__kwrest__)
|
178
178
|
return yield unless Tracing.tracing?
|
179
179
|
val = yield
|
180
180
|
if val.is_a?(Hash)
|
181
|
-
Tracing.current_trace.merge_values(val, type: type, **
|
181
|
+
Tracing.current_trace.merge_values(val, type: type, **__kwrest__)
|
182
182
|
elsif !path.empty?
|
183
|
-
Tracing.current_trace.record_value(val, *path, type: type, **
|
183
|
+
Tracing.current_trace.record_value(val, *path, type: type, **__kwrest__)
|
184
184
|
end
|
185
185
|
val
|
186
186
|
end
|