Skip to content

Commit

Permalink
Move IRB initialization into an overridable method.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKvalheim committed Feb 26, 2015
1 parent ef83586 commit 8817f4a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 10 additions & 0 deletions middleman-core/features/console.feature
@@ -0,0 +1,10 @@
Feature: Console

Scenario: Enter and exit the console
Given I run `middleman console` interactively
When I type "puts 'Hello from the console.'"
And I type "exit"
Then it should pass with:
"""
Hello from the console.
"""
11 changes: 10 additions & 1 deletion middleman-core/lib/middleman-core/cli/console.rb
Expand Up @@ -34,10 +34,19 @@ def console

# TODO: get file watcher / reload! working in console

interact_with @app
end

private

# Start an interactive console in the context of the provided object.
# @param [Object] context
# @return [void]
def interact_with(context)
IRB.setup nil
IRB.conf[:MAIN_CONTEXT] = IRB::Irb.new.context
require 'irb/ext/multi-irb'
IRB.irb nil, @app
IRB.irb nil, context
end
end
end

0 comments on commit 8817f4a

Please sign in to comment.