IRB – Interactive Ruby Shell

IRB – Interactive Ruby Shell

jul 13

Passar batido sem falar do irb ficaria um tanto complicado. Você vê tuas linhas ganharem vida no irb quando executa o código na unha.

O irb pode lêr sua configuração de um ~/.irbrc da vida. O que uso:

require 'irb/completion'
require 'irb/ext/save-history'
 
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
puts "History configured."
 
# auto-indent
IRB.conf[:AUTO_INDENT]=true
puts "Auto-indent on."
 
require 'rubygems'
require 'map_by_method'
require 'what_methods'
require 'pp'
require 'wirble'
 
THEME_FOR_WHITE_BKG = {
      # delimiter colors
      :comma              => :purple,
      :refers             => :blue,
 
      # container colors (hash and array)
      :open_hash          => :red,
      :close_hash         => :red,
      :open_array         => :red,
      :close_array        => :red,
 
      # object colors
      :open_object        => :dark_gray,
      :object_class       => :purple,
      :object_addr_prefix => :blue,
      :object_line_prefix => :blue,
      :close_object       => :dark_gray,
      # symbol colors
      :symbol             => :black,
      :symbol_prefix      => :light_gray,
 
      # string colors
      :open_string        => :blue,
      :string             => :dark_gray,
      :close_string       => :blue,
 
      # misc colors
      :number             => :black,
      :keyword            => :brown,
      :class              => :red,
      :range              => :blue,
    }
 
#Wirble::Colorize.colors = THEME_FOR_WHITE_BKG
Wirble.init(:skip_prompt=>true,:skip_history=>true)
Wirble.colorize

Leave a Reply