dry-system 0.27.2 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/dry-system.gemspec +4 -6
- data/lib/dry/system/config/component_dir.rb +0 -34
- data/lib/dry/system/config/namespaces.rb +1 -13
- data/lib/dry/system/container.rb +19 -56
- data/lib/dry/system/errors.rb +4 -5
- data/lib/dry/system/importer.rb +1 -2
- data/lib/dry/system/plugins/dependency_graph/strategies.rb +1 -1
- data/lib/dry/system/plugins/notifications.rb +1 -1
- data/lib/dry/system/provider/source.rb +3 -51
- data/lib/dry/system/provider/source_dsl.rb +2 -39
- data/lib/dry/system/provider.rb +2 -2
- data/lib/dry/system/provider_registrar.rb +1 -24
- data/lib/dry/system/provider_source_registry.rb +1 -13
- data/lib/dry/system/provider_sources/settings/config.rb +8 -17
- data/lib/dry/system/provider_sources/settings/loader.rb +0 -6
- data/lib/dry/system/provider_sources/settings.rb +1 -1
- data/lib/dry/system/stubs.rb +6 -2
- data/lib/dry/system/version.rb +1 -1
- data/lib/dry/system.rb +1 -28
- metadata +29 -58
- data/lib/dry/system/components.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6f625944296b640e8b964f73c561bfe28fb16574bcbe716221b7f643e86d930
|
4
|
+
data.tar.gz: b0195e7bb3f0979962b1687d7473552e11d97647e4d8c97fe067c35a453df8eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6607e793820ddb9c732e3c924725fcf4d0dbed7a88559a97f260435bfc7776055d14d529c9a00a3cfe39a4906187190195b45debd398f0127758eddc3093cc1d
|
7
|
+
data.tar.gz: fbc14360a133b341886b2279c1dd8a69ceea18f7fa9589e32f90acbbf83e5e72c492024868fc16824249b526b01f90cb0919963bd2f1a212588ca23711fd88dc
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
2
2
|
|
3
|
+
## 0.28.0 unreleased
|
4
|
+
|
5
|
+
|
6
|
+
### Changed
|
7
|
+
|
8
|
+
- This version uses dry-core 1.0 and dry-configurable 1.0 (@solnic + @flash-gordon)
|
9
|
+
|
10
|
+
[Compare v0.27.2...v0.28.0](https://github.com/dry-rb/dry-system/compare/v0.27.2...v0.28.0)
|
11
|
+
|
12
|
+
## 0.27.2 2022-10-17
|
13
|
+
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
|
17
|
+
- Removed remaining manual require left-overs (@solnic)
|
18
|
+
|
19
|
+
|
20
|
+
[Compare v0.27.1...v0.27.2](https://github.com/dry-rb/dry-system/compare/v0.27.1...v0.27.2)
|
21
|
+
|
3
22
|
## 0.27.1 2022-10-15
|
4
23
|
|
5
24
|
|
data/dry-system.gemspec
CHANGED
@@ -29,12 +29,10 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.required_ruby_version = ">= 2.7.0"
|
30
30
|
|
31
31
|
# to update dependencies edit project.yml
|
32
|
-
spec.add_runtime_dependency "
|
33
|
-
spec.add_runtime_dependency "dry-
|
34
|
-
spec.add_runtime_dependency "dry-
|
35
|
-
spec.add_runtime_dependency "dry-
|
36
|
-
spec.add_runtime_dependency "dry-core", "~> 0.9", ">= 0.9.0"
|
37
|
-
spec.add_runtime_dependency "dry-inflector", "~> 0.1", ">= 0.1.2"
|
32
|
+
spec.add_runtime_dependency "dry-auto_inject", "~> 1.0.0.rc1", "< 2"
|
33
|
+
spec.add_runtime_dependency "dry-configurable", "~> 1.0", "< 2"
|
34
|
+
spec.add_runtime_dependency "dry-core", "~> 1.0", "< 2"
|
35
|
+
spec.add_runtime_dependency "dry-inflector", "~> 1.0", "< 2"
|
38
36
|
|
39
37
|
spec.add_development_dependency "bundler"
|
40
38
|
spec.add_development_dependency "rake"
|
@@ -190,40 +190,6 @@ module Dry
|
|
190
190
|
# @api public
|
191
191
|
setting :add_to_load_path, default: true
|
192
192
|
|
193
|
-
# @api public
|
194
|
-
def default_namespace=(namespace)
|
195
|
-
Dry::Core::Deprecations.announce(
|
196
|
-
"Dry::System::Config::ComponentDir#default_namespace=",
|
197
|
-
"Add a namespace instead: `dir.namespaces.add #{namespace.to_s.inspect}, key: nil`",
|
198
|
-
tag: "dry-system",
|
199
|
-
uplevel: 1
|
200
|
-
)
|
201
|
-
|
202
|
-
# We don't have the configured separator here, so the best we can do is guess
|
203
|
-
# that it's a dot
|
204
|
-
namespace_path = namespace.gsub(".", PATH_SEPARATOR)
|
205
|
-
|
206
|
-
return if namespaces.namespaces[namespace_path]
|
207
|
-
|
208
|
-
namespaces.add namespace_path, key: nil
|
209
|
-
end
|
210
|
-
|
211
|
-
# @api public
|
212
|
-
def default_namespace
|
213
|
-
Dry::Core::Deprecations.announce(
|
214
|
-
"Dry::System::Config::ComponentDir#default_namespace",
|
215
|
-
"Use namespaces instead, e.g. `dir.namespaces`",
|
216
|
-
tag: "dry-system",
|
217
|
-
uplevel: 1
|
218
|
-
)
|
219
|
-
|
220
|
-
ns_path = namespaces.to_a.reject(&:root?).first&.path
|
221
|
-
|
222
|
-
# We don't have the configured separator here, so the best we can do is guess
|
223
|
-
# that it's a dot
|
224
|
-
ns_path&.gsub(PATH_SEPARATOR, ".")
|
225
|
-
end
|
226
|
-
|
227
193
|
# @!endgroup
|
228
194
|
|
229
195
|
# Returns the component dir path, relative to the configured container root
|
@@ -44,19 +44,7 @@ module Dry
|
|
44
44
|
# @return [Namespace, nil] the root namespace, if configured
|
45
45
|
#
|
46
46
|
# @api public
|
47
|
-
def root
|
48
|
-
if options.any?
|
49
|
-
Dry::Core::Deprecations.announce(
|
50
|
-
"Dry::System::Config::Namespaces#root (with arguments)",
|
51
|
-
"Use `#add_root(key: nil, const: nil)` instead",
|
52
|
-
tag: "dry-system",
|
53
|
-
uplevel: 1
|
54
|
-
)
|
55
|
-
|
56
|
-
add_root(**options)
|
57
|
-
return
|
58
|
-
end
|
59
|
-
|
47
|
+
def root
|
60
48
|
namespaces[Namespace::ROOT_PATH]
|
61
49
|
end
|
62
50
|
|
data/lib/dry/system/container.rb
CHANGED
@@ -4,7 +4,6 @@ require "pathname"
|
|
4
4
|
|
5
5
|
require "dry/configurable"
|
6
6
|
require "dry/auto_inject"
|
7
|
-
require "dry/container"
|
8
7
|
require "dry/inflector"
|
9
8
|
|
10
9
|
module Dry
|
@@ -53,13 +52,12 @@ module Dry
|
|
53
52
|
#
|
54
53
|
# @api public
|
55
54
|
class Container
|
56
|
-
extend Dry::Container::Mixin
|
55
|
+
extend Dry::Core::Container::Mixin
|
57
56
|
extend Dry::System::Plugins
|
58
57
|
|
59
58
|
setting :name
|
60
59
|
setting :root, default: Pathname.pwd.freeze, constructor: ->(path) { Pathname(path) }
|
61
60
|
setting :provider_dirs, default: ["system/providers"]
|
62
|
-
setting :bootable_dirs # Deprecated for provider_dirs, see .provider_paths below
|
63
61
|
setting :registrations_dir, default: "system/registrations"
|
64
62
|
setting :component_dirs, default: Config::ComponentDirs.new, cloneable: true
|
65
63
|
setting :exports, reader: true
|
@@ -73,8 +71,6 @@ module Dry
|
|
73
71
|
config.namespace_separator = KEY_SEPARATOR
|
74
72
|
|
75
73
|
class << self
|
76
|
-
extend Dry::Core::Deprecations["Dry::System::Container"]
|
77
|
-
|
78
74
|
# @!method config
|
79
75
|
# Returns the configuration for the container
|
80
76
|
#
|
@@ -152,46 +148,35 @@ module Dry
|
|
152
148
|
#
|
153
149
|
# @example
|
154
150
|
# # system/container.rb
|
151
|
+
# require "dry/system/container"
|
152
|
+
# require "logger"
|
153
|
+
#
|
155
154
|
# class Core < Dry::System::Container
|
156
|
-
#
|
157
|
-
# config.root = Pathname("/path/to/app")
|
158
|
-
# config.auto_register = %w(lib/apis lib/core)
|
159
|
-
# end
|
155
|
+
# register("logger", Logger.new($stdout))
|
160
156
|
# end
|
161
157
|
#
|
162
158
|
# # apps/my_app/system/container.rb
|
163
159
|
# require 'system/container'
|
164
160
|
#
|
165
161
|
# class MyApp < Dry::System::Container
|
166
|
-
#
|
167
|
-
# config.root = Pathname("/path/to/app")
|
168
|
-
# config.auto_register = %w(lib/apis lib/core)
|
169
|
-
# end
|
170
|
-
#
|
171
|
-
# import core: Core
|
162
|
+
# import(from: Core, as: :core)
|
172
163
|
# end
|
173
164
|
#
|
174
|
-
#
|
165
|
+
# MyApp.import(keys: ["logger"], from: Core, as: :core2)
|
166
|
+
#
|
167
|
+
# MyApp["core.logger"].info("Test")
|
168
|
+
# MyApp["core2.logger"].info("Test2")
|
169
|
+
#
|
170
|
+
# @param keys [Array<String>] Keys for the components to import
|
171
|
+
# @param from [Class] The container to import from
|
172
|
+
# @param as [Symbol] Namespace to use for the components of the imported container
|
173
|
+
#
|
174
|
+
# @raise [Dry::System::ContainerAlreadyFinalizedError] if the container has already
|
175
|
+
# been finalized
|
175
176
|
#
|
176
177
|
# @api public
|
177
|
-
def import(
|
178
|
-
if
|
179
|
-
Dry::Core::Deprecations.announce(
|
180
|
-
"Dry::System::Container.import with {namespace => container} hash",
|
181
|
-
"Use Dry::System::Container.import(from: container, as: namespace) instead",
|
182
|
-
tag: "dry-system",
|
183
|
-
uplevel: 1
|
184
|
-
)
|
185
|
-
|
186
|
-
deprecated_import_hash.each do |namespace, container|
|
187
|
-
importer.register(container: container, namespace: namespace)
|
188
|
-
end
|
189
|
-
return self
|
190
|
-
elsif from == Undefined || as == Undefined
|
191
|
-
# These keyword arguments can become properly required in the params list once
|
192
|
-
# we remove the deprecation shim above
|
193
|
-
raise ArgumentError, "required keyword arguments: :from, :as"
|
194
|
-
end
|
178
|
+
def import(from:, as:, keys: nil)
|
179
|
+
raise Dry::System::ContainerAlreadyFinalizedError if finalized?
|
195
180
|
|
196
181
|
importer.register(container: from, namespace: as, keys: keys)
|
197
182
|
|
@@ -291,26 +276,6 @@ module Dry
|
|
291
276
|
|
292
277
|
# rubocop:enable Layout/LineLength
|
293
278
|
|
294
|
-
# @see .register_provider
|
295
|
-
# @api public
|
296
|
-
def boot(name, **opts, &block)
|
297
|
-
Dry::Core::Deprecations.announce(
|
298
|
-
"Dry::System::Container.boot",
|
299
|
-
"Use `Dry::System::Container.register_provider` instead",
|
300
|
-
tag: "dry-system",
|
301
|
-
uplevel: 1
|
302
|
-
)
|
303
|
-
|
304
|
-
register_provider(
|
305
|
-
name,
|
306
|
-
namespace: opts[:namespace],
|
307
|
-
from: opts[:from],
|
308
|
-
source: opts[:key],
|
309
|
-
&block
|
310
|
-
)
|
311
|
-
end
|
312
|
-
deprecate :finalize, :boot
|
313
|
-
|
314
279
|
# Return if a container was finalized
|
315
280
|
#
|
316
281
|
# @return [TrueClass, FalseClass]
|
@@ -403,7 +368,6 @@ module Dry
|
|
403
368
|
providers.prepare(name)
|
404
369
|
self
|
405
370
|
end
|
406
|
-
deprecate :init, :prepare
|
407
371
|
|
408
372
|
# Stop a specific component but calls only `stop` lifecycle trigger
|
409
373
|
#
|
@@ -563,7 +527,6 @@ module Dry
|
|
563
527
|
def providers
|
564
528
|
@providers ||= config.provider_registrar.new(self)
|
565
529
|
end
|
566
|
-
deprecate :booter, :providers
|
567
530
|
|
568
531
|
# @api private
|
569
532
|
def auto_registrar
|
data/lib/dry/system/errors.rb
CHANGED
@@ -2,7 +2,10 @@
|
|
2
2
|
|
3
3
|
module Dry
|
4
4
|
module System
|
5
|
-
|
5
|
+
# Error raised when import is called on an already finalized container
|
6
|
+
#
|
7
|
+
# @api public
|
8
|
+
ContainerAlreadyFinalizedError = Class.new(StandardError)
|
6
9
|
|
7
10
|
# Error raised when a component dir is added to configuration more than once
|
8
11
|
#
|
@@ -43,8 +46,6 @@ module Dry
|
|
43
46
|
super("Provider #{provider_name.inspect} has already been registered")
|
44
47
|
end
|
45
48
|
end
|
46
|
-
DuplicatedComponentKeyError = ProviderAlreadyRegisteredError
|
47
|
-
deprecate_constant :DuplicatedComponentKeyError
|
48
49
|
|
49
50
|
# Error raised when a named provider could not be found
|
50
51
|
#
|
@@ -54,8 +55,6 @@ module Dry
|
|
54
55
|
super("Provider #{name.inspect} not found")
|
55
56
|
end
|
56
57
|
end
|
57
|
-
InvalidComponentError = ProviderNotFoundError
|
58
|
-
deprecate_constant :InvalidComponentError
|
59
58
|
|
60
59
|
# Error raised when a named provider source could not be found
|
61
60
|
#
|
data/lib/dry/system/importer.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "dry/container"
|
4
3
|
require "dry/system/constants"
|
5
4
|
|
6
5
|
module Dry
|
@@ -106,7 +105,7 @@ module Dry
|
|
106
105
|
end
|
107
106
|
|
108
107
|
def build_merge_container(other, keys)
|
109
|
-
keys.each_with_object(
|
108
|
+
keys.each_with_object(Core::Container.new) { |key, ic|
|
110
109
|
next unless other.key?(key)
|
111
110
|
|
112
111
|
# Access the other container's items directly so that we can preserve all their
|
@@ -37,11 +37,11 @@ module Dry
|
|
37
37
|
# @see Dry::System::Provider::SourceDSL
|
38
38
|
#
|
39
39
|
# @api private
|
40
|
-
def for(name:, group: nil,
|
40
|
+
def for(name:, group: nil, &block)
|
41
41
|
Class.new(self) { |klass|
|
42
42
|
klass.source_name name
|
43
43
|
klass.source_group group
|
44
|
-
SourceDSL.evaluate(klass,
|
44
|
+
SourceDSL.evaluate(klass, &block) if block
|
45
45
|
}
|
46
46
|
end
|
47
47
|
|
@@ -183,21 +183,6 @@ module Dry
|
|
183
183
|
# @api public
|
184
184
|
def stop; end
|
185
185
|
|
186
|
-
def use(*provider_names)
|
187
|
-
Dry::Core::Deprecations.announce(
|
188
|
-
"Dry::System::Provider#use",
|
189
|
-
"Use `target_container.start` instead, e.g. `target_container.start(:another_provider)`", # rubocop:disable Layout/LineLength
|
190
|
-
tag: "dry-system",
|
191
|
-
uplevel: 1
|
192
|
-
)
|
193
|
-
|
194
|
-
provider_names.each do |name|
|
195
|
-
target_container.start(name)
|
196
|
-
end
|
197
|
-
|
198
|
-
self
|
199
|
-
end
|
200
|
-
|
201
186
|
# Registers a "before" callback for the given lifecycle step.
|
202
187
|
#
|
203
188
|
# The given block will be run before the lifecycle step method is run. The block
|
@@ -212,17 +197,6 @@ module Dry
|
|
212
197
|
#
|
213
198
|
# @api public
|
214
199
|
def before(step_name, &block)
|
215
|
-
if step_name.to_sym == :init
|
216
|
-
Dry::Core::Deprecations.announce(
|
217
|
-
"Dry::System::Provider before(:init) callback",
|
218
|
-
"Use `before(:prepare)` callback instead",
|
219
|
-
tag: "dry-system",
|
220
|
-
uplevel: 1
|
221
|
-
)
|
222
|
-
|
223
|
-
step_name = :prepare
|
224
|
-
end
|
225
|
-
|
226
200
|
callbacks[:before][step_name] << block
|
227
201
|
self
|
228
202
|
end
|
@@ -241,17 +215,6 @@ module Dry
|
|
241
215
|
#
|
242
216
|
# @api public
|
243
217
|
def after(step_name, &block)
|
244
|
-
if step_name.to_sym == :init
|
245
|
-
Dry::Core::Deprecations.announce(
|
246
|
-
"Dry::System::Provider after(:init) callback",
|
247
|
-
"Use `after(:prepare)` callback instead",
|
248
|
-
tag: "dry-system",
|
249
|
-
uplevel: 1
|
250
|
-
)
|
251
|
-
|
252
|
-
step_name = :prepare
|
253
|
-
end
|
254
|
-
|
255
218
|
callbacks[:after][step_name] << block
|
256
219
|
self
|
257
220
|
end
|
@@ -259,18 +222,7 @@ module Dry
|
|
259
222
|
# @api private
|
260
223
|
def run_callback(hook, step)
|
261
224
|
callbacks[hook][step].each do |callback|
|
262
|
-
|
263
|
-
Dry::Core::Deprecations.announce(
|
264
|
-
"Dry::System::Provider::Source.before and .after callbacks with single block parameter", # rubocop:disable Layout/LineLength
|
265
|
-
"Use `provider_container` (or `container` for short) inside your block instead",
|
266
|
-
tag: "dry-system",
|
267
|
-
uplevel: 1
|
268
|
-
)
|
269
|
-
|
270
|
-
instance_exec(provider_container, &callback)
|
271
|
-
else
|
272
|
-
instance_eval(&callback)
|
273
|
-
end
|
225
|
+
instance_eval(&callback)
|
274
226
|
end
|
275
227
|
end
|
276
228
|
|
@@ -10,19 +10,8 @@ module Dry
|
|
10
10
|
#
|
11
11
|
# @api private
|
12
12
|
class SourceDSL
|
13
|
-
|
14
|
-
|
15
|
-
def self.evaluate(source_class, target_container, &block)
|
16
|
-
if block.parameters.any?
|
17
|
-
Dry::Core::Deprecations.announce(
|
18
|
-
"Dry::System.register_provider with single block parameter",
|
19
|
-
"Use `target_container` (or `target` for short) inside your block instead",
|
20
|
-
tag: "dry-system"
|
21
|
-
)
|
22
|
-
new(source_class).instance_exec(target_container, &block)
|
23
|
-
else
|
24
|
-
new(source_class).instance_eval(&block)
|
25
|
-
end
|
13
|
+
def self.evaluate(source_class, &block)
|
14
|
+
new(source_class).instance_eval(&block)
|
26
15
|
end
|
27
16
|
|
28
17
|
attr_reader :source_class
|
@@ -35,35 +24,9 @@ module Dry
|
|
35
24
|
source_class.setting(...)
|
36
25
|
end
|
37
26
|
|
38
|
-
# rubocop:disable Layout/LineLength
|
39
|
-
|
40
|
-
def settings(&block)
|
41
|
-
Dry::Core::Deprecations.announce(
|
42
|
-
"Dry::System.register_provider with nested settings block",
|
43
|
-
"Use individual top-level `setting` declarations instead (see dry-configurable docs for details)",
|
44
|
-
tag: "dry-system",
|
45
|
-
uplevel: 1
|
46
|
-
)
|
47
|
-
|
48
|
-
DeprecatedSettingsDSL.new(self).instance_eval(&block)
|
49
|
-
end
|
50
|
-
|
51
|
-
# rubocop:enable Layout/LineLength
|
52
|
-
|
53
|
-
class DeprecatedSettingsDSL
|
54
|
-
def initialize(base_dsl)
|
55
|
-
@base_dsl = base_dsl
|
56
|
-
end
|
57
|
-
|
58
|
-
def key(name, type)
|
59
|
-
@base_dsl.setting(name, constructor: type)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
27
|
def prepare(&block)
|
64
28
|
source_class.define_method(:prepare, &block)
|
65
29
|
end
|
66
|
-
deprecate :init, :prepare
|
67
30
|
|
68
31
|
def start(&block)
|
69
32
|
source_class.define_method(:start, &block)
|
data/lib/dry/system/provider.rb
CHANGED
@@ -90,7 +90,7 @@ module Dry
|
|
90
90
|
# later marged into the target container after the `prepare` and `start` lifecycle
|
91
91
|
# steps.
|
92
92
|
#
|
93
|
-
# @return [Dry::Container]
|
93
|
+
# @return [Dry::Core::Container]
|
94
94
|
#
|
95
95
|
# @api public
|
96
96
|
attr_reader :provider_container
|
@@ -206,7 +206,7 @@ module Dry
|
|
206
206
|
|
207
207
|
# @api private
|
208
208
|
def build_provider_container
|
209
|
-
container =
|
209
|
+
container = Core::Container.new
|
210
210
|
|
211
211
|
case namespace
|
212
212
|
when String, Symbol
|
@@ -15,8 +15,6 @@ module Dry
|
|
15
15
|
#
|
16
16
|
# @api private
|
17
17
|
class ProviderRegistrar
|
18
|
-
extend Dry::Core::Deprecations["Dry::System::Container"]
|
19
|
-
|
20
18
|
# @api private
|
21
19
|
attr_reader :providers
|
22
20
|
|
@@ -138,7 +136,6 @@ module Dry
|
|
138
136
|
end
|
139
137
|
}.first
|
140
138
|
end
|
141
|
-
deprecate :boot_files, :provider_files
|
142
139
|
|
143
140
|
# @api private
|
144
141
|
def finalize!
|
@@ -184,24 +181,9 @@ module Dry
|
|
184
181
|
|
185
182
|
private
|
186
183
|
|
187
|
-
# rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity, Layout/LineLength
|
188
184
|
# @api private
|
189
185
|
def provider_paths
|
190
186
|
provider_dirs = container.config.provider_dirs
|
191
|
-
bootable_dirs = container.config.bootable_dirs || ["system/boot"]
|
192
|
-
|
193
|
-
if container.config.provider_dirs == ["system/providers"] && \
|
194
|
-
provider_dirs.none? { |d| container.root.join(d).exist? } && \
|
195
|
-
bootable_dirs.any? { |d| container.root.join(d).exist? }
|
196
|
-
Dry::Core::Deprecations.announce(
|
197
|
-
"Dry::System::Container.config.bootable_dirs (defaulting to 'system/boot')",
|
198
|
-
"Use `Dry::System::Container.config.provider_dirs` (defaulting to 'system/providers') instead",
|
199
|
-
tag: "dry-system",
|
200
|
-
uplevel: 2
|
201
|
-
)
|
202
|
-
|
203
|
-
provider_dirs = bootable_dirs
|
204
|
-
end
|
205
187
|
|
206
188
|
provider_dirs.map { |dir|
|
207
189
|
dir = Pathname(dir)
|
@@ -213,14 +195,9 @@ module Dry
|
|
213
195
|
end
|
214
196
|
}
|
215
197
|
end
|
216
|
-
# rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity, Layout/LineLength
|
217
198
|
|
218
199
|
def build_provider(name, namespace:, source: nil, &block)
|
219
|
-
source_class = source || Provider::Source.for(
|
220
|
-
name: name,
|
221
|
-
target_container: container,
|
222
|
-
&block
|
223
|
-
)
|
200
|
+
source_class = source || Provider::Source.for(name: name, &block)
|
224
201
|
|
225
202
|
Provider.new(
|
226
203
|
name: name,
|
@@ -22,31 +22,19 @@ module Dry
|
|
22
22
|
sources[key(name, group)] = source
|
23
23
|
end
|
24
24
|
|
25
|
-
def register_from_block(name:, group:,
|
25
|
+
def register_from_block(name:, group:, &block)
|
26
26
|
register(
|
27
27
|
name: name,
|
28
28
|
group: group,
|
29
29
|
source: Provider::Source.for(
|
30
30
|
name: name,
|
31
31
|
group: group,
|
32
|
-
target_container: target_container,
|
33
32
|
&block
|
34
33
|
)
|
35
34
|
)
|
36
35
|
end
|
37
36
|
|
38
37
|
def resolve(name:, group:)
|
39
|
-
if group == :system
|
40
|
-
Dry::Core::Deprecations.announce(
|
41
|
-
"Providers using `from: :system`",
|
42
|
-
"Use `from: :dry_system` instead",
|
43
|
-
tag: "dry-system",
|
44
|
-
uplevel: 1
|
45
|
-
)
|
46
|
-
|
47
|
-
group = :dry_system
|
48
|
-
end
|
49
|
-
|
50
38
|
sources[key(name, group)].tap { |source|
|
51
39
|
unless source
|
52
40
|
raise ProviderSourceNotFoundError.new(
|
@@ -33,13 +33,17 @@ module Dry
|
|
33
33
|
new.tap do |settings_obj|
|
34
34
|
errors = {}
|
35
35
|
|
36
|
-
settings.to_a.each do |
|
37
|
-
value = loader[
|
36
|
+
settings.to_a.each do |setting|
|
37
|
+
value = loader[setting.name.to_s.upcase]
|
38
38
|
|
39
39
|
begin
|
40
|
-
|
40
|
+
if value
|
41
|
+
settings_obj.config.public_send(:"#{setting.name}=", value)
|
42
|
+
else
|
43
|
+
settings_obj.config[setting.name]
|
44
|
+
end
|
41
45
|
rescue => e # rubocop:disable Style/RescueStandardError
|
42
|
-
errors[
|
46
|
+
errors[setting.name] = e
|
43
47
|
end
|
44
48
|
end
|
45
49
|
|
@@ -47,19 +51,6 @@ module Dry
|
|
47
51
|
end
|
48
52
|
end
|
49
53
|
|
50
|
-
# rubocop:disable Layout/LineLength
|
51
|
-
def self.key(name, type)
|
52
|
-
Dry::Core::Deprecations.announce(
|
53
|
-
"Dry::System :settings provider source setting definition using `key`",
|
54
|
-
"Use `setting` instead, with dry-configurable `setting` options, e.g. `setting :my_setting, default: \"hello\", constructor: Types::String.constrained(min_length: 3)`",
|
55
|
-
tag: "dry-system",
|
56
|
-
uplevel: 1
|
57
|
-
)
|
58
|
-
|
59
|
-
setting(name, constructor: type)
|
60
|
-
end
|
61
|
-
# rubocop:enable Layout/LineLength
|
62
|
-
|
63
54
|
include Dry::Configurable
|
64
55
|
|
65
56
|
private
|
@@ -26,12 +26,6 @@ module Dry
|
|
26
26
|
require "dotenv"
|
27
27
|
Dotenv.load(*dotenv_files(root, env)) if defined?(Dotenv)
|
28
28
|
rescue LoadError
|
29
|
-
Dry::Core::Deprecations.announce(
|
30
|
-
"Dry::System :settings provider now requires dotenv to to load settings from .env files`", # rubocop:disable Layout/LineLength
|
31
|
-
"Add `gem \"dotenv\"` to your application's `Gemfile`",
|
32
|
-
tag: "dry-system",
|
33
|
-
uplevel: 3
|
34
|
-
)
|
35
29
|
# Do nothing if dotenv is unavailable
|
36
30
|
end
|
37
31
|
|
@@ -21,7 +21,7 @@ module Dry
|
|
21
21
|
# requiring an app-specific types module for setting constructors)
|
22
22
|
if block
|
23
23
|
@settings_block = block
|
24
|
-
elsif @settings_class
|
24
|
+
elsif defined? @settings_class
|
25
25
|
@settings_class
|
26
26
|
elsif @settings_block
|
27
27
|
@settings_class = Class.new(Settings::Config, &@settings_block)
|
data/lib/dry/system/stubs.rb
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "dry/container/stub"
|
3
|
+
require "dry/core/container/stub"
|
4
4
|
|
5
5
|
module Dry
|
6
6
|
module System
|
7
7
|
class Container
|
8
8
|
# @api private
|
9
9
|
module Stubs
|
10
|
-
|
10
|
+
# This overrides default finalize! just to disable automatic freezing
|
11
|
+
# of the container
|
12
|
+
#
|
13
|
+
# @api private
|
14
|
+
def finalize!(**, &block)
|
11
15
|
super(freeze: false, &block)
|
12
16
|
end
|
13
17
|
end
|
data/lib/dry/system/version.rb
CHANGED
data/lib/dry/system.rb
CHANGED
@@ -27,17 +27,6 @@ module Dry
|
|
27
27
|
provider_sources.load_sources(path)
|
28
28
|
end
|
29
29
|
|
30
|
-
def self.register_provider(_name, options)
|
31
|
-
Dry::Core::Deprecations.announce(
|
32
|
-
"Dry::System.register_provider",
|
33
|
-
"Use `Dry::System.register_provider_sources` instead",
|
34
|
-
tag: "dry-system",
|
35
|
-
uplevel: 1
|
36
|
-
)
|
37
|
-
|
38
|
-
register_provider_sources(options.fetch(:path))
|
39
|
-
end
|
40
|
-
|
41
30
|
# Registers a provider source, which can be used as the basis for other providers
|
42
31
|
#
|
43
32
|
# @api public
|
@@ -49,26 +38,10 @@ module Dry
|
|
49
38
|
if source
|
50
39
|
provider_sources.register(name: name, group: group, source: source)
|
51
40
|
else
|
52
|
-
provider_sources.register_from_block(
|
53
|
-
name: name,
|
54
|
-
group: group,
|
55
|
-
target_container: self,
|
56
|
-
&block
|
57
|
-
)
|
41
|
+
provider_sources.register_from_block(name: name, group: group, &block)
|
58
42
|
end
|
59
43
|
end
|
60
44
|
|
61
|
-
def self.register_component(name, provider:, &block)
|
62
|
-
Dry::Core::Deprecations.announce(
|
63
|
-
"Dry::System.register_component",
|
64
|
-
"Use `Dry::System.register_provider_source` instead",
|
65
|
-
tag: "dry-system",
|
66
|
-
uplevel: 1
|
67
|
-
)
|
68
|
-
|
69
|
-
register_provider_source(name, group: provider, &block)
|
70
|
-
end
|
71
|
-
|
72
45
|
# @api private
|
73
46
|
def self.provider_sources
|
74
47
|
@provider_sources ||= ProviderSourceRegistry.new
|
metadata
CHANGED
@@ -1,123 +1,95 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-system
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: zeitwerk
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.6'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '2.6'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: dry-auto_inject
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.4.0
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 0.4.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: dry-configurable
|
43
15
|
requirement: !ruby/object:Gem::Requirement
|
44
16
|
requirements:
|
45
17
|
- - "~>"
|
46
18
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
-
- - "
|
19
|
+
version: 1.0.0.rc1
|
20
|
+
- - "<"
|
49
21
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
22
|
+
version: '2'
|
51
23
|
type: :runtime
|
52
24
|
prerelease: false
|
53
25
|
version_requirements: !ruby/object:Gem::Requirement
|
54
26
|
requirements:
|
55
27
|
- - "~>"
|
56
28
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
58
|
-
- - "
|
29
|
+
version: 1.0.0.rc1
|
30
|
+
- - "<"
|
59
31
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
32
|
+
version: '2'
|
61
33
|
- !ruby/object:Gem::Dependency
|
62
|
-
name: dry-
|
34
|
+
name: dry-configurable
|
63
35
|
requirement: !ruby/object:Gem::Requirement
|
64
36
|
requirements:
|
65
37
|
- - "~>"
|
66
38
|
- !ruby/object:Gem::Version
|
67
|
-
version: '0
|
68
|
-
- - "
|
39
|
+
version: '1.0'
|
40
|
+
- - "<"
|
69
41
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
42
|
+
version: '2'
|
71
43
|
type: :runtime
|
72
44
|
prerelease: false
|
73
45
|
version_requirements: !ruby/object:Gem::Requirement
|
74
46
|
requirements:
|
75
47
|
- - "~>"
|
76
48
|
- !ruby/object:Gem::Version
|
77
|
-
version: '0
|
78
|
-
- - "
|
49
|
+
version: '1.0'
|
50
|
+
- - "<"
|
79
51
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
52
|
+
version: '2'
|
81
53
|
- !ruby/object:Gem::Dependency
|
82
54
|
name: dry-core
|
83
55
|
requirement: !ruby/object:Gem::Requirement
|
84
56
|
requirements:
|
85
57
|
- - "~>"
|
86
58
|
- !ruby/object:Gem::Version
|
87
|
-
version: '0
|
88
|
-
- - "
|
59
|
+
version: '1.0'
|
60
|
+
- - "<"
|
89
61
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
62
|
+
version: '2'
|
91
63
|
type: :runtime
|
92
64
|
prerelease: false
|
93
65
|
version_requirements: !ruby/object:Gem::Requirement
|
94
66
|
requirements:
|
95
67
|
- - "~>"
|
96
68
|
- !ruby/object:Gem::Version
|
97
|
-
version: '0
|
98
|
-
- - "
|
69
|
+
version: '1.0'
|
70
|
+
- - "<"
|
99
71
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
72
|
+
version: '2'
|
101
73
|
- !ruby/object:Gem::Dependency
|
102
74
|
name: dry-inflector
|
103
75
|
requirement: !ruby/object:Gem::Requirement
|
104
76
|
requirements:
|
105
77
|
- - "~>"
|
106
78
|
- !ruby/object:Gem::Version
|
107
|
-
version: '0
|
108
|
-
- - "
|
79
|
+
version: '1.0'
|
80
|
+
- - "<"
|
109
81
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
82
|
+
version: '2'
|
111
83
|
type: :runtime
|
112
84
|
prerelease: false
|
113
85
|
version_requirements: !ruby/object:Gem::Requirement
|
114
86
|
requirements:
|
115
87
|
- - "~>"
|
116
88
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0
|
118
|
-
- - "
|
89
|
+
version: '1.0'
|
90
|
+
- - "<"
|
119
91
|
- !ruby/object:Gem::Version
|
120
|
-
version:
|
92
|
+
version: '2'
|
121
93
|
- !ruby/object:Gem::Dependency
|
122
94
|
name: bundler
|
123
95
|
requirement: !ruby/object:Gem::Requirement
|
@@ -176,7 +148,6 @@ files:
|
|
176
148
|
- lib/dry/system/auto_registrar.rb
|
177
149
|
- lib/dry/system/component.rb
|
178
150
|
- lib/dry/system/component_dir.rb
|
179
|
-
- lib/dry/system/components.rb
|
180
151
|
- lib/dry/system/config/component_dir.rb
|
181
152
|
- lib/dry/system/config/component_dirs.rb
|
182
153
|
- lib/dry/system/config/namespace.rb
|
@@ -233,9 +204,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
233
204
|
version: 2.7.0
|
234
205
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
235
206
|
requirements:
|
236
|
-
- - "
|
207
|
+
- - ">"
|
237
208
|
- !ruby/object:Gem::Version
|
238
|
-
version:
|
209
|
+
version: 1.3.1
|
239
210
|
requirements: []
|
240
211
|
rubygems_version: 3.1.6
|
241
212
|
signing_key:
|