Method: Bio::Shell::Irb#start_irb

Defined in:
lib/bio/shell/irb.rb

#start_irbObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/bio/shell/irb.rb', line 28

def start_irb
  Bio::Shell.cache[:irb] = IRB::Irb.new

  # needed for method completion
  IRB.conf[:MAIN_CONTEXT] = Bio::Shell.cache[:irb].context

  # store binding for evaluation
  Bio::Shell.cache[:binding] = IRB.conf[:MAIN_CONTEXT].workspace.binding

  # overwrite gets to store history with time stamp
  io = IRB.conf[:MAIN_CONTEXT].io
  io.class.class_eval do
    alias_method :irb_original_gets, :gets
  end

  def io.gets
    line = irb_original_gets
    if line
      Bio::Shell.store_history(line)
    end
    return line
  end

  if File.exists?("./config/boot.rb")
    require "./config/boot"
    require "./config/environment"
    #require 'commands/console'
  end
end