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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecd889b5a9f662d00312e10d8bb01c25f35cfe56aa1f4e361fee46ead43af918
4
- data.tar.gz: 5c3921ddef8bbef598806a55f8f8beb9bf7b27b49df296bf1dc168370a4c159f
3
+ metadata.gz: ddc4b1bdc750d6aa71030a8140e25127d20ec041254bdf79e239c44d1804d5eb
4
+ data.tar.gz: 42be794c396f2c861707560b8d63e6d51350f458c4da10e650006f2e6b6cbf0e
5
5
  SHA512:
6
- metadata.gz: 5e9911f756c77a8110b031a8afef85819915742fe541f9bbfcd58011c6cb4f05f65928da4bed158f82a52fa9ad41c76420d3ad3f9885d2c4c7bd3aeb6307b849
7
- data.tar.gz: a6aa11ab9a3681983df6ce936680511fc9cc86658287ff7a3ff5691201d83e85cbac9b18155a04cb8bbccd81f41fdd0cabe203504c11a5baab2afc0b831a470e
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 >= 6, generate it via `rails credentials:edit --environment local`).
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 `library "anyway_config"` to your Steepfile.
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(_1) }
16
+ val.transform_values { |_1| it = _1;call(it) }
17
17
  when ARRAY_RXP
18
- val.split(/\s*,\s*/).map { |_1| call(_1) }
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(_1) })
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, **options)
392
+ def load_from_sources(base_config, **__kwrest__)
393
393
  Anyway.loaders.each do |(_id, loader)|
394
- Utils.deep_merge!(base_config, loader.call(**options))
394
+ Utils.deep_merge!(base_config, loader.call(**__kwrest__))
395
395
  end
396
396
  base_config
397
397
  end
398
398
 
399
- def dig(*keys) ; values.dig(*keys); end
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, **opts)
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, **opts) }
32
+ Trace.new.tap { |_1| it = _1;it.merge_values(val, **__kwrest__) }
33
33
  else
34
- Trace.new(:value, val, **opts)
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, **opts)
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, **opts)
48
+ value[key.to_s].merge_values(val, **__kwrest__)
49
49
  else
50
- value[key.to_s] = Trace.new(:value, val, **opts)
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, **opts)
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, **opts)
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, **opts)
183
+ Tracing.current_trace.record_value(val, *path, type: type, **__kwrest__)
184
184
  end
185
185
  val
186
186
  end
@@ -34,7 +34,7 @@ module Anyway
34
34
 
35
35
  if array
36
36
  raw_arr = raw.is_a?(String) ? raw.split(/\s*,\s*/) : Array(raw)
37
- raw_arr.map { |_1| caster.call(_1) }
37
+ raw_arr.map { |_1| it = _1;caster.call(it) }
38
38
  else
39
39
  caster.call(raw)
40
40
  end
@@ -13,9 +13,9 @@ module Anyway
13
13
 
14
14
  case val
15
15
  when Hash
16
- val.transform_values { call(_1) }
16
+ val.transform_values { it = _1;call(it) }
17
17
  when ARRAY_RXP
18
- val.split(/\s*,\s*/).map { call(_1) }
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(_1) })
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, **options)
392
+ def load_from_sources(base_config, **__kwrest__)
393
393
  Anyway.loaders.each do |(_id, loader)|
394
- Utils.deep_merge!(base_config, loader.call(**options))
394
+ Utils.deep_merge!(base_config, loader.call(**__kwrest__))
395
395
  end
396
396
  base_config
397
397
  end
398
398
 
399
- def dig(*keys) ; values.dig(*keys); end
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, **opts)
10
- new(local: local).call(**opts)
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, **opts)
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, **opts) }
32
+ Trace.new.tap { it = _1;it.merge_values(val, **__kwrest__) }
33
33
  else
34
- Trace.new(:value, val, **opts)
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, **opts)
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, **opts)
48
+ value[key.to_s].merge_values(val, **__kwrest__)
49
49
  else
50
- value[key.to_s] = Trace.new(:value, val, **opts)
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, **opts)
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, **opts)
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, **opts)
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(_1) })
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, **options)
392
+ def load_from_sources(base_config, **__kwrest__)
393
393
  Anyway.loaders.each do |(_id, loader)|
394
- Utils.deep_merge!(base_config, loader.call(**options))
394
+ Utils.deep_merge!(base_config, loader.call(**__kwrest__))
395
395
  end
396
396
  base_config
397
397
  end
398
398
 
399
- def dig(*keys) = values.dig(*keys)
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, **opts)
10
- new(local: local).call(**opts)
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, **opts)
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, **opts) }
32
+ Trace.new.tap { it = _1;it.merge_values(val, **__kwrest__) }
33
33
  else
34
- Trace.new(:value, val, **opts)
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, **opts)
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, **opts)
48
+ value[key.to_s].merge_values(val, **__kwrest__)
49
49
  else
50
- value[key.to_s] = Trace.new(:value, val, **opts)
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, **opts)
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, **opts)
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, **opts)
183
+ Tracing.current_trace.record_value(val, *path, type: type, **__kwrest__)
184
184
  end
185
185
  val
186
186
  end