Skip to content

Commit

Permalink
Changed how the initializers are defined by default, including hooks,…
Browse files Browse the repository at this point in the history
… requires, and routes. Updated the generated apps as well, in addition to the spec app.
  • Loading branch information
mtodd committed Apr 11, 2008
1 parent 905fbea commit fe2d7e4
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 38 deletions.
4 changes: 2 additions & 2 deletions lib/halcyon/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Application
def initialize
self.logger.info "Starting up..."

self.hooks[:startup].call(Halcyon.config) if self.hooks[:startup]
self.hooks[:startup].call(Halcyon.config, Halcyon.logger) if self.hooks[:startup]

# clean after ourselves and get prepared to start serving things
self.logger.debug "Starting GC."
Expand All @@ -38,7 +38,7 @@ def initialize

at_exit do
self.logger.info "Shutting down #{$$}."
self.hooks[:shutdown].call(Halcyon.config) if self.hooks[:shutdown]
self.hooks[:shutdown].call(Halcyon.config, Halcyon.logger) if self.hooks[:shutdown]
self.logger.info "Done."
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Halcyon::Application
# r.default_routes
{:action => 'missing'}
end
startup do |config|
startup do |config, logger|
$started = true
end
end
21 changes: 0 additions & 21 deletions support/generators/halcyon/templates/config/initialize.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# = Hooks
Halcyon::Application.startup do |config, logger|
logger.info 'Define startup tasks in config/initialize/hooks.rb'
end

Halcyon::Application.shutdown do |config, logger|
logger.info 'Define shutdown tasks in config/initialize/hooks.rb'
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# = Required Libraries
%w().each {|dep|require dep}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# = Routes
Halcyon::Application.route do |r|
r.match('/time').to(:controller => 'application', :action => 'time')

r.match('/').to(:controller => 'application', :action => 'index')

# failover
{:action => 'not_found'}
end
28 changes: 14 additions & 14 deletions support/generators/halcyon_flat/templates/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%w().each {|dep|require dep}

# = Configuration
# Halcyon::Runner.load_config Halcyon.root/'config'/'config.yml'
Halcyon.config = {
:allow_from => 'all',
:logging => {
Expand All @@ -13,20 +14,19 @@
}
}.to_mash

# = Initialization
class Halcyon::Application
startup do |config|
self.logger.info 'Initialize application resources and define routes in config/initialize.rb'
end
# = Routes
route do |r|
r.match('/time').to(:controller => 'application', :action => 'time')

r.match('/').to(:controller => 'application', :action => 'index')

# failover
{:action => 'not_found'}
end
# = Routes
Halcyon::Application.route do |r|
r.match('/time').to(:controller => 'application', :action => 'time')

r.match('/').to(:controller => 'application', :action => 'index')

# failover
{:action => 'not_found'}
end

# = Hooks
Halcyon::Application.startup do |config, logger|
logger.info 'Define startup tasks in config/initialize/hooks.rb'
end

# = Application
Expand Down

0 comments on commit fe2d7e4

Please sign in to comment.