anyway_config 2.0.6 → 2.2.2

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +241 -181
  3. data/README.md +237 -12
  4. data/lib/.rbnext/1995.next/anyway/config.rb +438 -0
  5. data/lib/.rbnext/1995.next/anyway/dynamic_config.rb +31 -0
  6. data/lib/.rbnext/1995.next/anyway/env.rb +56 -0
  7. data/lib/.rbnext/1995.next/anyway/loaders/base.rb +21 -0
  8. data/lib/.rbnext/1995.next/anyway/tracing.rb +181 -0
  9. data/lib/.rbnext/2.7/anyway/auto_cast.rb +39 -19
  10. data/lib/.rbnext/2.7/anyway/config.rb +60 -15
  11. data/lib/.rbnext/2.7/anyway/rails/loaders/yaml.rb +30 -0
  12. data/lib/.rbnext/2.7/anyway/rbs.rb +92 -0
  13. data/lib/.rbnext/2.7/anyway/settings.rb +79 -0
  14. data/lib/.rbnext/2.7/anyway/tracing.rb +1 -1
  15. data/lib/.rbnext/2.7/anyway/type_casting.rb +143 -0
  16. data/lib/.rbnext/3.0/anyway/auto_cast.rb +53 -0
  17. data/lib/.rbnext/{2.8 → 3.0}/anyway/config.rb +60 -15
  18. data/lib/.rbnext/{2.8 → 3.0}/anyway/loaders/base.rb +0 -0
  19. data/lib/.rbnext/{2.8 → 3.0}/anyway/loaders.rb +0 -0
  20. data/lib/.rbnext/{2.8 → 3.0}/anyway/tracing.rb +1 -1
  21. data/lib/anyway/auto_cast.rb +39 -19
  22. data/lib/anyway/config.rb +74 -29
  23. data/lib/anyway/dynamic_config.rb +6 -2
  24. data/lib/anyway/env.rb +1 -1
  25. data/lib/anyway/ext/deep_dup.rb +12 -0
  26. data/lib/anyway/ext/hash.rb +0 -12
  27. data/lib/anyway/loaders/base.rb +1 -1
  28. data/lib/anyway/loaders/env.rb +3 -1
  29. data/lib/anyway/loaders/yaml.rb +9 -5
  30. data/lib/anyway/option_parser_builder.rb +1 -3
  31. data/lib/anyway/optparse_config.rb +5 -7
  32. data/lib/anyway/rails/loaders/credentials.rb +4 -4
  33. data/lib/anyway/rails/loaders/secrets.rb +6 -8
  34. data/lib/anyway/rails/loaders/yaml.rb +11 -0
  35. data/lib/anyway/rails/settings.rb +9 -2
  36. data/lib/anyway/rbs.rb +92 -0
  37. data/lib/anyway/settings.rb +52 -2
  38. data/lib/anyway/tracing.rb +6 -6
  39. data/lib/anyway/type_casting.rb +134 -0
  40. data/lib/anyway/utils/deep_merge.rb +21 -0
  41. data/lib/anyway/version.rb +1 -1
  42. data/lib/anyway_config.rb +4 -0
  43. data/sig/anyway_config.rbs +129 -0
  44. metadata +42 -15
  45. data/lib/.rbnext/2.7/anyway/option_parser_builder.rb +0 -31
@@ -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.0.6
4
+ version: 2.2.2
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: 2020-07-07 00:00:00.000000000 Z
11
+ date: 2021-10-26 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.8.0
19
+ version: 0.11.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.8.0
26
+ version: 0.11.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ammeter
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -70,14 +70,14 @@ dependencies:
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '3.8'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.8'
83
83
  - !ruby/object:Gem::Dependency
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.8'
97
+ - !ruby/object:Gem::Dependency
98
+ name: steep
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: "\n Configuration DSL for Ruby libraries and applications.\n Allows
98
112
  you to easily follow the twelve-factor application principles (https://12factor.net/config).\n
99
113
  \ "
@@ -106,14 +120,23 @@ files:
106
120
  - CHANGELOG.md
107
121
  - LICENSE.txt
108
122
  - README.md
123
+ - lib/.rbnext/1995.next/anyway/config.rb
124
+ - lib/.rbnext/1995.next/anyway/dynamic_config.rb
125
+ - lib/.rbnext/1995.next/anyway/env.rb
126
+ - lib/.rbnext/1995.next/anyway/loaders/base.rb
127
+ - lib/.rbnext/1995.next/anyway/tracing.rb
109
128
  - lib/.rbnext/2.7/anyway/auto_cast.rb
110
129
  - lib/.rbnext/2.7/anyway/config.rb
111
- - lib/.rbnext/2.7/anyway/option_parser_builder.rb
130
+ - lib/.rbnext/2.7/anyway/rails/loaders/yaml.rb
131
+ - lib/.rbnext/2.7/anyway/rbs.rb
132
+ - lib/.rbnext/2.7/anyway/settings.rb
112
133
  - lib/.rbnext/2.7/anyway/tracing.rb
113
- - lib/.rbnext/2.8/anyway/config.rb
114
- - lib/.rbnext/2.8/anyway/loaders.rb
115
- - lib/.rbnext/2.8/anyway/loaders/base.rb
116
- - lib/.rbnext/2.8/anyway/tracing.rb
134
+ - lib/.rbnext/2.7/anyway/type_casting.rb
135
+ - lib/.rbnext/3.0/anyway/auto_cast.rb
136
+ - lib/.rbnext/3.0/anyway/config.rb
137
+ - lib/.rbnext/3.0/anyway/loaders.rb
138
+ - lib/.rbnext/3.0/anyway/loaders/base.rb
139
+ - lib/.rbnext/3.0/anyway/tracing.rb
117
140
  - lib/anyway.rb
118
141
  - lib/anyway/auto_cast.rb
119
142
  - lib/anyway/config.rb
@@ -136,10 +159,13 @@ files:
136
159
  - lib/anyway/rails/loaders/yaml.rb
137
160
  - lib/anyway/rails/settings.rb
138
161
  - lib/anyway/railtie.rb
162
+ - lib/anyway/rbs.rb
139
163
  - lib/anyway/settings.rb
140
164
  - lib/anyway/testing.rb
141
165
  - lib/anyway/testing/helpers.rb
142
166
  - lib/anyway/tracing.rb
167
+ - lib/anyway/type_casting.rb
168
+ - lib/anyway/utils/deep_merge.rb
143
169
  - lib/anyway/version.rb
144
170
  - lib/anyway_config.rb
145
171
  - lib/generators/anyway/app_config/USAGE
@@ -151,6 +177,7 @@ files:
151
177
  - lib/generators/anyway/install/USAGE
152
178
  - lib/generators/anyway/install/install_generator.rb
153
179
  - lib/generators/anyway/install/templates/application_config.rb.tt
180
+ - sig/anyway_config.rbs
154
181
  homepage: http://github.com/palkan/anyway_config
155
182
  licenses:
156
183
  - MIT
@@ -160,7 +187,7 @@ metadata:
160
187
  documentation_uri: http://github.com/palkan/anyway_config
161
188
  homepage_uri: http://github.com/palkan/anyway_config
162
189
  source_code_uri: http://github.com/palkan/anyway_config
163
- post_install_message:
190
+ post_install_message:
164
191
  rdoc_options: []
165
192
  require_paths:
166
193
  - lib
@@ -175,8 +202,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
202
  - !ruby/object:Gem::Version
176
203
  version: '0'
177
204
  requirements: []
178
- rubygems_version: 3.0.6
179
- signing_key:
205
+ rubygems_version: 3.2.22
206
+ signing_key:
180
207
  specification_version: 4
181
208
  summary: Configuration DSL for Ruby libraries and applications
182
209
  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