Module: IRB

Defined in:
lib/tupelo/app/irb-shell.rb

Class Method Summary collapse

Class Method Details

.parse_optsObject



7
8
9
# File 'lib/tupelo/app/irb-shell.rb', line 7

def IRB.parse_opts
  # Don't touch ARGV, which belongs to the app which called this module.
end

.start_session(*args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/tupelo/app/irb-shell.rb', line 11

def IRB.start_session(*args)
  unless $irb
    IRB.setup nil
    ## maybe set some opts here, as in parse_opts in irb/init.rb?
  end

  workspace = WorkSpace.new(*args)

  @CONF[:PROMPT_MODE] = :SIMPLE

  # Enables _ as last value
  @CONF[:EVAL_HISTORY] = 1000
  @CONF[:SAVE_HISTORY] = 100

  if @CONF[:SCRIPT] ## normally, set by parse_opts
    $irb = Irb.new(workspace, @CONF[:SCRIPT])
  else
    $irb = Irb.new(workspace)
  end

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

  trap 'INT' do
    $irb.signal_handle
  end
  
  custom_configuration if defined?(IRB.custom_configuration)

  begin
    catch :IRB_EXIT do
      $irb.eval_input
    end
  ensure
    IRB.irb_at_exit
  end
  
  ## might want to reset your app's interrupt handler here
end