anyway_config 2.1.0 → 2.2.3
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 +4 -4
- data/CHANGELOG.md +52 -0
- data/README.md +189 -4
- data/lib/.rbnext/2.7/anyway/auto_cast.rb +41 -21
- data/lib/.rbnext/2.7/anyway/config.rb +48 -1
- data/lib/.rbnext/2.7/anyway/rails/loaders/yaml.rb +8 -2
- data/lib/.rbnext/2.7/anyway/rbs.rb +92 -0
- data/lib/.rbnext/2.7/anyway/tracing.rb +5 -7
- data/lib/.rbnext/2.7/anyway/type_casting.rb +143 -0
- data/lib/.rbnext/3.0/anyway/auto_cast.rb +53 -0
- data/lib/.rbnext/3.0/anyway/config.rb +48 -1
- data/lib/.rbnext/3.0/anyway/tracing.rb +5 -7
- data/lib/.rbnext/{1995.next → 3.1}/anyway/config.rb +48 -1
- data/lib/.rbnext/{1995.next → 3.1}/anyway/dynamic_config.rb +6 -2
- data/lib/.rbnext/{1995.next → 3.1}/anyway/env.rb +0 -0
- data/lib/.rbnext/{1995.next → 3.1}/anyway/loaders/base.rb +0 -0
- data/lib/.rbnext/{1995.next → 3.1}/anyway/tracing.rb +2 -2
- data/lib/anyway/auto_cast.rb +41 -21
- data/lib/anyway/config.rb +48 -1
- data/lib/anyway/dynamic_config.rb +6 -2
- data/lib/anyway/ext/deep_dup.rb +6 -0
- data/lib/anyway/loaders/env.rb +3 -1
- data/lib/anyway/loaders/yaml.rb +16 -4
- data/lib/anyway/option_parser_builder.rb +1 -3
- data/lib/anyway/optparse_config.rb +5 -7
- data/lib/anyway/rails/loaders/credentials.rb +2 -2
- data/lib/anyway/rails/loaders/secrets.rb +5 -7
- data/lib/anyway/rails/loaders/yaml.rb +8 -2
- data/lib/anyway/rails/settings.rb +8 -2
- data/lib/anyway/rbs.rb +92 -0
- data/lib/anyway/tracing.rb +3 -3
- data/lib/anyway/type_casting.rb +134 -0
- data/lib/anyway/version.rb +1 -1
- data/lib/anyway_config.rb +2 -0
- data/lib/generators/anyway/install/templates/application_config.rb.tt +1 -1
- data/sig/anyway_config.rbs +129 -0
- metadata +21 -16
- data/lib/.rbnext/2.7/anyway/option_parser_builder.rb +0 -31
@@ -22,7 +22,7 @@ module Anyway
|
|
22
22
|
:credentials,
|
23
23
|
store: credentials_path
|
24
24
|
) do
|
25
|
-
::Rails.application.credentials.
|
25
|
+
::Rails.application.credentials.config[name.to_sym]
|
26
26
|
end.then do |creds|
|
27
27
|
Utils.deep_merge!(config, creds) if creds
|
28
28
|
end
|
@@ -48,7 +48,7 @@ module Anyway
|
|
48
48
|
key_path: ::Rails.root.join("config/credentials/local.key")
|
49
49
|
)
|
50
50
|
|
51
|
-
creds.
|
51
|
+
creds.config[name.to_sym]
|
52
52
|
end
|
53
53
|
|
54
54
|
def credentials_path
|
@@ -24,13 +24,11 @@ module Anyway
|
|
24
24
|
private
|
25
25
|
|
26
26
|
def secrets
|
27
|
-
@secrets ||=
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
::Rails.application.remove_instance_variable(:@secrets)
|
33
|
-
end
|
27
|
+
@secrets ||= ::Rails.application.secrets.tap do |_|
|
28
|
+
# Reset secrets state if the app hasn't been initialized
|
29
|
+
# See https://github.com/palkan/anyway_config/issues/14
|
30
|
+
next if ::Rails.application.initialized?
|
31
|
+
::Rails.application.remove_instance_variable(:@secrets)
|
34
32
|
end
|
35
33
|
end
|
36
34
|
end
|
@@ -8,7 +8,11 @@ module Anyway
|
|
8
8
|
parsed_yml = super
|
9
9
|
return parsed_yml unless environmental?(parsed_yml)
|
10
10
|
|
11
|
-
|
11
|
+
env_config = parsed_yml[::Rails.env] || {}
|
12
|
+
return env_config if Anyway::Settings.default_environmental_key.blank?
|
13
|
+
|
14
|
+
default_config = parsed_yml[Anyway::Settings.default_environmental_key] || {}
|
15
|
+
Utils.deep_merge!(default_config, env_config)
|
12
16
|
end
|
13
17
|
|
14
18
|
private
|
@@ -18,7 +22,9 @@ module Anyway
|
|
18
22
|
# likely
|
19
23
|
return true if parsed_yml.key?(::Rails.env)
|
20
24
|
# less likely
|
21
|
-
::Rails.application.config.anyway_config.known_environments.any? { parsed_yml.key?(_1) }
|
25
|
+
return true if ::Rails.application.config.anyway_config.known_environments.any? { parsed_yml.key?(_1) }
|
26
|
+
# strange, but still possible
|
27
|
+
Anyway::Settings.default_environmental_key.present? && parsed_yml.key?(Anyway::Settings.default_environmental_key)
|
22
28
|
end
|
23
29
|
|
24
30
|
def relative_config_path(path)
|
@@ -17,6 +17,9 @@ module Anyway
|
|
17
17
|
attr_reader :autoload_static_config_path, :autoloader
|
18
18
|
attr_accessor :known_environments
|
19
19
|
|
20
|
+
# Define a key for environmental yaml files to read default values from
|
21
|
+
attr_accessor :default_environmental_key
|
22
|
+
|
20
23
|
if defined?(::Zeitwerk)
|
21
24
|
def autoload_static_config_path=(val)
|
22
25
|
raise "Cannot setup autoloader after application has been initialized" if ::Rails.application.initialized?
|
@@ -27,10 +30,11 @@ module Anyway
|
|
27
30
|
|
28
31
|
@autoload_static_config_path = val
|
29
32
|
|
30
|
-
# See https://github.com/rails/rails/blob/8ab4fd12f18203b83d0f252db96d10731485ff6a/railties/lib/rails/autoloaders.rb#L10
|
33
|
+
# See Rails 6 https://github.com/rails/rails/blob/8ab4fd12f18203b83d0f252db96d10731485ff6a/railties/lib/rails/autoloaders.rb#L10
|
34
|
+
# and Rails 7 https://github.com/rails/rails/blob/5462fbd5de1900c1b1ce1c9dc11c1a2d8cdcd809/railties/lib/rails/autoloaders.rb#L15
|
31
35
|
@autoloader = Zeitwerk::Loader.new.tap do |loader|
|
32
36
|
loader.tag = "anyway.config"
|
33
|
-
loader.inflector = ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector
|
37
|
+
loader.inflector = defined?(ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector) ? ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector : ::Rails::Autoloaders::Inflector
|
34
38
|
loader.push_dir(::Rails.root.join(val))
|
35
39
|
loader.setup
|
36
40
|
end
|
@@ -62,5 +66,7 @@ module Anyway
|
|
62
66
|
|
63
67
|
self.default_config_path = ->(name) { ::Rails.root.join("config", "#{name}.yml") }
|
64
68
|
self.known_environments = %w[test development production]
|
69
|
+
# Don't try read defaults when no key defined
|
70
|
+
self.default_environmental_key = nil
|
65
71
|
end
|
66
72
|
end
|
data/lib/anyway/rbs.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Anyway
|
4
|
+
module RBSGenerator
|
5
|
+
TYPE_TO_CLASS = {
|
6
|
+
string: "String",
|
7
|
+
integer: "Integer",
|
8
|
+
float: "Float",
|
9
|
+
date: "Date",
|
10
|
+
datetime: "DateTime",
|
11
|
+
uri: "URI",
|
12
|
+
boolean: "bool"
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
# Generate RBS signature from a config class
|
16
|
+
def to_rbs
|
17
|
+
*namespace, class_name = name.split("::")
|
18
|
+
|
19
|
+
buf = []
|
20
|
+
indent = 0
|
21
|
+
interface_name = "_Config"
|
22
|
+
|
23
|
+
if namespace.empty?
|
24
|
+
interface_name = "_#{class_name}"
|
25
|
+
else
|
26
|
+
buf << "module #{namespace.join("::")}"
|
27
|
+
indent += 1
|
28
|
+
end
|
29
|
+
|
30
|
+
# Using interface emulates a module we include to provide getters and setters
|
31
|
+
# (thus making `super` possible)
|
32
|
+
buf << "#{" " * indent}interface #{interface_name}"
|
33
|
+
indent += 1
|
34
|
+
|
35
|
+
# Generating setters and getters for config attributes
|
36
|
+
config_attributes.each do |param|
|
37
|
+
type = coercion_mapping[param] || defaults[param.to_s]
|
38
|
+
|
39
|
+
type =
|
40
|
+
case type
|
41
|
+
in NilClass
|
42
|
+
"untyped"
|
43
|
+
in Symbol
|
44
|
+
TYPE_TO_CLASS.fetch(type) { defaults[param] ? "Symbol" : "untyped" }
|
45
|
+
in Array
|
46
|
+
"Array[untyped]"
|
47
|
+
in array:, type:, **nil
|
48
|
+
"Array[#{TYPE_TO_CLASS.fetch(type, "untyped")}]"
|
49
|
+
in Hash
|
50
|
+
"Hash[string,untyped]"
|
51
|
+
in TrueClass | FalseClass
|
52
|
+
"bool"
|
53
|
+
else
|
54
|
+
type.class.to_s
|
55
|
+
end
|
56
|
+
|
57
|
+
getter_type = type
|
58
|
+
getter_type = "#{type}?" unless required_attributes.include?(param)
|
59
|
+
|
60
|
+
buf << "#{" " * indent}def #{param}: () -> #{getter_type}"
|
61
|
+
buf << "#{" " * indent}def #{param}=: (#{type}) -> void"
|
62
|
+
|
63
|
+
if type == "bool" || type == "bool?"
|
64
|
+
buf << "#{" " * indent}def #{param}?: () -> #{getter_type}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
indent -= 1
|
69
|
+
buf << "#{" " * indent}end"
|
70
|
+
|
71
|
+
buf << ""
|
72
|
+
|
73
|
+
buf << "#{" " * indent}class #{class_name} < #{superclass.name}"
|
74
|
+
indent += 1
|
75
|
+
|
76
|
+
buf << "#{" " * indent}include #{interface_name}"
|
77
|
+
|
78
|
+
indent -= 1
|
79
|
+
buf << "#{" " * indent}end"
|
80
|
+
|
81
|
+
unless namespace.empty?
|
82
|
+
buf << "end"
|
83
|
+
end
|
84
|
+
|
85
|
+
buf << ""
|
86
|
+
|
87
|
+
buf.join("\n")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
Config.extend RBSGenerator
|
92
|
+
end
|
data/lib/anyway/tracing.rb
CHANGED
@@ -34,11 +34,11 @@ module Anyway
|
|
34
34
|
|
35
35
|
def record_value(val, *path, **opts)
|
36
36
|
key = path.pop
|
37
|
-
if val.is_a?(Hash)
|
37
|
+
trace = if val.is_a?(Hash)
|
38
38
|
Trace.new.tap { _1.merge_values(val, **opts) }
|
39
39
|
else
|
40
40
|
Trace.new(:value, val, **opts)
|
41
|
-
end
|
41
|
+
end
|
42
42
|
|
43
43
|
target_trace = path.empty? ? self : value.dig(*path)
|
44
44
|
target_trace.value[key.to_s] = trace
|
@@ -86,7 +86,7 @@ module Anyway
|
|
86
86
|
if trace?
|
87
87
|
value.transform_values(&:to_h).tap { _1.default_proc = nil }
|
88
88
|
else
|
89
|
-
{value
|
89
|
+
{value:, source:}
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
@@ -0,0 +1,134 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Anyway
|
4
|
+
# Contains a mapping between type IDs/names and deserializers
|
5
|
+
class TypeRegistry
|
6
|
+
class << self
|
7
|
+
def default
|
8
|
+
@default ||= TypeRegistry.new
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@registry = {}
|
14
|
+
end
|
15
|
+
|
16
|
+
def accept(name_or_object, &block)
|
17
|
+
if !block && !name_or_object.respond_to?(:call)
|
18
|
+
raise ArgumentError, "Please, provide a type casting block or an object implementing #call(val) method"
|
19
|
+
end
|
20
|
+
|
21
|
+
registry[name_or_object] = block || name_or_object
|
22
|
+
end
|
23
|
+
|
24
|
+
def deserialize(raw, type_id, array: false)
|
25
|
+
return if raw.nil?
|
26
|
+
|
27
|
+
caster =
|
28
|
+
if type_id.is_a?(Symbol) || type_id.nil?
|
29
|
+
registry.fetch(type_id) { raise ArgumentError, "Unknown type: #{type_id}" }
|
30
|
+
else
|
31
|
+
raise ArgumentError, "Type must implement #call(val): #{type_id}" unless type_id.respond_to?(:call)
|
32
|
+
type_id
|
33
|
+
end
|
34
|
+
|
35
|
+
if array
|
36
|
+
raw_arr = raw.is_a?(String) ? raw.split(/\s*,\s*/) : Array(raw)
|
37
|
+
raw_arr.map { caster.call(_1) }
|
38
|
+
else
|
39
|
+
caster.call(raw)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def dup
|
44
|
+
new_obj = self.class.allocate
|
45
|
+
new_obj.instance_variable_set(:@registry, registry.dup)
|
46
|
+
new_obj
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
attr_reader :registry
|
52
|
+
end
|
53
|
+
|
54
|
+
TypeRegistry.default.tap do |obj|
|
55
|
+
obj.accept(nil, &:itself)
|
56
|
+
obj.accept(:string, &:to_s)
|
57
|
+
obj.accept(:integer, &:to_i)
|
58
|
+
obj.accept(:float, &:to_f)
|
59
|
+
|
60
|
+
obj.accept(:date) do
|
61
|
+
require "date" unless defined?(::Date)
|
62
|
+
|
63
|
+
next _1 if _1.is_a?(::Date)
|
64
|
+
|
65
|
+
next _1.to_date if _1.respond_to?(:to_date)
|
66
|
+
|
67
|
+
::Date.parse(_1)
|
68
|
+
end
|
69
|
+
|
70
|
+
obj.accept(:datetime) do
|
71
|
+
require "date" unless defined?(::Date)
|
72
|
+
|
73
|
+
next _1 if _1.is_a?(::DateTime)
|
74
|
+
|
75
|
+
next _1.to_datetime if _1.respond_to?(:to_datetime)
|
76
|
+
|
77
|
+
::DateTime.parse(_1)
|
78
|
+
end
|
79
|
+
|
80
|
+
obj.accept(:uri) do
|
81
|
+
require "uri" unless defined?(::URI)
|
82
|
+
|
83
|
+
next _1 if _1.is_a?(::URI)
|
84
|
+
|
85
|
+
::URI.parse(_1)
|
86
|
+
end
|
87
|
+
|
88
|
+
obj.accept(:boolean) do
|
89
|
+
_1.to_s.match?(/\A(true|t|yes|y|1)\z/i)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# TypeCaster is an object responsible for type-casting.
|
94
|
+
# It uses a provided types registry and mapping, and also
|
95
|
+
# accepts a fallback typecaster.
|
96
|
+
class TypeCaster
|
97
|
+
using Ext::DeepDup
|
98
|
+
using Ext::Hash
|
99
|
+
|
100
|
+
def initialize(mapping, registry: TypeRegistry.default, fallback: ::Anyway::AutoCast)
|
101
|
+
@mapping = mapping.deep_dup
|
102
|
+
@registry = registry
|
103
|
+
@fallback = fallback
|
104
|
+
end
|
105
|
+
|
106
|
+
def coerce(key, val, config: mapping)
|
107
|
+
caster_config = config[key.to_sym]
|
108
|
+
|
109
|
+
return fallback.coerce(key, val) unless caster_config
|
110
|
+
|
111
|
+
case caster_config
|
112
|
+
in array:, type:, **nil
|
113
|
+
registry.deserialize(val, type, array: array)
|
114
|
+
in Hash
|
115
|
+
return val unless val.is_a?(Hash)
|
116
|
+
|
117
|
+
caster_config.each do |k, v|
|
118
|
+
ks = k.to_s
|
119
|
+
next unless val.key?(ks)
|
120
|
+
|
121
|
+
val[ks] = coerce(k, val[ks], config: caster_config)
|
122
|
+
end
|
123
|
+
|
124
|
+
val
|
125
|
+
else
|
126
|
+
registry.deserialize(val, caster_config)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
private
|
131
|
+
|
132
|
+
attr_reader :mapping, :registry, :fallback
|
133
|
+
end
|
134
|
+
end
|
data/lib/anyway/version.rb
CHANGED
data/lib/anyway_config.rb
CHANGED
@@ -17,8 +17,10 @@ require "anyway/settings"
|
|
17
17
|
require "anyway/tracing"
|
18
18
|
require "anyway/config"
|
19
19
|
require "anyway/auto_cast"
|
20
|
+
require "anyway/type_casting"
|
20
21
|
require "anyway/env"
|
21
22
|
require "anyway/loaders"
|
23
|
+
require "anyway/rbs"
|
22
24
|
|
23
25
|
module Anyway # :nodoc:
|
24
26
|
class << self
|
@@ -4,7 +4,7 @@
|
|
4
4
|
class ApplicationConfig < Anyway::Config
|
5
5
|
class << self
|
6
6
|
# Make it possible to access a singleton config instance
|
7
|
-
# via class methods (i.e., without
|
7
|
+
# via class methods (i.e., without explicitly calling `instance`)
|
8
8
|
delegate_missing_to :instance
|
9
9
|
|
10
10
|
private
|
@@ -0,0 +1,129 @@
|
|
1
|
+
module Anyway
|
2
|
+
def self.env: -> Env
|
3
|
+
def self.loaders: -> Loaders::Registry
|
4
|
+
|
5
|
+
class Settings
|
6
|
+
def self.default_config_path=: (^(untyped) -> String val) -> ^(untyped) -> String?
|
7
|
+
def self.future: -> Future
|
8
|
+
|
9
|
+
class Future
|
10
|
+
def self.setting: (untyped name, untyped default_value) -> untyped
|
11
|
+
def self.settings: -> Hash[untyped, untyped]
|
12
|
+
def use: (*untyped names) -> untyped
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module Tracing
|
17
|
+
class Trace
|
18
|
+
def merge!: (Trace another_trace) -> void
|
19
|
+
end
|
20
|
+
|
21
|
+
def inspect: -> String
|
22
|
+
def self.capture: ?{ -> Hash[untyped, untyped] } -> nil
|
23
|
+
def self.trace_stack: -> Array[untyped]
|
24
|
+
def self.current_trace: -> Trace?
|
25
|
+
def self.source_stack: -> Array[untyped]
|
26
|
+
def self.current_trace_source: -> {type: :accessor, called_from: untyped}
|
27
|
+
def self.with_trace_source: (untyped src) -> untyped
|
28
|
+
def trace!: (Symbol, *Array[String] paths, **untyped) ?{ -> Hash[untyped, untyped]} -> Hash[untyped, untyped]
|
29
|
+
def self.trace!: (Symbol, *Array[String] paths, **untyped) ?{ -> Hash[untyped, untyped]} -> Hash[untyped, untyped]
|
30
|
+
end
|
31
|
+
|
32
|
+
module RBSGenerator
|
33
|
+
def to_rbs: -> String
|
34
|
+
end
|
35
|
+
|
36
|
+
module OptparseConfig
|
37
|
+
def option_parser: -> OptionParser
|
38
|
+
def parse_options!: (Array[String]) -> void
|
39
|
+
|
40
|
+
module ClassMethods
|
41
|
+
def ignore_options: (*Symbol args) -> void
|
42
|
+
def describe_options: (**(String | {desc: String, type: Module})) -> void
|
43
|
+
def flag_options: (*Symbol args) -> void
|
44
|
+
def extend_options: { (OptionParser, Config) -> void } -> void
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
module DynamicConfig
|
49
|
+
module ClassMethods
|
50
|
+
def for: (String | Symbol name, ?auto_cast: bool, **untyped) -> Hash[untyped, untyped]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
type valueType = Symbol | nil
|
55
|
+
type arrayType = {array: bool, type: valueType}
|
56
|
+
type hashType = Hash[Symbol, valueType | arrayType | hashType]
|
57
|
+
|
58
|
+
type mappingType = valueType | arrayType | hashType
|
59
|
+
|
60
|
+
class Config
|
61
|
+
extend RBSGenerator
|
62
|
+
extend DynamicConfig::ClassMethods
|
63
|
+
extend OptparseConfig::ClassMethods
|
64
|
+
include DynamicConfig
|
65
|
+
include OptparseConfig
|
66
|
+
|
67
|
+
def self.attr_config: (*Symbol args, **untyped) -> void
|
68
|
+
def self.defaults: -> Hash[String, untyped]
|
69
|
+
def self.config_attributes: -> Array[Symbol]?
|
70
|
+
def self.required: (*Symbol names) -> void
|
71
|
+
def self.required_attributes: -> Array[Symbol]
|
72
|
+
def self.on_load: (*Symbol callbacks) ?{ () -> void } -> void
|
73
|
+
def self.config_name: (?(Symbol | String) val) -> String?
|
74
|
+
def self.env_prefix: (?(Symbol | String) val) -> String
|
75
|
+
def self.coerce_types: (**mappingType) -> void
|
76
|
+
def self.coercion_mapping: -> Hash[untyped, untyped]?
|
77
|
+
def self.disable_auto_cast!: -> void
|
78
|
+
|
79
|
+
attr_reader config_name: String
|
80
|
+
attr_reader env_prefix: String
|
81
|
+
|
82
|
+
def initialize: (?Hash[Symbol | String, untyped] overrides) -> void
|
83
|
+
def reload: (?Hash[Symbol | String, untyped] overrides) -> Config
|
84
|
+
def clear: -> void
|
85
|
+
def load: (Hash[Symbol | String, untyped] overrides) -> Config
|
86
|
+
def dig: (*(Symbol | String) keys) -> untyped
|
87
|
+
def to_h: -> Hash[untyped, untyped]
|
88
|
+
def dup: -> Config
|
89
|
+
def deconstruct_keys: (untyped keys) -> Hash[untyped, untyped]
|
90
|
+
def to_source_trace: -> Hash[String, untyped]
|
91
|
+
def inspect: -> String
|
92
|
+
def pretty_print: (untyped q) -> untyped
|
93
|
+
|
94
|
+
private
|
95
|
+
attr_reader values: Hash[untyped, untyped]
|
96
|
+
def raise_validation_error: (String msg) -> void
|
97
|
+
|
98
|
+
class Error < StandardError
|
99
|
+
end
|
100
|
+
|
101
|
+
class ValidationError < Error
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
class Env
|
106
|
+
def clear: -> void
|
107
|
+
def fetch: (String prefix) -> untyped
|
108
|
+
def fetch_with_trace: (String prefix) -> [untyped, Tracing::Trace?]
|
109
|
+
end
|
110
|
+
|
111
|
+
module Loaders
|
112
|
+
class Base
|
113
|
+
include Tracing
|
114
|
+
|
115
|
+
def self.call: (?local: bool, **untyped) -> untyped
|
116
|
+
def initialize: (local: bool) -> void
|
117
|
+
def use_local?: -> bool
|
118
|
+
end
|
119
|
+
|
120
|
+
class Registry
|
121
|
+
def prepend: (Symbol id, Base loader) -> void
|
122
|
+
def append: (Symbol id, Base loader) -> void
|
123
|
+
def insert_before: (Symbol another_id, Symbol id, Base loader) -> void
|
124
|
+
def insert_after: (Symbol another_id, Symbol id, Base loader) -> void
|
125
|
+
def override: (Symbol id, Base loader) -> void
|
126
|
+
def delete: (Symbol id) -> void
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
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.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-next-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.14.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.14.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: ammeter
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 0.14.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 0.14.0
|
97
97
|
description: "\n Configuration DSL for Ruby libraries and applications.\n Allows
|
98
98
|
you to easily follow the twelve-factor application principles (https://12factor.net/config).\n
|
99
99
|
\ "
|
@@ -106,21 +106,23 @@ files:
|
|
106
106
|
- CHANGELOG.md
|
107
107
|
- LICENSE.txt
|
108
108
|
- README.md
|
109
|
-
- lib/.rbnext/1995.next/anyway/config.rb
|
110
|
-
- lib/.rbnext/1995.next/anyway/dynamic_config.rb
|
111
|
-
- lib/.rbnext/1995.next/anyway/env.rb
|
112
|
-
- lib/.rbnext/1995.next/anyway/loaders/base.rb
|
113
|
-
- lib/.rbnext/1995.next/anyway/tracing.rb
|
114
109
|
- lib/.rbnext/2.7/anyway/auto_cast.rb
|
115
110
|
- lib/.rbnext/2.7/anyway/config.rb
|
116
|
-
- lib/.rbnext/2.7/anyway/option_parser_builder.rb
|
117
111
|
- lib/.rbnext/2.7/anyway/rails/loaders/yaml.rb
|
112
|
+
- lib/.rbnext/2.7/anyway/rbs.rb
|
118
113
|
- lib/.rbnext/2.7/anyway/settings.rb
|
119
114
|
- lib/.rbnext/2.7/anyway/tracing.rb
|
115
|
+
- lib/.rbnext/2.7/anyway/type_casting.rb
|
116
|
+
- lib/.rbnext/3.0/anyway/auto_cast.rb
|
120
117
|
- lib/.rbnext/3.0/anyway/config.rb
|
121
118
|
- lib/.rbnext/3.0/anyway/loaders.rb
|
122
119
|
- lib/.rbnext/3.0/anyway/loaders/base.rb
|
123
120
|
- lib/.rbnext/3.0/anyway/tracing.rb
|
121
|
+
- lib/.rbnext/3.1/anyway/config.rb
|
122
|
+
- lib/.rbnext/3.1/anyway/dynamic_config.rb
|
123
|
+
- lib/.rbnext/3.1/anyway/env.rb
|
124
|
+
- lib/.rbnext/3.1/anyway/loaders/base.rb
|
125
|
+
- lib/.rbnext/3.1/anyway/tracing.rb
|
124
126
|
- lib/anyway.rb
|
125
127
|
- lib/anyway/auto_cast.rb
|
126
128
|
- lib/anyway/config.rb
|
@@ -143,10 +145,12 @@ files:
|
|
143
145
|
- lib/anyway/rails/loaders/yaml.rb
|
144
146
|
- lib/anyway/rails/settings.rb
|
145
147
|
- lib/anyway/railtie.rb
|
148
|
+
- lib/anyway/rbs.rb
|
146
149
|
- lib/anyway/settings.rb
|
147
150
|
- lib/anyway/testing.rb
|
148
151
|
- lib/anyway/testing/helpers.rb
|
149
152
|
- lib/anyway/tracing.rb
|
153
|
+
- lib/anyway/type_casting.rb
|
150
154
|
- lib/anyway/utils/deep_merge.rb
|
151
155
|
- lib/anyway/version.rb
|
152
156
|
- lib/anyway_config.rb
|
@@ -159,6 +163,7 @@ files:
|
|
159
163
|
- lib/generators/anyway/install/USAGE
|
160
164
|
- lib/generators/anyway/install/install_generator.rb
|
161
165
|
- lib/generators/anyway/install/templates/application_config.rb.tt
|
166
|
+
- sig/anyway_config.rbs
|
162
167
|
homepage: http://github.com/palkan/anyway_config
|
163
168
|
licenses:
|
164
169
|
- MIT
|
@@ -168,7 +173,7 @@ metadata:
|
|
168
173
|
documentation_uri: http://github.com/palkan/anyway_config
|
169
174
|
homepage_uri: http://github.com/palkan/anyway_config
|
170
175
|
source_code_uri: http://github.com/palkan/anyway_config
|
171
|
-
post_install_message:
|
176
|
+
post_install_message:
|
172
177
|
rdoc_options: []
|
173
178
|
require_paths:
|
174
179
|
- lib
|
@@ -183,8 +188,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
188
|
- !ruby/object:Gem::Version
|
184
189
|
version: '0'
|
185
190
|
requirements: []
|
186
|
-
rubygems_version: 3.
|
187
|
-
signing_key:
|
191
|
+
rubygems_version: 3.2.22
|
192
|
+
signing_key:
|
188
193
|
specification_version: 4
|
189
194
|
summary: Configuration DSL for Ruby libraries and applications
|
190
195
|
test_files: []
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "optparse"
|
4
|
-
|
5
|
-
module Anyway # :nodoc:
|
6
|
-
# Initializes the OptionParser instance using the given configuration
|
7
|
-
class OptionParserBuilder
|
8
|
-
class << self
|
9
|
-
def call(options)
|
10
|
-
OptionParser.new do |opts|
|
11
|
-
opts.accept(AutoCast) { |_1| AutoCast.call(_1) }
|
12
|
-
|
13
|
-
options.each do |key, descriptor|
|
14
|
-
opts.on(*option_parser_on_args(key, **descriptor)) do |val|
|
15
|
-
yield [key, val]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def option_parser_on_args(key, flag: false, desc: nil, type: AutoCast)
|
24
|
-
on_args = ["--#{key.to_s.tr("_", "-")}#{flag ? "" : " VALUE"}"]
|
25
|
-
on_args << type unless flag
|
26
|
-
on_args << desc unless desc.nil?
|
27
|
-
on_args
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|