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

New dry-system-powered application and slices structure #1019

Merged
merged 83 commits into from Nov 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
54215d7
Initial spike of dry-system-based application/slices structure
timriley Sep 25, 2019
f4cd93c
Switch to another approach
timriley Oct 14, 2019
3d69536
Register inflector from outside when configuring container
timriley Oct 20, 2019
5b7babd
Tweak container setup
timriley Oct 26, 2019
e9441a1
I'm happy with the single param for initialize
timriley Oct 27, 2019
dcc9215
Pass in router settings from configuration
timriley Oct 27, 2019
cc38cd4
Apply middleware defined in config
timriley Oct 27, 2019
32761c3
Improve exposed container API on Application/Slices
timriley Oct 29, 2019
82ddb14
Set up Hanami::Logger instead of using dry-system logging plugin
timriley Nov 1, 2019
fd515e2
Finalize configuration when init'ing application
timriley Nov 1, 2019
af3f4ab
Remove unneeded container class
timriley Nov 1, 2019
27fd07d
Switch back to Hanami.{application/app} names, implement top-level .boot
timriley Nov 2, 2019
b897c82
Tidy constant definition
timriley Nov 2, 2019
9a22871
Update default config
timriley Nov 2, 2019
ea17f26
Reduce amount of extra router logic after pushing some upstream
timriley Nov 3, 2019
070c078
Gracefully support "#" in route names when resolving endpoints
timriley Nov 3, 2019
2690bca
Make method param optionality clearer
timriley Nov 3, 2019
b565858
Remove yield_self usage
timriley Nov 3, 2019
5ecf0cf
Add Hanami.logger back (Soundeck is using it)
timriley Nov 3, 2019
ff283a5
Create 2 levels of "magic" require files and add Hanami.init
timriley Nov 3, 2019
c3a1cbd
Delegate .keys to internal container on Hanami::Application and Slice
timriley Nov 3, 2019
b15cd17
Use Dry::System::Container from slices rather than custom subclass
timriley Nov 3, 2019
ded3f32
Set slice container env from application container
timriley Nov 3, 2019
7a70014
Fix saving of configured middleware without blocks
timriley Nov 3, 2019
4768bb4
Move router and endpoint resolver into "Application" namespace
timriley Nov 4, 2019
12d0841
Update RackLogger output names to match Hanami 1 CommonLogger-style keys
timriley Nov 4, 2019
dc78411
Remove unneeded monitoring plugin
timriley Nov 4, 2019
865a534
Tweak naming of rack_logger_filter_params config setting
timriley Nov 4, 2019
acaf2af
Tidy endpoint resolver config setting
timriley Nov 4, 2019
9af2980
Tidy config for router endpoint container key namespace
timriley Nov 4, 2019
b13ddb2
Fix typo
timriley Nov 5, 2019
6c13445
Improve method delegation for .[]
timriley Nov 5, 2019
1c4f828
Rename application_module to application_namespace
timriley Nov 5, 2019
a43ce29
Tidy up const_set usage by relying on its return value
timriley Nov 5, 2019
f0f91d2
Remove code scraps
timriley Nov 5, 2019
f4193df
Init application (instead of booting) in CLI console
timriley Nov 5, 2019
8c2384b
Remove unneeded require
timriley Nov 5, 2019
679a3e0
Remove unneeded require
timriley Nov 5, 2019
21c0ad3
Make it possible to Hanami.boot and skip loading web-specific code
timriley Nov 5, 2019
ebd4a7b
Add "inflector" alias to configuration
timriley Nov 5, 2019
f05fafd
Make root configurable
timriley Nov 5, 2019
9885bee
Properly handle default value for slices_dir setting
timriley Nov 5, 2019
9be7d64
Move require for web/rack_logger back to where we need it
timriley Nov 5, 2019
199f184
Load routes when initing the Hanami application
timriley Nov 7, 2019
faca8cb
Remove comment
timriley Nov 7, 2019
9b5ead0
Remove disabled rom-rb console helpers (for now)
timriley Nov 7, 2019
8331078
Remove dry-system components provider setup (we don't need it atm)
timriley Nov 7, 2019
ab6c0b3
Configure root of application container
timriley Nov 7, 2019
89be582
Force dry-system after_configure hooks when setting up container
timriley Nov 7, 2019
cc78c43
Fix reference to Hanami.application
timriley Nov 7, 2019
b075fdd
Pass application inflector to CLI commands
timriley Nov 7, 2019
fadcbe7
Add .key? to both Application and Slice and delegate to container
timriley Nov 7, 2019
6e78513
Get a bunch of specs working
timriley Nov 7, 2019
eec6a4a
Add .register_slice to create and register slice instances
timriley Nov 9, 2019
1e38f74
Delegate .register to containers
timriley Nov 9, 2019
48c2c84
Allow slices to be initialized/registered before the application boots
timriley Nov 9, 2019
e360380
Make failing isolation specs work again
timriley Nov 9, 2019
77366ec
Update Gemfile to use required support branches
timriley Nov 9, 2019
329bff0
Allow slice imports and per-slice behavior customization through config
timriley Nov 10, 2019
7f2d4e8
Remove unused require
timriley Nov 10, 2019
4f8f7f2
Import application during slice init
timriley Nov 10, 2019
edd88ce
Raise specific error when trying to import after boot
timriley Nov 10, 2019
5d90065
Add test to verify imports work with non-booted/finalized slices
timriley Nov 10, 2019
85dffed
Remove unneeded comment
timriley Nov 16, 2019
3ecd1ee
Remove unneeded require
timriley Nov 16, 2019
5bb139e
Fix looping through slices
timriley Nov 16, 2019
d8b62da
Ensure application in init'ed when loading CLI
timriley Nov 16, 2019
cbabb60
Move "use" middleware behavior back into Application::Router
timriley Nov 23, 2019
ed011bc
Allow slices to load when their modules already exist
timriley Nov 23, 2019
d787804
Switch back to unstable branch of hanami/controller
timriley Nov 23, 2019
30d7e61
Remove now-unused lib/hanami/web
timriley Nov 23, 2019
d8aedb7
Remove references to as yet unimplemented CLI commands
timriley Nov 23, 2019
e5c99ad
Fix Rubocop issues
timriley Nov 23, 2019
cdffae2
Rely upon unstable branch of hanami-router again
timriley Nov 26, 2019
8afc065
Simplify param name for disabling web-app support
timriley Nov 26, 2019
1d619a9
Add shortcut require file for init-ing the Hanami app
timriley Nov 26, 2019
8bed0f1
Add beginnings of integration tests for major application features
timriley Nov 26, 2019
43b8be9
Fix for Ruby 2.5 and earlier
timriley Nov 26, 2019
fbb809e
Add improved integration specs for slice container imports
timriley Nov 27, 2019
fd598d3
Add integration specs for auto-injection mixin
timriley Nov 27, 2019
4df50d6
Clear out another loaded feature entry between integration specs
timriley Nov 27, 2019
40d94c7
Satisfy Rubocop
timriley Nov 27, 2019
480e8ec
Add integration spec for routing based on container identifiers
timriley Nov 29, 2019
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
4 changes: 4 additions & 0 deletions .rubocop.yml
Expand Up @@ -6,3 +6,7 @@ Naming/HeredocDelimiterNaming:
Enabled: false
Style/CommentedKeyword:
Enabled: false
Style/TrailingCommaInArguments:
Enabled: false
Style/TrailingCommaInHashLiteral:
Enabled: false
6 changes: 3 additions & 3 deletions Gemfile
Expand Up @@ -8,9 +8,9 @@ unless ENV["CI"]
gem "yard", require: false
end

gem "hanami-utils", "~> 2.0.alpha", require: false, git: "https://github.com/hanami/utils.git", branch: "unstable"
gem "hanami-router", "~> 2.0.alpha", require: false, git: "https://github.com/hanami/router.git", branch: "unstable"
gem "hanami-utils", "~> 2.0.alpha", require: false, git: "https://github.com/hanami/utils.git", branch: "unstable"
gem "hanami-router", "~> 2.0.alpha", require: false, git: "https://github.com/hanami/router.git", branch: "unstable"
gem "hanami-controller", "~> 2.0.alpha", require: false, git: "https://github.com/hanami/controller.git", branch: "unstable"
gem "hanami-cli", "~> 1.0.alpha", require: false, git: "https://github.com/hanami/cli.git", branch: "unstable"
gem "hanami-cli", "~> 1.0.alpha", require: false, git: "https://github.com/hanami/cli.git", branch: "unstable"

gem "hanami-devtools", require: false, git: "https://github.com/hanami/devtools.git"
1 change: 1 addition & 0 deletions hanami.gemspec
Expand Up @@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "hanami-router", "~> 2.0.alpha"
spec.add_dependency "hanami-controller", "~> 2.0.alpha"
spec.add_dependency "hanami-cli", "~> 1.0.alpha"
spec.add_dependency "dry-monitor"
spec.add_dependency "dry-system", "~> 0.10"
spec.add_dependency "dry-inflector", "~> 0.1", ">= 0.1.2"
spec.add_dependency "bundler", ">= 1.16", "< 3"
Expand Down
53 changes: 23 additions & 30 deletions lib/hanami.rb
Expand Up @@ -7,52 +7,42 @@
# @see http://hanamirb.org
module Hanami
require "hanami/version"
require "hanami/frameworks"
require "hanami/container"
require "hanami/application"

@_mutex = Mutex.new

def self.application_class
def self.application
@_mutex.synchronize do
raise "Hanami.application_class not configured" unless defined?(@_application_class)
raise "Hanami.application not configured" unless defined?(@_application)

@_application_class
@_application
end
end

def self.application_class=(klass)
def self.application=(klass)
@_mutex.synchronize do
raise "Hanami.application_class already configured" if defined?(@_application_class)
raise "Hanami.application already configured" if defined?(@_application)

@_application_class = klass unless klass.name.nil?
@_application = klass unless klass.name.nil?
end
end

def self.application
def self.app
@_mutex.synchronize do
raise "Hanami.application not configured" unless defined?(@_application)
raise "Hanami.app not configured" unless defined?(@_app)

@_application
@_app
end
end

def self.application=(application)
def self.app=(app)
@_mutex.synchronize do
raise "Hanami.application already configured" if defined?(@_application)
raise "Hanami.app already configured" if defined?(@_app)

@_application = application
@_app = app
end
end

class << self
alias app application
end

def self.root
Container.root
end

def self.env
(ENV["HANAMI_ENV"] || "development").to_sym
end
Expand All @@ -62,18 +52,21 @@ def self.env?(*names)
end

def self.logger
Container[:logger]
application[:logger]
end

def self.boot
@_mutex.synchronize do
raise "Hanami application already booted" if defined?(@_booted)
def self.init
application.init
end

@_booted = true
end
def self.boot(web: true)
if defined?(@_app)
@_app
else
application.boot

Container.finalize!
self.application = application_class.new
@_app = application.new if web
end
end

def self.bundler_groups
Expand Down