Skip to content

Instantly share code, notes, and snippets.

@elmer
Forked from twoism/consolize.rb
Created September 19, 2010 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elmer/586424 to your computer and use it in GitHub Desktop.
Save elmer/586424 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'irb'
def consolize &block
yield
IRB.setup(nil)
irb = IRB::Irb.new
IRB.conf[:MAIN_CONTEXT] = irb.context
irb.context.evaluate("require 'irb/completion'", 0)
trap("SIGINT") do
irb.signal_handle
end
catch(:IRB_EXIT) do
irb.eval_input
end
end
consolize do
# require whatever you need
require 'mongo_mapper'
end
# run from command line
$ ruby consolize.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment