Module: IRB

Defined in:
lib/live_console.rb

Overview

We need to make a couple of changes to the IRB module to account for using a weird I/O method and re-starting IRB from time to time.

Defined Under Namespace

Classes: Context, Irb

Constant Summary collapse

ARGV =
[]

Class Method Summary collapse

Class Method Details

.start_with_io(io, bind, &block) ⇒ Object

Overridden a la FXIrb to accomodate our needs.



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/live_console.rb', line 132

def IRB.start_with_io(io, bind, &block)
	unless @inited
		setup '/dev/null'
		IRB.parse_opts
		IRB.load_modules
		@inited = true
	end

	ws = IRB::WorkSpace.new(bind)
	irb = Irb.new(ws, io, io)
	bind ||= IRB::Frame.top(1) rescue TOPLEVEL_BINDING

	@CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
	@CONF[:MAIN_CONTEXT] = irb.context
	@CONF[:PROMPT_MODE] = :INF_RUBY

	catch(:IRB_EXIT) { 
		begin
			irb.eval_input
		rescue StandardError => e
			irb.print([e.to_s, e.backtrace].flatten.join("\n") + "\n")
			retry
		end
	}
	irb.print "\n"
end