Computing Magazine

Colourized Logging in Ruby(irb) Prompt

Posted on the 12 September 2014 by Abhishek Somani @somaniabhi
Wirble is a set of enhancements for ruby(irb). Wirble enables several items mentioned on the RubyGarden "Irb Tips and Tricks" page, including tab-completion, history, and a built-in ri command, as well as colorized results and a couple other goodies.Wirble even works with rvm , lets hack the trick to do so:Step 1: When we start irb prompt it first checks for .irbrc file in home folder. ~/.irbrc.Step 2 : To enable wirble in irb prompt, Open the ~/.irbrc file (Create a new one if Not present.), and Paste the contents of the below code.

require 'irb/completion'
require 'irb/ext/save-history'
require 'rubygems'
unless Gem::Specification.find_all_by_name('wirble').any?
puts "Installing Wirble"
%x{gem install 'wirble' --no-ri --no-rdoc}
end
Gem.refresh
require 'wirble'
# Initializing Wirble
Wirble.init
Wirble.colorize
# Customize according to your will.
colors = Wirble::Colorize.colors.merge({
:object_class => :purple,
:symbol => :purple,
:symbol_prefix => :purple
})
Wirble::Colorize.colors = colors
Step 3: Move out of the blog for a colourfull irb prompt and Njoy Coding in Ruby. Thanks to Santosh for writing this post .COLOURIZED LOGGING IN RUBY(IRB) PROMPT

Back to Featured Articles on Logo Paperblog

Magazines