The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
irbtools / Release the power of irb!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jan Lelis

Posts: 136
Nickname: rbjl
Registered: Aug, 2009

Jan Lelis is an IT student from Dresden/Germany
irbtools / Release the power of irb! Posted: Oct 6, 2010 11:44 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jan Lelis.
Original Post: irbtools / Release the power of irb!
Feed Title: rbJ*_*L.net
Feed URL: http://feeds.feedburner.com/rbJL
Feed Description: Hi, I am a fan of Ruby and like to explore it and the world around ;). So I started this blog, where I am publishing code snippets, tutorials for beginners as well as general thoughts about Ruby, the web or programming in general.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jan Lelis
Latest Posts From rbJ*_*L.net

Advertisement

Equipped with some tools discussed at the germany.rb user group meetup, I’ve played around with my ~/.irbrc and put together a little meta gem for some useful irb tools.

Features

  • Colorized by wirble and put out as comment by irb_rocket
  • Nice IRB prompt and IRB’s auto indention (still simple, but still far better than none)
  • FileUtils: ls, cd, pwd, ln_s, rm, mkdir, touch, cat
  • Many debugging helpers: ap, q, o, c, y, Object#m, Object#d
    • apawesome_print
    • q – like p, but on one line
    • Object#m – ordered method list (takes integer parameter: level of nesting)
    • Objedt#d – puts the object, returns self (using tap)
  • “Magical” information constants: Info, OS, RubyVersion, RubyEngine
    • OS.windows?
    • RubyEngine.jruby?
    • RubyVersion.is.at_least? 1.9
  • guessmethod automatically corrects typing mistakes or suggests alternative methods (method_missing hook)
  • Clipboard features: copy and paste
    • also available: copy_input and copy_output for session history
  • Call vim (or another supported editor) to edit a file, close it and it gets loaded into your current irb session, powered by interactive_editor
  • Highlight a string with colorize('string') or a file with ray('path'), powered by coderay
  • Displays ActiveRecord databse entries as tables with hirb
  • Restart irb with reset! or change the Ruby version with the use method and rvm!
  • Includes the current directory in the load path (was removed in 1.9.2 for security reasons, but is pretty annoying in irb)
  • Shorter requiring like this: rq:mathn
  • (DrX object inspector: Object#see, requires tk – did not include it in the gem, because it fails to build correctly on lots of system)

Screenshots

irbtools examples 1

irbtools examples 2

Setup

gem install irbtools
gem install irb_rocket --source http://merbi.st

On Linux, you also need to sudo apt-get install xclip

On MacOS, you can install growl to use the g gem.

Usage

To use it, put the following in your ~/.irbrc file (this file is loaded everytime you start an irb):

require 'rubygems' # only needed in 1.8
require 'irbtools'

If it does not exists, just create a new one.

It’s is possible to modify, which libraries get loaded:

# no require 'irbtools'
require 'irbtools/configure'
# edit the Irbtools.libs array 
Irbtools.init

You could also just read and copy the irbtools/configure.rb and irbtools.rb source files, tweak them and use them directly as .irbrc ;)

By the way

Sometimes, you need a clean IRB without all the .irbrc libraries. In such a case, just start irb with the -f option and it will suppress loading the .irbrc.

Github

CC-BY (DE)

Read: irbtools / Release the power of irb!

Topic: Resque-multi-step Previous Topic   Next Topic Topic: An Introduction to Outside-in Development

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use