dry-system 0.17.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/lib/dry-system.rb +1 -1
- data/lib/dry/system.rb +2 -2
- data/lib/dry/system/auto_registrar.rb +5 -5
- data/lib/dry/system/booter.rb +47 -40
- data/lib/dry/system/component.rb +7 -7
- data/lib/dry/system/components.rb +2 -2
- data/lib/dry/system/components/bootable.rb +6 -34
- data/lib/dry/system/components/config.rb +2 -2
- data/lib/dry/system/constants.rb +5 -5
- data/lib/dry/system/container.rb +47 -45
- data/lib/dry/system/errors.rb +1 -5
- data/lib/dry/system/lifecycle.rb +2 -2
- data/lib/dry/system/loader.rb +1 -1
- data/lib/dry/system/magic_comments_parser.rb +2 -2
- data/lib/dry/system/manual_registrar.rb +1 -1
- data/lib/dry/system/plugins.rb +7 -7
- data/lib/dry/system/plugins/bootsnap.rb +3 -3
- data/lib/dry/system/plugins/dependency_graph.rb +3 -3
- data/lib/dry/system/plugins/dependency_graph/strategies.rb +1 -1
- data/lib/dry/system/plugins/logging.rb +5 -5
- data/lib/dry/system/plugins/monitoring.rb +3 -3
- data/lib/dry/system/plugins/monitoring/proxy.rb +3 -3
- data/lib/dry/system/plugins/notifications.rb +1 -1
- data/lib/dry/system/provider.rb +3 -3
- data/lib/dry/system/settings.rb +6 -6
- data/lib/dry/system/settings/file_loader.rb +2 -2
- data/lib/dry/system/settings/file_parser.rb +1 -1
- data/lib/dry/system/stubs.rb +1 -1
- data/lib/dry/system/system_components/settings.rb +1 -1
- data/lib/dry/system/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd92a68eeadd612968bc08038f2c9fb7eaa60b90467de3f76fe441d558974944
|
4
|
+
data.tar.gz: c52ecf52aed4fdc98c435d2b3b1bbe0f19b37b30468b75d45f1806874af768fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc65408fdbe918f5ce2b985b384e8e70aa66ac6c535a5325305b1648f3f9604c507c6c8786f1152f15050c329c18b01613bb05040ee29cd05782a7e806252212
|
7
|
+
data.tar.gz: ac91650b306a20904b663b134ab39052ab88fdab19d3170434545d9e135e528d4b647e946841ab44470b99a1e3a67e10878813542b42faa356a44cc37c9cc4af
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## 0.18.0 2020-08-24
|
2
|
+
|
3
|
+
|
4
|
+
### Added
|
5
|
+
|
6
|
+
- New `bootable_dirs` setting on `Dry::System::Container`, which accepts paths to multiple directories for looking up bootable component files. (@timriley in PR #151)
|
7
|
+
|
8
|
+
For each entry in the `bootable_dirs` array, relative directories will be appended to the container's `root`, and absolute directories will be left unchanged.
|
9
|
+
|
10
|
+
When searching for bootable files, the first match will win, and any subsequent same-named files will not be loaded. In this way, the `bootable_dirs` act similarly to the `$PATH` in a shell environment.
|
11
|
+
|
12
|
+
|
13
|
+
[Compare v0.17.0...v0.18.0](https://github.com/dry-rb/dry-system/compare/v0.17.0...v0.18.0)
|
14
|
+
|
1
15
|
## 0.17.0 2020-02-19
|
2
16
|
|
3
17
|
|
data/lib/dry-system.rb
CHANGED
data/lib/dry/system.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "dry/system/constants"
|
4
|
+
require "dry/system/magic_comments_parser"
|
5
|
+
require "dry/system/auto_registrar/configuration"
|
6
6
|
|
7
7
|
module Dry
|
8
8
|
module System
|
@@ -67,8 +67,8 @@ module Dry
|
|
67
67
|
|
68
68
|
# @api private
|
69
69
|
def relative_path(dir, file_path)
|
70
|
-
dir_root = root.join(dir.to_s.split(
|
71
|
-
file_path.to_s.sub("#{dir_root}/",
|
70
|
+
dir_root = root.join(dir.to_s.split("/")[0])
|
71
|
+
file_path.to_s.sub("#{dir_root}/", "").sub(RB_EXT, EMPTY_STRING)
|
72
72
|
end
|
73
73
|
|
74
74
|
# @api private
|
data/lib/dry/system/booter.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
3
|
+
require "dry/system/components/bootable"
|
4
|
+
require "dry/system/errors"
|
5
|
+
require "dry/system/constants"
|
6
|
+
require "dry/system/lifecycle"
|
7
|
+
require "dry/system/booter/component_registry"
|
8
|
+
require "pathname"
|
8
9
|
|
9
10
|
module Dry
|
10
11
|
module System
|
@@ -16,29 +17,22 @@ module Dry
|
|
16
17
|
#
|
17
18
|
# @api private
|
18
19
|
class Booter
|
19
|
-
attr_reader :
|
20
|
+
attr_reader :paths
|
20
21
|
|
21
22
|
attr_reader :booted
|
22
23
|
|
23
24
|
attr_reader :components
|
24
25
|
|
25
26
|
# @api private
|
26
|
-
def initialize(
|
27
|
-
@
|
27
|
+
def initialize(paths)
|
28
|
+
@paths = paths
|
28
29
|
@booted = []
|
29
30
|
@components = ComponentRegistry.new
|
30
31
|
end
|
31
32
|
|
32
33
|
# @api private
|
33
34
|
def bootable?(component)
|
34
|
-
boot_file(component).
|
35
|
-
end
|
36
|
-
|
37
|
-
# @api private
|
38
|
-
def boot_file(name)
|
39
|
-
name = name.respond_to?(:root_key) ? name.root_key.to_s : name
|
40
|
-
|
41
|
-
path.join("#{name}#{RB_EXT}")
|
35
|
+
!boot_file(component).nil?
|
42
36
|
end
|
43
37
|
|
44
38
|
# @api private
|
@@ -47,15 +41,6 @@ module Dry
|
|
47
41
|
self
|
48
42
|
end
|
49
43
|
|
50
|
-
# @api private
|
51
|
-
def load_component(path)
|
52
|
-
identifier = Pathname(path).basename(RB_EXT).to_s.to_sym
|
53
|
-
|
54
|
-
Kernel.require path unless components.exists?(identifier)
|
55
|
-
|
56
|
-
self
|
57
|
-
end
|
58
|
-
|
59
44
|
# @api private
|
60
45
|
def finalize!
|
61
46
|
boot_files.each do |path|
|
@@ -120,7 +105,7 @@ module Dry
|
|
120
105
|
# @api private
|
121
106
|
def call(name_or_component)
|
122
107
|
with_component(name_or_component) do |component|
|
123
|
-
raise ComponentFileMismatchError
|
108
|
+
raise ComponentFileMismatchError, name unless component
|
124
109
|
|
125
110
|
yield(component) if block_given?
|
126
111
|
|
@@ -129,11 +114,14 @@ module Dry
|
|
129
114
|
end
|
130
115
|
|
131
116
|
# @api private
|
132
|
-
def
|
133
|
-
|
117
|
+
def boot_dependency(component)
|
118
|
+
boot_file = boot_file(component)
|
119
|
+
|
120
|
+
start(boot_file.basename(".*").to_s.to_sym) if boot_file
|
134
121
|
end
|
135
122
|
|
136
|
-
|
123
|
+
private
|
124
|
+
|
137
125
|
def with_component(id_or_component)
|
138
126
|
component =
|
139
127
|
case id_or_component
|
@@ -149,24 +137,43 @@ module Dry
|
|
149
137
|
yield(component)
|
150
138
|
end
|
151
139
|
|
152
|
-
|
140
|
+
def load_component(path)
|
141
|
+
identifier = Pathname(path).basename(RB_EXT).to_s.to_sym
|
142
|
+
|
143
|
+
Kernel.require path unless components.exists?(identifier)
|
144
|
+
|
145
|
+
self
|
146
|
+
end
|
147
|
+
|
148
|
+
def boot_file(name)
|
149
|
+
name = name.respond_to?(:root_key) ? name.root_key.to_s : name
|
150
|
+
|
151
|
+
find_boot_file(name)
|
152
|
+
end
|
153
|
+
|
153
154
|
def require_boot_file(identifier)
|
154
|
-
boot_file =
|
155
|
-
Pathname(path).basename(RB_EXT).to_s == identifier.to_s
|
156
|
-
}
|
155
|
+
boot_file = find_boot_file(identifier)
|
157
156
|
|
158
157
|
Kernel.require boot_file if boot_file
|
159
158
|
end
|
160
159
|
|
161
|
-
|
162
|
-
|
163
|
-
::Dir["#{path}/**/#{RB_GLOB}"].sort
|
160
|
+
def find_boot_file(name)
|
161
|
+
boot_files.detect { |file| File.basename(file, RB_EXT) == name.to_s }
|
164
162
|
end
|
165
163
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
164
|
+
def boot_files
|
165
|
+
@boot_files ||= paths.each_with_object([[], []]) { |path, (boot_files, loaded)|
|
166
|
+
files = Dir["#{path}/#{RB_GLOB}"].sort
|
167
|
+
|
168
|
+
files.each do |file|
|
169
|
+
basename = File.basename(file)
|
170
|
+
|
171
|
+
unless loaded.include?(basename)
|
172
|
+
boot_files << Pathname(file)
|
173
|
+
loaded << basename
|
174
|
+
end
|
175
|
+
end
|
176
|
+
}.first
|
170
177
|
end
|
171
178
|
end
|
172
179
|
end
|
data/lib/dry/system/component.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "concurrent/map"
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
5
|
+
require "dry-equalizer"
|
6
|
+
require "dry/inflector"
|
7
|
+
require "dry/system/loader"
|
8
|
+
require "dry/system/errors"
|
9
|
+
require "dry/system/constants"
|
10
10
|
|
11
11
|
module Dry
|
12
12
|
module System
|
@@ -118,7 +118,7 @@ module Dry
|
|
118
118
|
ruby2_keywords(:instance) if respond_to?(:ruby2_keywords, true)
|
119
119
|
|
120
120
|
# @api private
|
121
|
-
def
|
121
|
+
def bootable?
|
122
122
|
false
|
123
123
|
end
|
124
124
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
3
|
+
require "dry/system/lifecycle"
|
4
|
+
require "dry/system/settings"
|
5
|
+
require "dry/system/components/config"
|
6
|
+
require "dry/system/constants"
|
7
7
|
|
8
8
|
module Dry
|
9
9
|
module System
|
@@ -70,7 +70,7 @@ module Dry
|
|
70
70
|
@config = nil
|
71
71
|
@config_block = nil
|
72
72
|
@identifier = identifier
|
73
|
-
@triggers = {
|
73
|
+
@triggers = {before: TRIGGER_MAP.dup, after: TRIGGER_MAP.dup}
|
74
74
|
@options = block ? options.merge(block: block) : options
|
75
75
|
@namespace = options[:namespace]
|
76
76
|
finalize = options[:finalize] || DEFAULT_FINALIZE
|
@@ -229,38 +229,10 @@ module Dry
|
|
229
229
|
# @return [TrueClass]
|
230
230
|
#
|
231
231
|
# @api private
|
232
|
-
def
|
232
|
+
def bootable?
|
233
233
|
true
|
234
234
|
end
|
235
235
|
|
236
|
-
# Return path to component's boot file
|
237
|
-
#
|
238
|
-
# @return [String]
|
239
|
-
#
|
240
|
-
# @api private
|
241
|
-
def boot_file
|
242
|
-
container_boot_files
|
243
|
-
.detect { |path| Pathname(path).basename(RB_EXT).to_s == identifier.to_s }
|
244
|
-
end
|
245
|
-
|
246
|
-
# Return path to boot dir
|
247
|
-
#
|
248
|
-
# @return [String]
|
249
|
-
#
|
250
|
-
# @api private
|
251
|
-
def boot_path
|
252
|
-
container.boot_path
|
253
|
-
end
|
254
|
-
|
255
|
-
# Return all boot files defined under container's boot path
|
256
|
-
#
|
257
|
-
# @return [String]
|
258
|
-
#
|
259
|
-
# @api private
|
260
|
-
def container_boot_files
|
261
|
-
::Dir[container.boot_path.join("**/#{RB_GLOB}")].sort
|
262
|
-
end
|
263
|
-
|
264
236
|
private
|
265
237
|
|
266
238
|
# Return lifecycle object used for this component
|
@@ -21,8 +21,8 @@ module Dry
|
|
21
21
|
private
|
22
22
|
|
23
23
|
def method_missing(meth, value = nil)
|
24
|
-
if meth.to_s.end_with?(
|
25
|
-
@settings[meth.to_s.gsub(
|
24
|
+
if meth.to_s.end_with?("=")
|
25
|
+
@settings[meth.to_s.gsub("=", "").to_sym] = value
|
26
26
|
elsif @settings.key?(meth)
|
27
27
|
@settings[meth]
|
28
28
|
else
|
data/lib/dry/system/constants.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "dry/core/constants"
|
4
4
|
|
5
5
|
module Dry
|
6
6
|
module System
|
7
7
|
include Dry::Core::Constants
|
8
8
|
|
9
|
-
RB_EXT =
|
10
|
-
RB_GLOB =
|
11
|
-
PATH_SEPARATOR =
|
12
|
-
DEFAULT_SEPARATOR =
|
9
|
+
RB_EXT = ".rb"
|
10
|
+
RB_GLOB = "*.rb"
|
11
|
+
PATH_SEPARATOR = "/"
|
12
|
+
DEFAULT_SEPARATOR = "."
|
13
13
|
WORD_REGEX = /\w+/.freeze
|
14
14
|
end
|
15
15
|
end
|
data/lib/dry/system/container.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
|
10
|
-
require
|
11
|
-
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
3
|
+
require "pathname"
|
4
|
+
|
5
|
+
require "dry-auto_inject"
|
6
|
+
require "dry-configurable"
|
7
|
+
require "dry-container"
|
8
|
+
require "dry/inflector"
|
9
|
+
|
10
|
+
require "dry/core/deprecations"
|
11
|
+
|
12
|
+
require "dry/system"
|
13
|
+
require "dry/system/errors"
|
14
|
+
require "dry/system/loader"
|
15
|
+
require "dry/system/booter"
|
16
|
+
require "dry/system/auto_registrar"
|
17
|
+
require "dry/system/manual_registrar"
|
18
|
+
require "dry/system/importer"
|
19
|
+
require "dry/system/component"
|
20
|
+
require "dry/system/constants"
|
21
|
+
require "dry/system/plugins"
|
22
22
|
|
23
23
|
module Dry
|
24
24
|
module System
|
@@ -48,8 +48,6 @@ module Dry
|
|
48
48
|
#
|
49
49
|
# * `:name` - a unique container identifier
|
50
50
|
# * `:root` - a system root directory (defaults to `pwd`)
|
51
|
-
# * `:system_dir` - directory name relative to root, where bootable components
|
52
|
-
# can be defined in `boot` dir this defaults to `system`
|
53
51
|
#
|
54
52
|
# @example
|
55
53
|
# class MyApp < Dry::System::Container
|
@@ -75,8 +73,9 @@ module Dry
|
|
75
73
|
setting :name
|
76
74
|
setting :default_namespace
|
77
75
|
setting(:root, Pathname.pwd.freeze) { |path| Pathname(path) }
|
78
|
-
setting :system_dir,
|
79
|
-
setting :
|
76
|
+
setting :system_dir, "system"
|
77
|
+
setting :bootable_dirs, ["system/boot"]
|
78
|
+
setting :registrations_dir, "container"
|
80
79
|
setting :auto_register, []
|
81
80
|
setting :inflector, Dry::Inflector.new
|
82
81
|
setting :loader, Dry::System::Loader
|
@@ -95,7 +94,7 @@ module Dry
|
|
95
94
|
end
|
96
95
|
end
|
97
96
|
|
98
|
-
extend Dry::Core::Deprecations[
|
97
|
+
extend Dry::Core::Deprecations["Dry::System::Container"]
|
99
98
|
|
100
99
|
# Define a new configuration setting
|
101
100
|
#
|
@@ -170,9 +169,10 @@ module Dry
|
|
170
169
|
|
171
170
|
# Registers finalization function for a bootable component
|
172
171
|
#
|
173
|
-
# By convention, boot files for components should be placed in
|
174
|
-
#
|
175
|
-
# are loaded in isolation, or during finalization
|
172
|
+
# By convention, boot files for components should be placed in a
|
173
|
+
# `bootable_dirs` entry and they will be loaded on demand when
|
174
|
+
# components are loaded in isolation, or during the finalization
|
175
|
+
# process.
|
176
176
|
#
|
177
177
|
# @example
|
178
178
|
# # system/container.rb
|
@@ -255,30 +255,24 @@ module Dry
|
|
255
255
|
boot_local(name, **opts, &block)
|
256
256
|
end
|
257
257
|
|
258
|
+
booter.register_component component
|
259
|
+
|
258
260
|
components[name] = component
|
259
261
|
end
|
260
262
|
deprecate :finalize, :boot
|
261
263
|
|
262
264
|
# @api private
|
263
265
|
def boot_external(identifier, from:, key: nil, namespace: nil, &block)
|
264
|
-
|
266
|
+
System.providers[from].component(
|
265
267
|
identifier, key: key, namespace: namespace, finalize: block, container: self
|
266
268
|
)
|
267
|
-
|
268
|
-
booter.register_component(component)
|
269
|
-
|
270
|
-
component
|
271
269
|
end
|
272
270
|
|
273
271
|
# @api private
|
274
272
|
def boot_local(identifier, namespace: nil, &block)
|
275
|
-
|
273
|
+
Components::Bootable.new(
|
276
274
|
identifier, container: self, namespace: namespace, &block
|
277
275
|
)
|
278
|
-
|
279
|
-
booter.register_component(component)
|
280
|
-
|
281
|
-
component
|
282
276
|
end
|
283
277
|
|
284
278
|
# Return if a container was finalized
|
@@ -488,7 +482,7 @@ module Dry
|
|
488
482
|
# @param options [Hash] injector options
|
489
483
|
#
|
490
484
|
# @api public
|
491
|
-
def injector(options = {
|
485
|
+
def injector(options = {strategies: strategies})
|
492
486
|
Dry::AutoInject(self, options)
|
493
487
|
end
|
494
488
|
|
@@ -506,7 +500,7 @@ module Dry
|
|
506
500
|
# @api public
|
507
501
|
def require_from_root(*paths)
|
508
502
|
paths.flat_map { |path|
|
509
|
-
path.to_s.include?(
|
503
|
+
path.to_s.include?("*") ? ::Dir[root.join(path)].sort : root.join(path)
|
510
504
|
}.each { |path|
|
511
505
|
Kernel.require path.to_s
|
512
506
|
}
|
@@ -569,12 +563,20 @@ module Dry
|
|
569
563
|
|
570
564
|
# @api private
|
571
565
|
def booter
|
572
|
-
@booter ||= config.booter.new(
|
566
|
+
@booter ||= config.booter.new(boot_paths)
|
573
567
|
end
|
574
568
|
|
575
569
|
# @api private
|
576
|
-
def
|
577
|
-
|
570
|
+
def boot_paths
|
571
|
+
config.bootable_dirs.map { |dir|
|
572
|
+
dir = Pathname(dir)
|
573
|
+
|
574
|
+
if dir.relative?
|
575
|
+
root.join(dir)
|
576
|
+
else
|
577
|
+
dir
|
578
|
+
end
|
579
|
+
}
|
578
580
|
end
|
579
581
|
|
580
582
|
# @api private
|
@@ -635,13 +637,13 @@ module Dry
|
|
635
637
|
return self if registered?(key)
|
636
638
|
|
637
639
|
component(key).tap do |component|
|
638
|
-
if component.
|
640
|
+
if component.bootable?
|
639
641
|
booter.start(component)
|
640
642
|
else
|
641
643
|
root_key = component.root_key
|
642
644
|
|
643
|
-
if (
|
644
|
-
booter.start(
|
645
|
+
if (root_bootable = component(root_key)).bootable?
|
646
|
+
booter.start(root_bootable)
|
645
647
|
elsif importer.key?(root_key)
|
646
648
|
load_imported_component(component.namespaced(root_key))
|
647
649
|
end
|
data/lib/dry/system/errors.rb
CHANGED
@@ -17,12 +17,8 @@ module Dry
|
|
17
17
|
# @api public
|
18
18
|
ComponentFileMismatchError = Class.new(StandardError) do
|
19
19
|
def initialize(component)
|
20
|
-
path = component.boot_path
|
21
|
-
files = component.container_boot_files
|
22
|
-
|
23
20
|
super(<<-STR)
|
24
|
-
|
25
|
-
Container boot files under #{path}: #{files.inspect}")
|
21
|
+
Bootable component #{component.identifier.inspect} not found
|
26
22
|
STR
|
27
23
|
end
|
28
24
|
end
|
data/lib/dry/system/lifecycle.rb
CHANGED
data/lib/dry/system/loader.rb
CHANGED
data/lib/dry/system/plugins.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "dry/system/constants"
|
4
4
|
|
5
5
|
module Dry
|
6
6
|
module System
|
@@ -116,22 +116,22 @@ module Dry
|
|
116
116
|
@enabled_plugins ||= []
|
117
117
|
end
|
118
118
|
|
119
|
-
require
|
119
|
+
require "dry/system/plugins/bootsnap"
|
120
120
|
register(:bootsnap, Plugins::Bootsnap)
|
121
121
|
|
122
|
-
require
|
122
|
+
require "dry/system/plugins/logging"
|
123
123
|
register(:logging, Plugins::Logging)
|
124
124
|
|
125
|
-
require
|
125
|
+
require "dry/system/plugins/env"
|
126
126
|
register(:env, Plugins::Env)
|
127
127
|
|
128
|
-
require
|
128
|
+
require "dry/system/plugins/notifications"
|
129
129
|
register(:notifications, Plugins::Notifications)
|
130
130
|
|
131
|
-
require
|
131
|
+
require "dry/system/plugins/monitoring"
|
132
132
|
register(:monitoring, Plugins::Monitoring)
|
133
133
|
|
134
|
-
require
|
134
|
+
require "dry/system/plugins/dependency_graph"
|
135
135
|
register(:dependency_graph, Plugins::DependencyGraph)
|
136
136
|
end
|
137
137
|
end
|
@@ -22,7 +22,7 @@ module Dry
|
|
22
22
|
|
23
23
|
# @api private
|
24
24
|
def self.dependencies
|
25
|
-
{
|
25
|
+
{bootsnap: "bootsnap"}
|
26
26
|
end
|
27
27
|
|
28
28
|
# Set up bootsnap for faster booting
|
@@ -31,12 +31,12 @@ module Dry
|
|
31
31
|
def setup_bootsnap
|
32
32
|
return unless bootsnap_available?
|
33
33
|
|
34
|
-
::Bootsnap.setup(config.bootsnap.merge(cache_dir: root.join(
|
34
|
+
::Bootsnap.setup(config.bootsnap.merge(cache_dir: root.join("tmp/cache").to_s))
|
35
35
|
end
|
36
36
|
|
37
37
|
# @api private
|
38
38
|
def bootsnap_available?
|
39
|
-
RUBY_ENGINE ==
|
39
|
+
RUBY_ENGINE == "ruby" && RUBY_VERSION >= "2.3.0" && RUBY_VERSION < "2.5.0"
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "dry/system/constants"
|
4
|
+
require "dry/system/plugins/dependency_graph/strategies"
|
5
5
|
|
6
6
|
module Dry
|
7
7
|
module System
|
@@ -28,7 +28,7 @@ module Dry
|
|
28
28
|
|
29
29
|
# @api private
|
30
30
|
def self.dependencies
|
31
|
-
{
|
31
|
+
{'dry-events': "dry/events/publisher"}
|
32
32
|
end
|
33
33
|
|
34
34
|
# @api private
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "logger"
|
4
4
|
|
5
5
|
module Dry
|
6
6
|
module System
|
@@ -11,12 +11,12 @@ module Dry
|
|
11
11
|
system.before(:configure) do
|
12
12
|
setting :logger, reader: true
|
13
13
|
|
14
|
-
setting :log_dir,
|
14
|
+
setting :log_dir, "log"
|
15
15
|
|
16
16
|
setting :log_levels,
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
development: Logger::DEBUG,
|
18
|
+
test: Logger::DEBUG,
|
19
|
+
production: Logger::ERROR
|
20
20
|
|
21
21
|
setting :logger_class, ::Logger, reader: true
|
22
22
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "dry/system/constants"
|
4
|
+
require "dry/system/plugins/monitoring/proxy"
|
5
5
|
|
6
6
|
module Dry
|
7
7
|
module System
|
@@ -21,7 +21,7 @@ module Dry
|
|
21
21
|
|
22
22
|
# @api private
|
23
23
|
def self.dependencies
|
24
|
-
{
|
24
|
+
{'dry-events': "dry/events/publisher"}
|
25
25
|
end
|
26
26
|
|
27
27
|
# @api private
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "delegate"
|
4
4
|
|
5
5
|
module Dry
|
6
6
|
module System
|
@@ -9,7 +9,7 @@ module Dry
|
|
9
9
|
# @api private
|
10
10
|
class Proxy < SimpleDelegator
|
11
11
|
# @api private
|
12
|
-
def self.for(target, key:, methods: []
|
12
|
+
def self.for(target, key:, methods: [])
|
13
13
|
monitored_methods =
|
14
14
|
if methods.empty?
|
15
15
|
target.public_methods - Object.public_instance_methods
|
@@ -30,7 +30,7 @@ module Dry
|
|
30
30
|
monitored_methods.each do |meth|
|
31
31
|
define_method(meth) do |*args, &block|
|
32
32
|
object = __getobj__
|
33
|
-
opts = {
|
33
|
+
opts = {target: key, object: object, method: meth, args: args}
|
34
34
|
|
35
35
|
__notifications__.instrument(:monitoring, opts) do
|
36
36
|
object.public_send(meth, *args, &block)
|
data/lib/dry/system/provider.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "concurrent/map"
|
4
|
+
require "dry/system/constants"
|
5
|
+
require "dry/system/components/bootable"
|
6
6
|
|
7
7
|
module Dry
|
8
8
|
module System
|
data/lib/dry/system/settings.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "dry/core/class_builder"
|
4
|
+
require "dry/types"
|
5
|
+
require "dry/struct"
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
7
|
+
require "dry/system/settings/file_loader"
|
8
|
+
require "dry/system/constants"
|
9
9
|
|
10
10
|
module Dry
|
11
11
|
module System
|
@@ -22,7 +22,7 @@ module Dry
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def call
|
25
|
-
Core::ClassBuilder.new(name:
|
25
|
+
Core::ClassBuilder.new(name: "Configuration", parent: Configuration).call do |klass|
|
26
26
|
schema.each do |key, type|
|
27
27
|
klass.setting(key, type)
|
28
28
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "dry/system/settings/file_parser"
|
4
4
|
|
5
5
|
module Dry
|
6
6
|
module System
|
@@ -20,7 +20,7 @@ module Dry
|
|
20
20
|
|
21
21
|
def files(root, env)
|
22
22
|
[
|
23
|
-
root.join(
|
23
|
+
root.join(".env"),
|
24
24
|
root.join(".env.#{env}")
|
25
25
|
].compact
|
26
26
|
end
|
data/lib/dry/system/stubs.rb
CHANGED
data/lib/dry/system/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-system
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|