38 lines
612 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require "irb"
# @private
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
2020-08-17 13:31:16 +01:00
setup(nil, argv: [])
2015-03-10 23:25:31 -04:00
@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