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
Constant Summary collapse
- ARGV =
[]
Class Method Summary collapse
-
.start_with_io(io, bind, &block) ⇒ Object
Overridden a la FXIrb to accomodate our needs.
Class Method Details
.start_with_io(io, bind, &block) ⇒ Object
Overridden a la FXIrb to accomodate our needs.
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/live_console.rb', line 163 def IRB.start_with_io(io, bind, &block) unless @inited setup '/dev/null' IRB.parse_opts IRB.load_modules @inited = true end #Redirect stdout and stderr to cover output of Ruby commands like puts $stdout.sync=true $stderr.sync=true $stdout.reopen(io.output) $stderr.reopen(io.output) ws = IRB::WorkSpace.new(bind) @CONF[:PROMPT_MODE] = :DEFAULT #Remove the context from all prompts-can be too long depending on binding @CONF[:PROMPT][:DEFAULT][:PROMPT_I] = "%N():%03n:%i> " @CONF[:PROMPT][:DEFAULT][:PROMPT_N] = "%N():%03n:%i> " #Add > to S and C as they don't get picked up by telnet prompt scan @CONF[:PROMPT][:DEFAULT][:PROMPT_S] = "%N():%03n:%i%l> " @CONF[:PROMPT][:DEFAULT][:PROMPT_C] = "%N():%03n:%i*> " @CONF[:USE_READLINE] = false 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 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 |