dry-system 0.14.1 → 0.15.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 +22 -0
- data/dry-system.gemspec +1 -1
- data/lib/dry/system/constants.rb +0 -31
- data/lib/dry/system/container.rb +7 -2
- data/lib/dry/system/errors.rb +31 -0
- data/lib/dry/system/plugins.rb +1 -0
- data/lib/dry/system/plugins/bootsnap.rb +1 -1
- data/lib/dry/system/plugins/dependency_graph.rb +3 -1
- data/lib/dry/system/plugins/logging.rb +9 -7
- 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: f029366a9ef603592adb0566dc7d7d1afb13b4e0a5ea86d70d6560a4e80b80f0
|
4
|
+
data.tar.gz: 96b625962372b8e0a00a4cb99a449f8a5ed550c3328b887ef65c47a314628092
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ef15338eb9e108b6e489a59ce10f0e8e57608cb6882ae7f8b89680786752b68e00b12a15238f61af63c03382b160dadfe59457ef0d35516fe9defcfe69cb4f9
|
7
|
+
data.tar.gz: 4db3b188698061f78f23a8647d6145dc4466da9ac867c7c561f4aecd59434a18493b98b22d60c92f619f19f5fc177a723a8f2b4050be16f00d9151cadf7fdef2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
## v0.15.0 2020-01-30
|
2
|
+
|
3
|
+
|
4
|
+
### Added
|
5
|
+
|
6
|
+
- New hook - `before(:configure)` which a plugin should use if it needs to declare new settings (@solnic)
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
# in your plugin code
|
10
|
+
before(:configure) { setting :my_new_setting }
|
11
|
+
|
12
|
+
after(:configure) { config.my_new_setting = "awesome" }
|
13
|
+
```
|
14
|
+
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
|
18
|
+
- Centralize error definitions in `lib/dry/system/errors.rb` (@cgeorgii)
|
19
|
+
- All built-in plugins use `before(:configure)` now to declare their settings (@solnic)
|
20
|
+
|
21
|
+
[Compare v0.14.1...vv0.15.0](https://github.com/dry-rb/dry-system/compare/v0.14.1...vv0.15.0)
|
22
|
+
|
1
23
|
## 0.14.1 2020-01-22
|
2
24
|
|
3
25
|
|
data/dry-system.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.metadata['source_code_uri'] = 'https://github.com/dry-rb/dry-system'
|
24
24
|
spec.metadata['bug_tracker_uri'] = 'https://github.com/dry-rb/dry-system/issues'
|
25
25
|
|
26
|
-
spec.required_ruby_version =
|
26
|
+
spec.required_ruby_version = ">= 2.4.0"
|
27
27
|
|
28
28
|
# to update dependencies edit project.yml
|
29
29
|
spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
|
data/lib/dry/system/constants.rb
CHANGED
@@ -11,36 +11,5 @@ module Dry
|
|
11
11
|
PATH_SEPARATOR = '/'
|
12
12
|
DEFAULT_SEPARATOR = '.'
|
13
13
|
WORD_REGEX = /\w+/.freeze
|
14
|
-
|
15
|
-
ComponentsDirMissing = Class.new(StandardError)
|
16
|
-
DuplicatedComponentKeyError = Class.new(ArgumentError)
|
17
|
-
InvalidSettingsError = Class.new(ArgumentError) do
|
18
|
-
# @api private
|
19
|
-
def initialize(attributes)
|
20
|
-
message = <<~STR
|
21
|
-
Could not initialize settings. The following settings were invalid:
|
22
|
-
|
23
|
-
#{attributes_errors(attributes).join("\n")}
|
24
|
-
STR
|
25
|
-
super(message)
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def attributes_errors(attributes)
|
31
|
-
attributes.map { |key, error| "#{key.name}: #{error}" }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# Exception raise when a plugin dependency failed to load
|
36
|
-
#
|
37
|
-
# @api public
|
38
|
-
PluginDependencyMissing = Class.new(StandardError) do
|
39
|
-
# @api private
|
40
|
-
def initialize(plugin, message, gem = nil)
|
41
|
-
details = gem ? "#{message} - add #{gem} to your Gemfile" : message
|
42
|
-
super("dry-system plugin #{plugin.inspect} failed to load its dependencies: #{details}")
|
43
|
-
end
|
44
|
-
end
|
45
14
|
end
|
46
15
|
end
|
data/lib/dry/system/container.rb
CHANGED
@@ -112,9 +112,10 @@ module Dry
|
|
112
112
|
#
|
113
113
|
# @api public
|
114
114
|
def configure(&block)
|
115
|
+
hooks[:before_configure].each { |hook| instance_eval(&hook) }
|
115
116
|
super(&block)
|
116
117
|
load_paths!(config.system_dir)
|
117
|
-
hooks[:
|
118
|
+
hooks[:after_configure].each { |hook| instance_eval(&hook) }
|
118
119
|
self
|
119
120
|
end
|
120
121
|
|
@@ -642,7 +643,11 @@ module Dry
|
|
642
643
|
|
643
644
|
# @api private
|
644
645
|
def after(event, &block)
|
645
|
-
hooks[event] << block
|
646
|
+
hooks[:"after_#{event}"] << block
|
647
|
+
end
|
648
|
+
|
649
|
+
def before(event, &block)
|
650
|
+
hooks[:"before_#{event}"] << block
|
646
651
|
end
|
647
652
|
|
648
653
|
# @api private
|
data/lib/dry/system/errors.rb
CHANGED
@@ -84,5 +84,36 @@ module Dry
|
|
84
84
|
super("Plugin #{plugin_name.inspect} does not exist")
|
85
85
|
end
|
86
86
|
end
|
87
|
+
|
88
|
+
ComponentsDirMissing = Class.new(StandardError)
|
89
|
+
DuplicatedComponentKeyError = Class.new(ArgumentError)
|
90
|
+
InvalidSettingsError = Class.new(ArgumentError) do
|
91
|
+
# @api private
|
92
|
+
def initialize(attributes)
|
93
|
+
message = <<~STR
|
94
|
+
Could not initialize settings. The following settings were invalid:
|
95
|
+
|
96
|
+
#{attributes_errors(attributes).join("\n")}
|
97
|
+
STR
|
98
|
+
super(message)
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
def attributes_errors(attributes)
|
104
|
+
attributes.map { |key, error| "#{key.name}: #{error}" }
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# Exception raise when a plugin dependency failed to load
|
109
|
+
#
|
110
|
+
# @api public
|
111
|
+
PluginDependencyMissing = Class.new(StandardError) do
|
112
|
+
# @api private
|
113
|
+
def initialize(plugin, message, gem = nil)
|
114
|
+
details = gem ? "#{message} - add #{gem} to your Gemfile" : message
|
115
|
+
super("dry-system plugin #{plugin.inspect} failed to load its dependencies: #{details}")
|
116
|
+
end
|
117
|
+
end
|
87
118
|
end
|
88
119
|
end
|
data/lib/dry/system/plugins.rb
CHANGED
@@ -14,7 +14,9 @@ module Dry
|
|
14
14
|
|
15
15
|
system.use(:notifications)
|
16
16
|
|
17
|
-
system.
|
17
|
+
system.before(:configure) do
|
18
|
+
setting :ignored_dependencies, []
|
19
|
+
end
|
18
20
|
|
19
21
|
system.after(:configure) do
|
20
22
|
self[:notifications].register_event(:resolved_dependency)
|
@@ -8,16 +8,18 @@ module Dry
|
|
8
8
|
module Logging
|
9
9
|
# @api private
|
10
10
|
def self.extended(system)
|
11
|
-
system.
|
11
|
+
system.before(:configure) do
|
12
|
+
setting :logger, reader: true
|
12
13
|
|
13
|
-
|
14
|
+
setting :log_dir, 'log'
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
setting :log_levels,
|
17
|
+
development: Logger::DEBUG,
|
18
|
+
test: Logger::DEBUG,
|
19
|
+
production: Logger::ERROR
|
19
20
|
|
20
|
-
|
21
|
+
setting :logger_class, ::Logger, reader: true
|
22
|
+
end
|
21
23
|
|
22
24
|
system.after(:configure, &:register_logger)
|
23
25
|
|
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.15.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-01-
|
11
|
+
date: 2020-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|