dry-system 0.24.0 → 0.25.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: 374dd39e2ef3e67b1a337af6d71aed0ebb5de9ebb31e8a16072ce37170576e88
4
- data.tar.gz: 8c3fc432ccaba83593018b09cf0d24f9d2c145057a18b9266c49dc8f5919ed8e
3
+ metadata.gz: 7ee8640692f53a8c0a9a29fd59bfe5595a269b3680d4a8f71d630e87ed2398b9
4
+ data.tar.gz: 435806646f338c4bdec369ae98fc29f451bb6a5dbe38bc2f20d7c3cb422b4223
5
5
  SHA512:
6
- metadata.gz: 9d855078f7dff3cd01a23e5cbfca252c3b801d2d7b3406d9c12038c01268de6c334c59c97e3d14ae333b5e2a76c6bde90d0c4b57bcc43c8310e1e9b41796e1be
7
- data.tar.gz: 2bf41708e4da839a1ba447231e32313ecb77acaad87499a85394c2d39f1cea6bc4f3b5581cb25de806ece5621734874354e82a1edb94bf26b89a890a5904db00
6
+ metadata.gz: 90130f6f367b24a1b45fd6be2915efe9d0c9e22b676e03b3a827ea7e9d02accca210272c8f5cd330993f2ea378ca2674ffc9281f7d695b14b7acb6f4d0a24c6d
7
+ data.tar.gz: 30cb6a24cb9e12cbd259223d0b861f837b692e139b21f95e1dfdd6b0365129e37377153151bce0cda8b9171249507ff458e4239ac61df0200c7144063381c0ad
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
+ ## 0.25.0 2022-07-10
4
+
5
+
6
+ ### Fixed
7
+
8
+ - Fix incorrect type in `ManifestRegistrar#finalize!` (@alassek)
9
+
10
+ ### Changed
11
+
12
+ - Import root components via `nil` import namespace (via #236) (@timriley)
13
+ - Allow deeper `Provider::Source` hierarchies (via #240) (@timriley + @solnic)
14
+ - Prefer local components when importing (via #241) (@timriley + @solnic)
15
+
16
+ [Compare v0.24.0...v0.25.0](https://github.com/dry-rb/dry-system/compare/v0.24.0...v0.25.0)
17
+
3
18
  ## 0.24.0
4
19
 
5
20
 
data/dry-system.gemspec CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
33
33
  spec.add_runtime_dependency "dry-auto_inject", ">= 0.4.0"
34
34
  spec.add_runtime_dependency "dry-configurable", "~> 0.14", ">= 0.14.0"
35
- spec.add_runtime_dependency "dry-container", "~> 0.9", ">= 0.9.0"
35
+ spec.add_runtime_dependency "dry-container", "~> 0.10", ">= 0.10.0"
36
36
  spec.add_runtime_dependency "dry-core", "~> 0.5", ">= 0.5"
37
37
  spec.add_runtime_dependency "dry-inflector", "~> 0.1", ">= 0.1.2"
38
38
 
@@ -7,6 +7,7 @@ require "dry/inflector"
7
7
  require "dry/system/loader"
8
8
  require "dry/system/errors"
9
9
  require "dry/system/constants"
10
+ require "pathname"
10
11
  require_relative "identifier"
11
12
 
12
13
  module Dry
@@ -17,7 +18,7 @@ module Dry
17
18
  #
18
19
  # @api public
19
20
  class Component
20
- include Dry::Equalizer(:identifier, :namespace, :options)
21
+ include Dry::Equalizer(:identifier, :file_path, :namespace, :options)
21
22
 
22
23
  DEFAULT_OPTIONS = {
23
24
  inflector: Dry::Inflector.new,
@@ -28,6 +29,10 @@ module Dry
28
29
  # @return [String] the component's unique identifier
29
30
  attr_reader :identifier
30
31
 
32
+ # @!attribute [r] file_path
33
+ # @return [Pathname] the component's source file path
34
+ attr_reader :file_path
35
+
31
36
  # @!attribute [r] namespace
32
37
  # @return [Dry::System::Config::Namespace] the component's namespace
33
38
  attr_reader :namespace
@@ -37,8 +42,9 @@ module Dry
37
42
  attr_reader :options
38
43
 
39
44
  # @api private
40
- def initialize(identifier, namespace:, **options)
45
+ def initialize(identifier, file_path:, namespace:, **options)
41
46
  @identifier = identifier
47
+ @file_path = Pathname(file_path)
42
48
  @namespace = namespace
43
49
  @options = DEFAULT_OPTIONS.merge(options)
44
50
  end
@@ -141,7 +141,12 @@ module Dry
141
141
  **MagicCommentsParser.(file_path)
142
142
  }
143
143
 
144
- Component.new(identifier, namespace: namespace, **options)
144
+ Component.new(
145
+ identifier,
146
+ namespace: namespace,
147
+ file_path: file_path,
148
+ **options
149
+ )
145
150
  end
146
151
 
147
152
  def component_options
@@ -2,9 +2,9 @@
2
2
 
3
3
  require "pathname"
4
4
 
5
- require "dry-auto_inject"
6
- require "dry-configurable"
7
- require "dry-container"
5
+ require "dry/configurable"
6
+ require "dry/auto_inject"
7
+ require "dry/container"
8
8
  require "dry/core/deprecations"
9
9
  require "dry/inflector"
10
10
 
@@ -70,12 +70,11 @@ module Dry
70
70
  #
71
71
  # @api public
72
72
  class Container
73
- extend Dry::Configurable
74
73
  extend Dry::Container::Mixin
75
74
  extend Dry::System::Plugins
76
75
 
77
76
  setting :name
78
- setting :root, default: Pathname.pwd.freeze, constructor: -> path { Pathname(path) }
77
+ setting :root, default: Pathname.pwd.freeze, constructor: ->(path) { Pathname(path) }
79
78
  setting :provider_dirs, default: ["system/providers"]
80
79
  setting :bootable_dirs # Deprecated for provider_dirs, see .provider_paths below
81
80
  setting :registrations_dir, default: "system/registrations"
@@ -193,7 +192,7 @@ module Dry
193
192
  # @param other [Hash, Dry::Container::Namespace]
194
193
  #
195
194
  # @api public
196
- def import(keys: nil, from: nil, as: nil, **deprecated_import_hash)
195
+ def import(keys: nil, from: Undefined, as: Undefined, **deprecated_import_hash)
197
196
  if deprecated_import_hash.any?
198
197
  Dry::Core::Deprecations.announce(
199
198
  "Dry::System::Container.import with {namespace => container} hash",
@@ -206,7 +205,7 @@ module Dry
206
205
  importer.register(container: container, namespace: namespace)
207
206
  end
208
207
  return self
209
- elsif from.nil? || as.nil?
208
+ elsif from == Undefined || as == Undefined
210
209
  # These keyword arguments can become properly required in the params list once
211
210
  # we remove the deprecation shim above
212
211
  raise ArgumentError, "required keyword arguments: :from, :as"
@@ -376,10 +375,10 @@ module Dry
376
375
  hooks[:before_finalize].each { |hook| instance_eval(&hook) }
377
376
  yield(self) if block
378
377
 
379
- importer.finalize!
380
378
  providers.finalize!
381
- manifest_registrar.finalize!
382
379
  auto_registrar.finalize!
380
+ manifest_registrar.finalize!
381
+ importer.finalize!
383
382
 
384
383
  @__finalized__ = true
385
384
 
@@ -659,6 +658,7 @@ module Dry
659
658
 
660
659
  protected
661
660
 
661
+ # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
662
662
  # @api private
663
663
  def load_component(key)
664
664
  return self if registered?(key)
@@ -678,11 +678,14 @@ module Dry
678
678
  elsif manifest_registrar.file_exists?(component)
679
679
  manifest_registrar.(component)
680
680
  elsif importer.namespace?(component.identifier.root_key)
681
- load_imported_component(component.identifier)
681
+ load_imported_component(component.identifier, namespace: component.identifier.root_key)
682
+ elsif importer.namespace?(nil)
683
+ load_imported_component(component.identifier, namespace: nil)
682
684
  end
683
685
 
684
686
  self
685
687
  end
688
+ # rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity
686
689
 
687
690
  private
688
691
 
@@ -692,14 +695,12 @@ module Dry
692
695
  end
693
696
  end
694
697
 
695
- def load_imported_component(identifier)
696
- import_namespace = identifier.root_key
697
-
698
- return unless importer.namespace?(import_namespace)
698
+ def load_imported_component(identifier, namespace:)
699
+ return unless importer.namespace?(namespace)
699
700
 
700
- import_key = identifier.namespaced(from: import_namespace, to: nil).key
701
+ import_key = identifier.namespaced(from: namespace, to: nil).key
701
702
 
702
- importer.import(import_namespace, keys: [import_key])
703
+ importer.import(namespace, keys: [import_key])
703
704
  end
704
705
 
705
706
  def find_component(key)
@@ -84,7 +84,7 @@ module Dry
84
84
  end
85
85
 
86
86
  def import_keys(other, namespace, keys)
87
- container.merge(build_merge_container(other, keys), namespace: namespace)
87
+ merge(container, build_merge_container(other, keys), namespace: namespace)
88
88
  end
89
89
 
90
90
  def import_all(other, namespace)
@@ -95,7 +95,14 @@ module Dry
95
95
  build_merge_container(other.finalize!, other.keys)
96
96
  end
97
97
 
98
- container.merge(merge_container, namespace: namespace)
98
+ merge(container, merge_container, namespace: namespace)
99
+ end
100
+
101
+ # Merges `other` into `container`, favoring the container's existing registrations
102
+ def merge(container, other, namespace:)
103
+ container.merge(other, namespace: namespace) { |_key, old_item, new_item|
104
+ old_item || new_item
105
+ }
99
106
  end
100
107
 
101
108
  def build_merge_container(other, keys)
@@ -27,7 +27,7 @@ module Dry
27
27
  # @api private
28
28
  def finalize!
29
29
  ::Dir[registrations_dir.join(RB_GLOB)].sort.each do |file|
30
- call(File.basename(file, RB_EXT))
30
+ call(Identifier.new(File.basename(file, RB_EXT)))
31
31
  end
32
32
  end
33
33
 
@@ -53,9 +53,14 @@ module Dry
53
53
  def inherited(subclass)
54
54
  super
55
55
 
56
- # FIXME: This shouldn't _need_ to be in an inherited hook but right now it's
57
- # the only way to prevent individual Source instances from sharing settings
58
- subclass.include Dry::Configurable
56
+ # Include Dry::Configurable only when first subclassing to ensure that
57
+ # distinct Source subclasses do not share settings.
58
+ #
59
+ # The superclass check here allows deeper Source class hierarchies to be
60
+ # created without running into a Dry::Configurable::AlreadyIncluded error.
61
+ if subclass.superclass == Source
62
+ subclass.include Dry::Configurable
63
+ end
59
64
  end
60
65
 
61
66
  # @api private
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  module System
5
- VERSION = "0.24.0"
5
+ VERSION = "0.25.0"
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.24.0
4
+ version: 0.25.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-05-28 00:00:00.000000000 Z
11
+ date: 2022-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -64,20 +64,20 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0.9'
67
+ version: '0.10'
68
68
  - - ">="
69
69
  - !ruby/object:Gem::Version
70
- version: 0.9.0
70
+ version: 0.10.0
71
71
  type: :runtime
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - "~>"
76
76
  - !ruby/object:Gem::Version
77
- version: '0.9'
77
+ version: '0.10'
78
78
  - - ">="
79
79
  - !ruby/object:Gem::Version
80
- version: 0.9.0
80
+ version: 0.10.0
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: dry-core
83
83
  requirement: !ruby/object:Gem::Requirement
@@ -221,7 +221,7 @@ metadata:
221
221
  changelog_uri: https://github.com/dry-rb/dry-system/blob/main/CHANGELOG.md
222
222
  source_code_uri: https://github.com/dry-rb/dry-system
223
223
  bug_tracker_uri: https://github.com/dry-rb/dry-system/issues
224
- post_install_message:
224
+ post_install_message:
225
225
  rdoc_options: []
226
226
  require_paths:
227
227
  - lib
@@ -236,8 +236,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
236
  - !ruby/object:Gem::Version
237
237
  version: '0'
238
238
  requirements: []
239
- rubygems_version: 3.2.32
240
- signing_key:
239
+ rubygems_version: 3.1.6
240
+ signing_key:
241
241
  specification_version: 4
242
242
  summary: Organize your code into reusable components
243
243
  test_files: []