Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provider and booter overhaul, including class-backed provider sources #202

Merged
merged 78 commits into from Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
acf3e94
Make Provider#trigger properly private
timriley Jan 7, 2022
f8143db
Use proper initialize params for ProviderLifecycle
timriley Jan 7, 2022
466bf68
Fix a stray provider_dirs issue in specs
timriley Jan 7, 2022
c924699
Rename Provider `container` to `target_container`
timriley Jan 7, 2022
56aefb1
Build provider container on initialize, have lifecycle access this co…
timriley Jan 7, 2022
c241069
Build Lifecycle as part of Provider initialize
timriley Jan 7, 2022
d27f502
Remove unused ivar
timriley Jan 7, 2022
ec6dc1c
Rename trigger! to handle_trigger
timriley Jan 7, 2022
46ebeff
Actually, let's call them "lifecycle steps"
timriley Jan 7, 2022
8967de2
Rename "trigger" to "step callback" in Provider
timriley Jan 7, 2022
a1f9eb0
Extract Provider steps into shared provide method
timriley Jan 7, 2022
577612e
Move step status handling out of Lifecycle and into Provider
timriley Jan 7, 2022
3e29231
Remove unused configure from lifecycle
timriley Jan 7, 2022
df86136
Move things around, clarify DSLs for both lifecycles and steps
timriley Jan 7, 2022
c3a19fe
Shift things around a bit, see how this feels
timriley Jan 7, 2022
f29f0b8
WIP, but everything passing here
timriley Jan 9, 2022
281a040
Getting there, but missing constant errors
timriley Jan 10, 2022
044fe85
boot_spec is working
timriley Jan 10, 2022
d403a8f
Closer to working
timriley Jan 10, 2022
54ec0ae
Bit gross but everything is working now
timriley Jan 10, 2022
4d01b2c
Remove debug noise
timriley Jan 10, 2022
7870538
Got the settings component nearly working again
timriley Jan 10, 2022
bec08b9
Everything is green now
timriley Jan 10, 2022
995116a
Rename to SourceBuilder
timriley Jan 10, 2022
4443e33
Remove previous attempts at this
timriley Jan 10, 2022
f26061a
Provider should receive a source_class only
timriley Jan 10, 2022
55b1b17
Remove unneeded stuff
timriley Jan 10, 2022
44ff72a
Add Provider.source_class as an entrypoint builder
timriley Jan 10, 2022
6e0109c
More tweaks
timriley Jan 10, 2022
94f8d6c
Clean up
timriley Jan 10, 2022
1dd6ef6
Massively simplify the booter
timriley Jan 10, 2022
110fb70
Remove ProviderRegistry
timriley Jan 10, 2022
ea9b3ba
Remove conditional apply from provider for now
timriley Jan 10, 2022
a573373
Alias target->target_container
timriley Jan 10, 2022
2af4b4a
Remove the "refinement_block" name
timriley Jan 10, 2022
3b17585
Add status predicate methods to Provider
timriley Jan 10, 2022
53089de
Remove Booter#call
timriley Jan 10, 2022
b7648c9
Reorganize Booter a bit
timriley Jan 10, 2022
56ba8cb
Rename Booter to ProviderRegistrar
timriley Jan 10, 2022
60b21ca
Restore some specs
timriley Jan 10, 2022
19fca4d
Rename boot_dependency to something clearer
timriley Jan 11, 2022
48107fe
Remove unused class
timriley Jan 11, 2022
0de6d97
Start on some docs
timriley Jan 11, 2022
0c8a18d
Allow source providers to be classes
timriley Jan 11, 2022
7a2aa6d
Allow regular providers to be sourced from classes
timriley Jan 11, 2022
fb469ec
Add API docs for Provider::Source
timriley Jan 11, 2022
f622716
Fix issues
timriley Jan 11, 2022
2f91e36
Fix namespace
timriley Jan 11, 2022
694feb1
Rename "system components" to "provider sources"
timriley Jan 11, 2022
2ea4e66
Rename source providers to provider sources
timriley Jan 11, 2022
9a2801f
Fix bug displaying settings errors
timriley Jan 11, 2022
952dbdd
Raise error when unknown provider source given
timriley Jan 11, 2022
76b9402
Add deprecations
timriley Jan 11, 2022
bd5a93d
Add more deprecations
timriley Jan 11, 2022
48c373e
Restore deprecation spec
timriley Jan 11, 2022
69f72dd
Restore deprecation
timriley Jan 11, 2022
3810fd6
Fix
timriley Jan 11, 2022
ccced2e
Add backwards for register_provider with block
timriley Jan 11, 2022
1c5e441
Deprecate provider callbacks with block arg
timriley Jan 11, 2022
37b7daf
Sort errors for stable tests on JRuby
timriley Jan 11, 2022
ed7866f
Touch up docs
timriley Jan 11, 2022
a7779cf
Fix typo
timriley Jan 11, 2022
bf3750a
Proper noun capitalise
timriley Jan 11, 2022
f00d972
Rename Settings::Settings to Settings::Config
timriley Jan 11, 2022
06169ea
Feedback tweaks
timriley Jan 11, 2022
27f8087
Shift rubocop disablement
timriley Jan 11, 2022
65456b3
Simplify ProviderRegistrar methods
timriley Jan 11, 2022
0b1ebb5
Add deprecated backwards compat for settings block
timriley Jan 11, 2022
7f8e940
Fix issue with settings being shared across provider source instances
timriley Jan 11, 2022
6928844
Remove note
timriley Jan 11, 2022
421cd28
Rubocop fixes
timriley Jan 11, 2022
0f68c0d
Document @return [self] instead of [void]
timriley Jan 12, 2022
ef69a02
Use started? helper method
timriley Jan 12, 2022
04cc650
Require source_class param
timriley Jan 12, 2022
4c5ae92
Remove unneeded tap
timriley Jan 12, 2022
3a25d25
Use public_send
timriley Jan 12, 2022
f2330da
Move variable declaration into appropriate scope
timriley Jan 12, 2022
b719562
Fix constant leak in tests
timriley Jan 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -9,6 +9,7 @@ gemspec
# Remove verson constraint once latter versions release their -java packages
gem "bootsnap", "= 1.4.9"
gem "dry-monitor"
gem "dry-types"
gem "zeitwerk"

group :tools do
Expand Down
39 changes: 26 additions & 13 deletions lib/dry/system.rb
@@ -1,49 +1,62 @@
# frozen_string_literal: true

require "dry/core/deprecations"
require_relative "system/source_provider_registry"
require_relative "system/provider_source_registry"

module Dry
module System
# Registers all the source providers in the files under the given path
# Registers the provider sources in the files under the given path
#
# @api public
def self.register_source_providers(path)
source_providers.load_sources(path)
def self.register_provider_sources(path)
provider_sources.load_sources(path)
end

def self.register_provider(_name, options)
Dry::Core::Deprecations.announce(
"Dry::System.register_provider",
"Use `Dry::System.register_source_providers` instead",
"Use `Dry::System.register_provider_sources` instead",
tag: "dry-system",
uplevel: 1
)

register_source_providers(options.fetch(:path))
register_provider_sources(options.fetch(:path))
end

# Registers a source provider, which can be used as the basis for other providers
# Registers a provider source, which can be used as the basis for other providers
#
# @api public
def self.register_source_provider(name, group:, &block)
source_providers.register(name: name, group: group, &block)
def self.register_provider_source(name, group:, source: nil, &block)
if source && block
raise ArgumentError, "You must supply only a `source:` option or a block, not both"
end

if source
provider_sources.register(name: name, group: group, source: source)
else
provider_sources.register_from_block(
name: name,
group: group,
target_container: self,
&block
)
end
end

def self.register_component(name, provider:, &block)
Dry::Core::Deprecations.announce(
"Dry::System.register_component",
"Use `Dry::System.register_source_provider` instead",
"Use `Dry::System.register_provider_source` instead",
tag: "dry-system",
uplevel: 1
)

register_source_provider(name, group: provider, &block)
register_provider_source(name, group: provider, &block)
end

# @api private
def self.source_providers
@source_providers ||= SourceProviderRegistry.new
def self.provider_sources
@provider_sources ||= ProviderSourceRegistry.new
end
end
end
197 changes: 0 additions & 197 deletions lib/dry/system/booter.rb

This file was deleted.

37 changes: 0 additions & 37 deletions lib/dry/system/booter/provider_registry.rb

This file was deleted.

11 changes: 9 additions & 2 deletions lib/dry/system/components.rb
@@ -1,5 +1,12 @@
# frozen_string_literal: true

require "dry/system"
require "dry/core/deprecations"

Dry::System.register_source_providers Pathname(__dir__).join("system_components").realpath
Dry::Core::Deprecations.announce(
"require \"dry/system/components\"",
"Use `require \"dry/system/provider_sources\"` instead",
tag: "dry-system",
uplevel: 1
)

require_relative "provider_sources"
35 changes: 0 additions & 35 deletions lib/dry/system/components/config.rb

This file was deleted.