pry - https://github.com/banister/pry
[quote]Pry is a powerful alternative to the standard IRB shell for Ruby. It is written from scratch to provide a number of advanced features, some of these include:
Source code browsing (including core C source with the pry-doc gem)
Documentation browsing
Live help system
Syntax highlighting
Command shell integration (start editors, run git, and rake from within Pry)
Gist integration
Navigation around state (cd, ls and friends)
Runtime invocation (use Pry as a developer console or debugger)
Exotic object support (BasicObject instances, IClasses, ...)
A Powerful and flexible command system
Ability to view and replay history
Many convenience commands inspired by IPython and other advanced REPLs[/quote]
pry(main)> class Hello
pry(main)* @x = 20
pry(main)* end
=> 20
pry(main)> cd Hello
pry(Hello):1> ls -i
=> [:@x]
pry(Hello):1> cd @x
pry(20:2)> self + 10
=> 30
pry(20:2)> cd ..
pry(Hello):1> cd ..
pry(main)> cd ..
[code]pry(main)> cd Gem
pry(Gem):1> show-doc try_activate
From: /Users/john/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb @ line 201:
Number of lines: 3
Try to activate a gem containing path. Returns true if
activation succeeded or wasn’t needed because it was already
activated. Returns false if it can’t find the path in a gem.
pry(Gem):1>[/code]
[code]pry(main)> show-method Array#select
From: array.c in Ruby Core (C Method):
Number of lines: 15
static VALUE
rb_ary_select(VALUE ary)
{
VALUE result;
long i;
RETURN_ENUMERATOR(ary, 0, 0);
result = rb_ary_new2(RARRAY_LEN(ary));
for (i = 0; i < RARRAY_LEN(ary); i++) {
if (RTEST(rb_yield(RARRAY_PTR(ary)[i]))) {
rb_ary_push(result, rb_ary_elt(ary, i));
}
}
return result;
}[/code]
I najlepsze (koniec debugu putsami i inspectami w kodzie) :D:
code:
[code]# test.rb
require ‘pry’
class A
def hello() puts “hello world!” end
end
a = A.new
start a REPL session
binding.pry
program resumes here (after pry session)
puts “program resumes here.”[/code]
Pry session:
[code]pry(main)> a.hello
hello world!
=> nil
pry(main)> def a.goodbye
pry(main)* puts “goodbye cruel world!”
pry(main)* end
=> nil
pry(main)> a.goodbye
goodbye cruel world!
=> nil
pry(main)> exit
program resumes here.[/code]
EDIT: I kolejna alternatywa (chyba nawet ciekawsza: https://github.com/cldwalker/ripl)