dry-system 0.26.0 → 0.27.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3817891e298713d98e37ad2f3fae19f0d63e2aaa0ed7fa43a084f4530a8c97b5
4
- data.tar.gz: d438cfec3270bd3abff042fa8a1b145517548300d79159a62be6b82e8f8d8df6
3
+ metadata.gz: 84621f047b9ae5be5233f099d1031bf5241c8694bd965884d161ce5f5b6ee079
4
+ data.tar.gz: be2f0f633dcbea09059608ed3dde19a0cb7d89b7d3f1b9e5484e780eb438f3d0
5
5
  SHA512:
6
- metadata.gz: d7a26bf48ab9318e359780ce83f0d2cd3ea541a2546dcc88c8fa0637d801b513bff9b1d8b64ce9c28e7307343ddea66d03f299ae4f1909c775ac1e478e7648af
7
- data.tar.gz: 5bc0286acd96dfaca17099c1a29d14417ba547cf4cb286a5f3951aa38bb9527d3ed2a966b959e658222a645f91a39caa094cdd2c63a4c2209f603b575a017792
6
+ metadata.gz: 9b5fc46ed7af654f4abc07cf95815ccfac84a44ed7ea76cc20d4253092ca78f82aa6ab5d66769ccbbe2f94937e536fa90f8156b2fbabd83466e59a6bbda098eb
7
+ data.tar.gz: d727819c4894eff4b5b095b33c27da01952643c7fed843321bca02e6e622c519a200b6a2f71cfe137003ef42cecb36b17a460005f291793816af10e1ad7a6475
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
+ ## 0.27.0 2022-10-15
4
+
5
+
6
+ ### Changed
7
+
8
+ - Use zeitwerk for auto-loading dry-system (@flash-gordon + @solnic)
9
+
10
+ [Compare v0.26.0...v0.27.0](https://github.com/dry-rb/dry-system/compare/v0.26.0...v0.27.0)
11
+
3
12
  ## 0.26.0 2022-10-08
4
13
 
5
14
 
data/dry-system.gemspec CHANGED
@@ -29,10 +29,11 @@ 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 "zeitwerk", "~> 2.6"
32
33
  spec.add_runtime_dependency "dry-auto_inject", ">= 0.4.0"
33
34
  spec.add_runtime_dependency "dry-configurable", "~> 0.16", ">= 0.16.0"
34
35
  spec.add_runtime_dependency "dry-container", "~> 0.10", ">= 0.10.0"
35
- spec.add_runtime_dependency "dry-core", "~> 0.5", ">= 0.5"
36
+ spec.add_runtime_dependency "dry-core", "~> 0.9", ">= 0.9.0"
36
37
  spec.add_runtime_dependency "dry-inflector", "~> 0.1", ">= 0.1.2"
37
38
 
38
39
  spec.add_development_dependency "bundler"
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "dry/system/constants"
4
- require_relative "component"
5
4
 
6
5
  module Dry
7
6
  module System
@@ -1,12 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/core/equalizer"
3
+ require "pathname"
4
4
  require "dry/inflector"
5
- require "dry/system/loader"
6
5
  require "dry/system/errors"
7
6
  require "dry/system/constants"
8
- require "pathname"
9
- require_relative "identifier"
10
7
 
11
8
  module Dry
12
9
  module System
@@ -2,9 +2,6 @@
2
2
 
3
3
  require "pathname"
4
4
  require "dry/system/constants"
5
- require_relative "constants"
6
- require_relative "identifier"
7
- require_relative "magic_comments_parser"
8
5
 
9
6
  module Dry
10
7
  module System
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/core/deprecations"
4
-
5
3
  Dry::Core::Deprecations.announce(
6
4
  "require \"dry/system/components\"",
7
5
  "Use `require \"dry/system/provider_sources\"` instead",
@@ -1,10 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/configurable"
4
- require "dry/core/deprecations"
5
3
  require "dry/system/constants"
6
- require "dry/system/loader"
7
- require_relative "namespaces"
8
4
 
9
5
  module Dry
10
6
  module System
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "dry/system/constants"
4
4
  require "dry/system/errors"
5
- require_relative "component_dir"
6
5
 
7
6
  module Dry
8
7
  module System
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/core/equalizer"
4
3
  require "dry/system/constants"
5
4
 
6
5
  module Dry
@@ -1,9 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/core/deprecations"
4
- require "dry/core/equalizer"
5
3
  require "dry/system/errors"
6
- require_relative "namespace"
7
4
 
8
5
  module Dry
9
6
  module System
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/core/constants"
4
-
5
3
  module Dry
6
4
  module System
7
5
  include Dry::Core::Constants
@@ -5,25 +5,8 @@ require "pathname"
5
5
  require "dry/configurable"
6
6
  require "dry/auto_inject"
7
7
  require "dry/container"
8
- require "dry/core/deprecations"
9
8
  require "dry/inflector"
10
9
 
11
- require "dry/system/auto_registrar"
12
- require "dry/system/component"
13
- require "dry/system/constants"
14
- require "dry/system/errors"
15
- require "dry/system/identifier"
16
- require "dry/system/importer"
17
- require "dry/system/indirect_component"
18
- require "dry/system/manifest_registrar"
19
- require "dry/system/plugins"
20
- require "dry/system/provider_registrar"
21
- require "dry/system/provider"
22
- require "dry/system/provider/source"
23
-
24
- require_relative "component_dir"
25
- require_relative "config/component_dirs"
26
-
27
10
  module Dry
28
11
  module System
29
12
  # Abstract container class to inherit from
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/core/deprecations"
4
-
5
3
  module Dry
6
4
  module System
7
5
  extend Dry::Core::Deprecations["dry-system"]
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/core/equalizer"
4
- require_relative "constants"
3
+ require "dry/system/constants"
5
4
 
6
5
  module Dry
7
6
  module System
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "dry/container"
4
- require_relative "constants"
4
+ require "dry/system/constants"
5
5
 
6
6
  module Dry
7
7
  module System
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/core/equalizer"
4
-
5
3
  module Dry
6
4
  module System
7
5
  # An indirect component is a component that cannot be directly from a source file
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../loader"
4
-
5
3
  module Dry
6
4
  module System
7
5
  class Loader
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dry
4
+ module System
5
+ module Plugins
6
+ # @api private
7
+ class Plugin
8
+ attr_reader :name
9
+
10
+ attr_reader :mod
11
+
12
+ attr_reader :block
13
+
14
+ # @api private
15
+ def initialize(name, mod, &block)
16
+ @name = name
17
+ @mod = mod
18
+ @block = block
19
+ end
20
+
21
+ # @api private
22
+ def apply_to(system, **options)
23
+ system.extend(stateful? ? mod.new(**options) : mod)
24
+ system.instance_eval(&block) if block
25
+ system
26
+ end
27
+
28
+ # @api private
29
+ def load_dependencies(dependencies = mod_dependencies, gem = nil)
30
+ Array(dependencies).each do |dependency|
31
+ if dependency.is_a?(Array) || dependency.is_a?(Hash)
32
+ dependency.each { |value| load_dependencies(*Array(value).reverse) }
33
+ elsif !Plugins.loaded_dependencies.include?(dependency.to_s)
34
+ load_dependency(dependency, gem)
35
+ end
36
+ end
37
+ end
38
+
39
+ # @api private
40
+ def load_dependency(dependency, gem)
41
+ Kernel.require dependency
42
+ Plugins.loaded_dependencies << dependency.to_s
43
+ rescue LoadError => e
44
+ raise PluginDependencyMissing.new(name, e.message, gem)
45
+ end
46
+
47
+ # @api private
48
+ def stateful?
49
+ mod < Module
50
+ end
51
+
52
+ # @api private
53
+ def mod_dependencies
54
+ return EMPTY_ARRAY unless mod.respond_to?(:dependencies)
55
+
56
+ mod.dependencies.is_a?(Array) ? mod.dependencies : [mod.dependencies]
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -1,64 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/system/constants"
4
-
5
3
  module Dry
6
4
  module System
7
5
  module Plugins
8
- # @api private
9
- class Plugin
10
- attr_reader :name
11
-
12
- attr_reader :mod
13
-
14
- attr_reader :block
15
-
16
- # @api private
17
- def initialize(name, mod, &block)
18
- @name = name
19
- @mod = mod
20
- @block = block
21
- end
22
-
23
- # @api private
24
- def apply_to(system, **options)
25
- system.extend(stateful? ? mod.new(**options) : mod)
26
- system.instance_eval(&block) if block
27
- system
28
- end
29
-
30
- # @api private
31
- def load_dependencies(dependencies = mod_dependencies, gem = nil)
32
- Array(dependencies).each do |dependency|
33
- if dependency.is_a?(Array) || dependency.is_a?(Hash)
34
- dependency.each { |value| load_dependencies(*Array(value).reverse) }
35
- elsif !Plugins.loaded_dependencies.include?(dependency.to_s)
36
- load_dependency(dependency, gem)
37
- end
38
- end
39
- end
40
-
41
- # @api private
42
- def load_dependency(dependency, gem)
43
- Kernel.require dependency
44
- Plugins.loaded_dependencies << dependency.to_s
45
- rescue LoadError => e
46
- raise PluginDependencyMissing.new(name, e.message, gem)
47
- end
48
-
49
- # @api private
50
- def stateful?
51
- mod < Module
52
- end
53
-
54
- # @api private
55
- def mod_dependencies
56
- return EMPTY_ARRAY unless mod.respond_to?(:dependencies)
57
-
58
- mod.dependencies.is_a?(Array) ? mod.dependencies : [mod.dependencies]
59
- end
60
- end
61
-
62
6
  # Register a plugin
63
7
  #
64
8
  # @param [Symbol] name The name of a plugin
@@ -93,7 +37,7 @@ module Dry
93
37
  def use(name, **options)
94
38
  return self if enabled_plugins.include?(name)
95
39
 
96
- raise PluginNotFoundError, name unless (plugin = Plugins.registry[name])
40
+ raise PluginNotFoundError, name unless (plugin = Dry::System::Plugins.registry[name])
97
41
 
98
42
  plugin.load_dependencies
99
43
  plugin.apply_to(self, **options)
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/configurable"
4
- require "dry/core/class_attributes"
5
- require "dry/core/deprecations"
6
3
  require_relative "source_dsl"
7
4
 
8
5
  module Dry
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/core/deprecations"
4
-
5
3
  module Dry
6
4
  module System
7
5
  class Provider
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/core/deprecations"
4
- require_relative "constants"
5
- require_relative "provider/source"
3
+ require "dry/system/constants"
6
4
 
7
5
  module Dry
8
6
  module System
@@ -1,11 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/core/deprecations"
4
- require "dry/system"
5
3
  require "pathname"
6
- require_relative "errors"
7
- require_relative "constants"
8
- require_relative "provider"
4
+
5
+ require "dry/system/errors"
6
+ require "dry/system/constants"
9
7
 
10
8
  module Dry
11
9
  module System
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/core/deprecations"
4
- require_relative "constants"
5
- require_relative "provider/source"
3
+ require "dry/system/constants"
6
4
 
7
5
  module Dry
8
6
  module System
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/configurable"
4
- require "dry/core/deprecations"
5
- require_relative "loader"
6
-
7
3
  module Dry
8
4
  module System
9
5
  module ProviderSources
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/configurable"
4
- require "dry/core/deprecations"
5
-
6
3
  module Dry
7
4
  module System
8
5
  module ProviderSources
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  module System
5
- VERSION = "0.26.0"
5
+ VERSION = "0.27.0"
6
6
  end
7
7
  end
data/lib/dry/system.rb CHANGED
@@ -1,10 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/core/deprecations"
4
- require_relative "system/provider_source_registry"
3
+ require "zeitwerk"
4
+ require "dry/core"
5
5
 
6
6
  module Dry
7
7
  module System
8
+ # @api private
9
+ def self.loader
10
+ @loader ||= Zeitwerk::Loader.new.tap do |loader|
11
+ root = File.expand_path("..", __dir__)
12
+ loader.tag = "dry-system"
13
+ loader.inflector = Zeitwerk::GemInflector.new("#{root}/dry-system.rb")
14
+ loader.push_dir(root)
15
+ loader.ignore(
16
+ "#{root}/dry-system.rb",
17
+ "#{root}/dry/system/{constants,errors,stubs,version}.rb"
18
+ )
19
+ loader.inflector.inflect("dsl" => "DSL")
20
+ end
21
+ end
22
+
8
23
  # Registers the provider sources in the files under the given path
9
24
  #
10
25
  # @api public
@@ -58,5 +73,7 @@ module Dry
58
73
  def self.provider_sources
59
74
  @provider_sources ||= ProviderSourceRegistry.new
60
75
  end
76
+
77
+ loader.setup
61
78
  end
62
79
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-system
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.0
4
+ version: 0.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-08 00:00:00.000000000 Z
11
+ date: 2022-10-15 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'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: dry-auto_inject
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -70,20 +84,20 @@ dependencies:
70
84
  requirements:
71
85
  - - "~>"
72
86
  - !ruby/object:Gem::Version
73
- version: '0.5'
87
+ version: '0.9'
74
88
  - - ">="
75
89
  - !ruby/object:Gem::Version
76
- version: '0.5'
90
+ version: 0.9.0
77
91
  type: :runtime
78
92
  prerelease: false
79
93
  version_requirements: !ruby/object:Gem::Requirement
80
94
  requirements:
81
95
  - - "~>"
82
96
  - !ruby/object:Gem::Version
83
- version: '0.5'
97
+ version: '0.9'
84
98
  - - ">="
85
99
  - !ruby/object:Gem::Version
86
- version: '0.5'
100
+ version: 0.9.0
87
101
  - !ruby/object:Gem::Dependency
88
102
  name: dry-inflector
89
103
  requirement: !ruby/object:Gem::Requirement
@@ -186,6 +200,7 @@ files:
186
200
  - lib/dry/system/plugins/monitoring.rb
187
201
  - lib/dry/system/plugins/monitoring/proxy.rb
188
202
  - lib/dry/system/plugins/notifications.rb
203
+ - lib/dry/system/plugins/plugin.rb
189
204
  - lib/dry/system/plugins/zeitwerk.rb
190
205
  - lib/dry/system/plugins/zeitwerk/compat_inflector.rb
191
206
  - lib/dry/system/provider.rb
@@ -207,7 +222,7 @@ metadata:
207
222
  changelog_uri: https://github.com/dry-rb/dry-system/blob/main/CHANGELOG.md
208
223
  source_code_uri: https://github.com/dry-rb/dry-system
209
224
  bug_tracker_uri: https://github.com/dry-rb/dry-system/issues
210
- post_install_message:
225
+ post_install_message:
211
226
  rdoc_options: []
212
227
  require_paths:
213
228
  - lib
@@ -222,8 +237,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
237
  - !ruby/object:Gem::Version
223
238
  version: '0'
224
239
  requirements: []
225
- rubygems_version: 3.3.7
226
- signing_key:
240
+ rubygems_version: 3.1.6
241
+ signing_key:
227
242
  specification_version: 4
228
243
  summary: Organize your code into reusable components
229
244
  test_files: []