dry-system 0.15.0 → 0.19.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +142 -2
  3. data/LICENSE +1 -1
  4. data/README.md +1 -1
  5. data/dry-system.gemspec +5 -4
  6. data/lib/dry-system.rb +1 -1
  7. data/lib/dry/system.rb +2 -2
  8. data/lib/dry/system/auto_registrar.rb +17 -59
  9. data/lib/dry/system/booter.rb +68 -41
  10. data/lib/dry/system/component.rb +62 -100
  11. data/lib/dry/system/component_dir.rb +128 -0
  12. data/lib/dry/system/components.rb +2 -2
  13. data/lib/dry/system/components/bootable.rb +6 -34
  14. data/lib/dry/system/components/config.rb +2 -2
  15. data/lib/dry/system/config/component_dir.rb +202 -0
  16. data/lib/dry/system/config/component_dirs.rb +184 -0
  17. data/lib/dry/system/constants.rb +5 -5
  18. data/lib/dry/system/container.rb +133 -184
  19. data/lib/dry/system/errors.rb +21 -16
  20. data/lib/dry/system/identifier.rb +157 -0
  21. data/lib/dry/system/lifecycle.rb +2 -2
  22. data/lib/dry/system/loader.rb +40 -41
  23. data/lib/dry/system/loader/autoloading.rb +26 -0
  24. data/lib/dry/system/magic_comments_parser.rb +2 -2
  25. data/lib/dry/system/manual_registrar.rb +1 -1
  26. data/lib/dry/system/plugins.rb +7 -7
  27. data/lib/dry/system/plugins/bootsnap.rb +3 -3
  28. data/lib/dry/system/plugins/dependency_graph.rb +3 -3
  29. data/lib/dry/system/plugins/dependency_graph/strategies.rb +1 -1
  30. data/lib/dry/system/plugins/logging.rb +5 -5
  31. data/lib/dry/system/plugins/monitoring.rb +3 -3
  32. data/lib/dry/system/plugins/monitoring/proxy.rb +3 -3
  33. data/lib/dry/system/plugins/notifications.rb +1 -1
  34. data/lib/dry/system/provider.rb +3 -3
  35. data/lib/dry/system/settings.rb +6 -6
  36. data/lib/dry/system/settings/file_loader.rb +2 -2
  37. data/lib/dry/system/settings/file_parser.rb +1 -1
  38. data/lib/dry/system/stubs.rb +1 -1
  39. data/lib/dry/system/system_components/settings.rb +1 -1
  40. data/lib/dry/system/version.rb +1 -1
  41. metadata +21 -25
  42. data/lib/dry/system/auto_registrar/configuration.rb +0 -43
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/system/constants'
4
- require 'dry/system/plugins/dependency_graph/strategies'
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
- { 'dry-events': 'dry/events/publisher' }
31
+ {'dry-events': "dry/events/publisher"}
32
32
  end
33
33
 
34
34
  # @api private
@@ -14,7 +14,7 @@ module Dry
14
14
 
15
15
  # @api private
16
16
  def define_initialize(klass)
17
- @container['notifications'].instrument(
17
+ @container["notifications"].instrument(
18
18
  :resolved_dependency, dependency_map: dependency_map.to_h, target_class: klass
19
19
  )
20
20
  super(klass)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'logger'
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, 'log'
14
+ setting :log_dir, "log"
15
15
 
16
16
  setting :log_levels,
17
- development: Logger::DEBUG,
18
- test: Logger::DEBUG,
19
- production: Logger::ERROR
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 'dry/system/constants'
4
- require 'dry/system/plugins/monitoring/proxy'
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
- { 'dry-events': 'dry/events/publisher' }
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 'delegate'
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: [], &block)
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 = { target: key, object: object, method: meth, args: args }
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)
@@ -12,7 +12,7 @@ module Dry
12
12
 
13
13
  # @api private
14
14
  def self.dependencies
15
- { 'dry-monitor': 'dry/monitor/notifications' }
15
+ {'dry-monitor': "dry/monitor/notifications"}
16
16
  end
17
17
 
18
18
  # @api private
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'concurrent/map'
4
- require 'dry/system/constants'
5
- require 'dry/system/components/bootable'
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
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/core/class_builder'
4
- require 'dry/types'
5
- require 'dry/struct'
3
+ require "dry/core/class_builder"
4
+ require "dry/types"
5
+ require "dry/struct"
6
6
 
7
- require 'dry/system/settings/file_loader'
8
- require 'dry/system/constants'
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: 'Configuration', parent: Configuration).call do |klass|
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 'dry/system/settings/file_parser'
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('.env'),
23
+ root.join(".env"),
24
24
  root.join(".env.#{env}")
25
25
  ].compact
26
26
  end
@@ -37,7 +37,7 @@ module Dry
37
37
  def parse_line(line, hash)
38
38
  if (match = line.match(LINE))
39
39
  key, value = match.captures
40
- hash[key] = parse_value(value || '')
40
+ hash[key] = parse_value(value || "")
41
41
  end
42
42
  hash
43
43
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/container/stub'
3
+ require "dry/container/stub"
4
4
 
5
5
  module Dry
6
6
  module System
@@ -2,7 +2,7 @@
2
2
 
3
3
  Dry::System.register_component(:settings, provider: :system) do
4
4
  init do
5
- require 'dry/system/settings'
5
+ require "dry/system/settings"
6
6
  end
7
7
 
8
8
  start do
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  module System
5
- VERSION = '0.15.0'
5
+ VERSION = "0.19.1"
6
6
  end
7
7
  end
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.15.0
4
+ version: 0.19.1
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-30 00:00:00.000000000 Z
11
+ date: 2021-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -44,14 +44,20 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.7'
47
+ version: '0.12'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 0.12.1
48
51
  type: :runtime
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
55
  - - "~>"
53
56
  - !ruby/object:Gem::Version
54
- version: '0.7'
57
+ version: '0.12'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 0.12.1
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: dry-container
57
63
  requirement: !ruby/object:Gem::Requirement
@@ -78,34 +84,20 @@ dependencies:
78
84
  requirements:
79
85
  - - "~>"
80
86
  - !ruby/object:Gem::Version
81
- version: '0.3'
87
+ version: '0.5'
82
88
  - - ">="
83
89
  - !ruby/object:Gem::Version
84
- version: 0.3.1
90
+ version: '0.5'
85
91
  type: :runtime
86
92
  prerelease: false
87
93
  version_requirements: !ruby/object:Gem::Requirement
88
94
  requirements:
89
95
  - - "~>"
90
96
  - !ruby/object:Gem::Version
91
- version: '0.3'
97
+ version: '0.5'
92
98
  - - ">="
93
99
  - !ruby/object:Gem::Version
94
- version: 0.3.1
95
- - !ruby/object:Gem::Dependency
96
- name: dry-equalizer
97
- requirement: !ruby/object:Gem::Requirement
98
- requirements:
99
- - - "~>"
100
- - !ruby/object:Gem::Version
101
- version: '0.2'
102
- type: :runtime
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- requirements:
106
- - - "~>"
107
- - !ruby/object:Gem::Version
108
- version: '0.2'
100
+ version: '0.5'
109
101
  - !ruby/object:Gem::Dependency
110
102
  name: dry-inflector
111
103
  requirement: !ruby/object:Gem::Requirement
@@ -196,19 +188,23 @@ files:
196
188
  - lib/dry-system.rb
197
189
  - lib/dry/system.rb
198
190
  - lib/dry/system/auto_registrar.rb
199
- - lib/dry/system/auto_registrar/configuration.rb
200
191
  - lib/dry/system/booter.rb
201
192
  - lib/dry/system/booter/component_registry.rb
202
193
  - lib/dry/system/component.rb
194
+ - lib/dry/system/component_dir.rb
203
195
  - lib/dry/system/components.rb
204
196
  - lib/dry/system/components/bootable.rb
205
197
  - lib/dry/system/components/config.rb
198
+ - lib/dry/system/config/component_dir.rb
199
+ - lib/dry/system/config/component_dirs.rb
206
200
  - lib/dry/system/constants.rb
207
201
  - lib/dry/system/container.rb
208
202
  - lib/dry/system/errors.rb
203
+ - lib/dry/system/identifier.rb
209
204
  - lib/dry/system/importer.rb
210
205
  - lib/dry/system/lifecycle.rb
211
206
  - lib/dry/system/loader.rb
207
+ - lib/dry/system/loader/autoloading.rb
212
208
  - lib/dry/system/magic_comments_parser.rb
213
209
  - lib/dry/system/manual_registrar.rb
214
210
  - lib/dry/system/plugins.rb
@@ -244,14 +240,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
244
240
  requirements:
245
241
  - - ">="
246
242
  - !ruby/object:Gem::Version
247
- version: 2.4.0
243
+ version: 2.5.0
248
244
  required_rubygems_version: !ruby/object:Gem::Requirement
249
245
  requirements:
250
246
  - - ">="
251
247
  - !ruby/object:Gem::Version
252
248
  version: '0'
253
249
  requirements: []
254
- rubygems_version: 3.0.3
250
+ rubygems_version: 3.1.6
255
251
  signing_key:
256
252
  specification_version: 4
257
253
  summary: Organize your code into reusable components
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Dry
4
- module System
5
- class AutoRegistrar
6
- # Default auto_registrar configuration
7
- #
8
- # This is currently configured by default for every System::Container.
9
- # Configuration allows to define custom initialization as well as exclusion
10
- # logic, for each component that is being registered by Dry::System
11
- # auto-registration.
12
- #
13
- # @api private
14
- class Configuration
15
- DEFAULT_INSTANCE = -> component { component.instance }.freeze
16
- FALSE_PROC = -> * { false }.freeze
17
-
18
- def self.setting(name)
19
- define_method(name) do |&block|
20
- ivar = "@#{name}"
21
- if block
22
- instance_variable_set(ivar, block)
23
- else
24
- instance_variable_get(ivar)
25
- end
26
- end
27
- end
28
-
29
- setting :exclude
30
- setting :instance
31
-
32
- attr_accessor :memoize
33
-
34
- # @api private
35
- def initialize
36
- @instance = DEFAULT_INSTANCE
37
- @exclude = FALSE_PROC
38
- @memoize = false
39
- end
40
- end
41
- end
42
- end
43
- end