Skip to content

Instantly share code, notes, and snippets.

@BanzaiMan
Created August 5, 2009 22:43
Show Gist options
  • Save BanzaiMan/163024 to your computer and use it in GitHub Desktop.
Save BanzaiMan/163024 to your computer and use it in GitHub Desktop.
require 'irb'
module IRB
def self.start_session(binding)
IRB.setup(nil)
workspace = WorkSpace.new(binding)
if @CONF[:SCRIPT]
irb = Irb.new(workspace, @CONF[:SCRIPT])
else
irb = Irb.new(workspace, f=File.new("test_output.txt"))
end
def f.prompt=(prompt)
nil
end
@CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
@CONF[:MAIN_CONTEXT] = irb.context
trap("SIGINT") do
irb.signal_handle
end
catch(:IRB_EXIT) do
irb.eval_input
end
end
end
if __FILE__ == $0
IRB.start_session __FILE__
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment