35 lines
560 B
Ruby
Raw Normal View History

require "irb"
module IRB
@setup_done = false
2015-03-10 23:25:31 -04:00
extend Module.new {
def parse_opts; end
2015-03-10 23:25:31 -04:00
def start_within(binding)
unless @setup_done
setup(nil)
@setup_done = true
end
2015-03-10 23:25:31 -04:00
workspace = WorkSpace.new(binding)
irb = Irb.new(workspace)
2017-09-24 19:24:46 +01:00
@CONF[:IRB_RC]&.call(irb.context)
2015-03-10 23:25:31 -04:00
@CONF[:MAIN_CONTEXT] = irb.context
trap("SIGINT") do
irb.signal_handle
end
2015-03-10 23:25:31 -04:00
begin
catch(:IRB_EXIT) do
irb.eval_input
end
ensure
irb_at_exit
end
end
2015-03-10 23:25:31 -04:00
}
end