Skip to content

Commit

Permalink
Merge branch 'interactive-shell-update-for-new-boot-system'
Browse files Browse the repository at this point in the history
  • Loading branch information
mtodd committed Jun 20, 2008
2 parents 1d3b7e0 + ec57f5d commit 50ced86
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
12 changes: 10 additions & 2 deletions lib/halcyon/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,14 @@ def route
end
end

# Used to keep track of whether the boot process has been run yet.
attr_accessor :booted

# Runs through the bootup process. This involves:
# * establishing configuration directives
# * loading required libraries
#
def boot
def boot(&block)
Halcyon.config ||= Halcyon::Config.new

# Set application name
Expand All @@ -227,6 +230,9 @@ def boot
require config_file
end

# Yield to the block to handle boot configuration (and other tasks).
Halcyon.config.use(&block) if block_given?

# Setup logger
if Halcyon.config[:logger]
Halcyon.config[:logging] = (Halcyon.config[:logging] || Halcyon::Config.defaults[:logging]).merge({
Expand Down Expand Up @@ -255,7 +261,9 @@ def boot
require model.chomp('.rb')
end

yield if block_given?
# Set to loaded so additional calls to boot are ignored (unless
# forcefully loaded by ignoring this value).
self.booted = true
end

end
Expand Down
4 changes: 2 additions & 2 deletions lib/halcyon/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Halcyon
# * setting up the logger
# * loading initializers
# * loading controllers
# All of which is done by the call to <tt>Halcyon::Application.boot</tt>.
#
# The Runner is a full-fledged Rack application, and accepts calls to #call.
#
Expand All @@ -14,15 +15,14 @@ module Halcyon
# Halcyon::Runner.run!(['start', '-p', '4647'])
#
# # load the config file and initialize the app
# Halcyon::Runner.load_config Halcyon.root/'config'/'config.yml'
# Halcyon::Runner.new
class Runner

autoload :Commands, 'halcyon/runner/commands'

# Initializes the application and application resources.
def initialize(&block)
Halcyon::Application.boot(&block)
Halcyon::Application.boot(&block) unless Halcyon::Application.booted
@app = Halcyon::Application.new
end

Expand Down
7 changes: 3 additions & 4 deletions lib/halcyon/runner/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ def console(argv)
# Set up the application
Object.instance_eval do
$log = ''
Halcyon::Runner.load_paths if Halcyon.paths.nil?
(Halcyon.config = Halcyon::Runner.load_config) || require(Halcyon.root/'app')
Halcyon.config[:logger] = Logger.new(StringIO.new($log))
$app = Halcyon::Runner.new
$app = Halcyon::Runner.new do |c|
c[:logger] = Logger.new(StringIO.new($log))
end
$response = nil
end

Expand Down

0 comments on commit 50ced86

Please sign in to comment.