Module: RightScale::Console

Defined in:
lib/right_agent/console.rb

Overview

ConsoleHelper

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.instanceObject

Returns the value of attribute instance.



40
41
42
# File 'lib/right_agent/console.rb', line 40

def instance
  @instance
end

Class Method Details

.start(binding, quit_on_exit = true) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/right_agent/console.rb', line 42

def self.start(binding, quit_on_exit=true)
  require 'irb'
  old_args = ARGV.dup
  ARGV.replace ["--simple-prompt"]

  IRB.setup(nil)
  self.instance = IRB::Irb.new(IRB::WorkSpace.new(binding))

  @CONF = IRB.instance_variable_get(:@CONF)
  @CONF[:IRB_RC].call self.instance.context if @CONF[:IRB_RC]
  @CONF[:MAIN_CONTEXT] = self.instance.context

  catch(:IRB_EXIT) { self.instance.eval_input }
ensure
  ARGV.replace old_args
  # Clean up tty settings in some evil, evil cases
  begin; catch(:IRB_EXIT) { irb_exit }; rescue Exception; end
  # Make agent exit when irb does
  EM.stop if EM.reactor_running? && quit_on_exit
end