Module: IRB

Defined in:
lib/webdrone.rb

Class Method Summary collapse

Class Method Details

.start_session(binding) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/webdrone.rb', line 77

def self.start_session(binding)
  unless Webdrone.irb_setup_done
    IRB.setup(nil)
    Webdrone.irb_setup_done = true
  end

  workspace = WorkSpace.new(binding)

  irb = \
    if @CONF[:SCRIPT]
      Irb.new(workspace, @CONF[:SCRIPT])
    else
      Irb.new(workspace)
    end

  @CONF[:IRB_RC]&.call(irb.context)
  @CONF[:MAIN_CONTEXT] = irb.context

  trap('SIGINT') do
    irb.signal_handle
  end

  begin
    catch(:IRB_EXIT) do
      irb.eval_input
    end
  ensure
    IRB.irb_at_exit
  end
end