Class | Bio::Shell::Irb
In: | lib/bio/shell/irb.rb
Parent: | Object

### Methods

new setup_irb start_irb

### Public Class methods

new()

[Source]

        # File lib/bio/shell/irb.rb, line 15
    15:     def initialize
    16:       require 'irb'
    17:       begin
    18:         require 'irb/completion'
    19:         Bio::Shell.cache[:readline] = true
    20:       rescue LoadError
    21:         Bio::Shell.cache[:readline] = false
    22:       end
    23:       IRB.setup(nil)
    24:       setup_irb
    25:       start_irb
    26:     end

### Public Instance methods

setup_irb()

[Source]

        # File lib/bio/shell/irb.rb, line 58
    58:     def  setup_irbsetup_irb
    59:       # set application name
    60:       IRB.conf[:AP_NAME] = 'bioruby'
    61:
    62:       # change prompt for bioruby
    63:       $_ = Bio::Shell.colors
    64:       IRB.conf[:PROMPT][:BIORUBY_COLOR] = {
    65:         :PROMPT_I => "bio#{$_[:ruby]}ruby#{$_[:none]}> ",
    66:         :PROMPT_S => "bio#{$_[:ruby]}ruby#{$_[:none]}%l ",
    67:         :PROMPT_C => "bio#{$_[:ruby]}ruby#{$_[:none]}+ ",
    68:         :RETURN   => "  ==> %s\n"
    69:       }
    70:       IRB.conf[:PROMPT][:BIORUBY] = {
    71:         :PROMPT_I => "bioruby> ",
    72:         :PROMPT_S => "bioruby%l ",
    73:         :PROMPT_C => "bioruby+ ",
    74:         :RETURN   => "  ==> %s\n"
    75:       }
    76:       if Bio::Shell.config[:color]
    77:         IRB.conf[:PROMPT_MODE] = :BIORUBY_COLOR
    78:       else
    79:         IRB.conf[:PROMPT_MODE] = :BIORUBY
    80:       end
    81:
    82:       # echo mode (uncomment to off by default)
    83:       #IRB.conf[:ECHO] = Bio::Shell.config[:echo] || false
    84:
    85:       # irb/input-method.rb >= v1.5 (not in 1.8.2)
    86:       #IRB.conf[:SAVE_HISTORY] = 100000
    87:
    88:       # not nicely works
    89:       #IRB.conf[:AUTO_INDENT] = true
    90:     end

start_irb()

[Source]

        # File lib/bio/shell/irb.rb, line 28
    28:     def start_irb
    29:       Bio::Shell.cache[:irb] = IRB::Irb.new
    30:
    31:       # needed for method completion
    32:       IRB.conf[:MAIN_CONTEXT] = Bio::Shell.cache[:irb].context
    33:
    34:       # store binding for evaluation
    35:       Bio::Shell.cache[:binding] = IRB.conf[:MAIN_CONTEXT].workspace.binding
    36:
    37:       # overwrite gets to store history with time stamp
    38:       io = IRB.conf[:MAIN_CONTEXT].io
    39:       io.class.class_eval do
    40:         alias_method :irb_original_gets, :gets
    41:       end
    42:
    43:       def io.gets
    44:         line = irb_original_gets
    45:         if line
    46:           Bio::Shell.store_history(line)
    47:         end
    48:         return line
    49:       end
    50:
    51:       if File.exists?("./config/boot.rb")
    52:         require "./config/boot"
    53:         require "./config/environment"
    54:         #require 'commands/console'
    55:       end
    56:     end

[Validate]