[ANN] ri_for 0.6.0 released--easy lookup of method documentation in irb

Hello all.
Pleased to announce the release of “ri_for” gem v 0.6.0

Changes:
0.6.0: jruby support, add File.method(:delete).ri_for

more information see https://github.com/rdp/ri_for

README contents:

The ri_for gem allows “runtime documentation lookup”, it show a method’s
source code/comments, ri (if available), arity, parameters,
etc. all at runtime (for example within an irb session).

Don’t know what a method does? Look it up!
It has proven quite useful, and I wouldn’t do a ruby-debug session
without it–you might like it.

Examples:

File.ri_for :delete

sig: File.delete arity -1
appears to be a c method
Searching ri for
sig: File.delete arity -1

----------------------------------------------------------- File::delete
File.delete(file_name, …) => integer
File.unlink(file_name, …) => integer


 Deletes the named files, returning the number of names passed as
 arguments. Raises an exception on any error. See also +Dir::rmdir+.

(end ri)
=> “sig: File.delete arity -1”

(or alternatively use >> File.method(:delete).ri_for)

or, given this dynamically generated class, it can still show runtime
parameter information:

class A;
def go(a); end;
end

A.new.ri_for :go

sig: A#go arity 1
def go(a)

do nothing

end
Parameters: go(a)
Searching ri for
sig: A#go arity 1

Nothing known about A
(end ri)
=> “Parameters: go(a)”

Or (my favorite) use it within debug session:

74 assert(true == false)

(rdb:1) ri_for :assert
#<Method: StoreControllerTest(Test::Unit::Assertions)#assert>
arity: -2
ri for Test::Unit::Assertions#assert
------------------------------------------ Test::Unit::Assertions#assert
assert(boolean, message=nil)

 From gem test-unit-2.0.1

 Asserts that +boolean+ is not false or nil.

 Example:

   assert [1, 2].include?(5)

(end ri)
def assert(boolean, message = nil)
_wrap_assertion do
assert_block(“assert should not be called with a block.”) do
(not block_given?)
end
assert_block(build_message(message, “<?> is not true.”, boolean)) {
boolean }
end
end
Parameters: assert(boolean, message = nil)

Thus, you can look at methods’ source/rdocs without having to run the
methods and step into them. Deftly convenient.

On Fri, Sep 2, 2011 at 5:23 AM, Roger P. [email protected]
wrote:

Pleased to announce the release of “ri_for” gem v 0.6.0

cool.
is it possible to show where the method is located?

thnaks for ri_for
-botp

On Fri, Sep 2, 2011 at 11:02 AM, botp [email protected] wrote:

On Fri, Sep 2, 2011 at 5:23 AM, Roger P. [email protected] wrote:

Pleased to announce the release of “ri_for” gem v 0.6.0

cool.
is it possible to show where the method is located?

And how about colored output? I couldn’t find anything in the README,
or on the issue tracker.

On Sep 1, 2011, at 2:23 PM, Roger P. wrote:

source code/comments, ri (if available), arity, parameters,
etc. all at runtime (for example within an irb session).

Don’t know what a method does? Look it up!
It has proven quite useful, and I wouldn’t do a ruby-debug session
without it–you might like it.

Why do you use RDoc::RI::Driver::run instead of RDoc::RI::Driver::new
and RDoc::RI::Driver#display_names?

cool.
is it possible to show where the method is located?

thnaks for ri_for
-botp

It does in 1.9 I think I could do it in 1.8.x by reading through all
the $LOADED_FEATURES and trying to find “any file that looks like it
matches” good idea.

And how about colored output? I couldn’t find anything in the README,
or on the issue tracker.

I’ll see what I can do (at least by allowing RI’s colors…or did you
want more than that?) :slight_smile:

Why do you use RDoc::RI::Driver::run instead of RDoc::RI::Driver::new
and RDoc::RI::Driver#display_names?

Because I didn’t know how. I’ll see if I can use instead
display_names…

Thanks!
-r

On Sat, Sep 3, 2011 at 11:22 PM, Roger P. [email protected]
wrote:
[…]

And how about colored output? I couldn’t find anything in the README,
or on the issue tracker.

I’ll see what I can do (at least by allowing RI’s colors…or did you
want more than that?) :slight_smile:

Not sure. I tend to use Google more than ri, but I guess that should
be ok for a start. Infact, if you are ok I can have a look into it as
well. That is the least I can do to to thank you for this gem; I had
multiple hacks in my .irbrc for a small subset of what ri_for has to
offer. Just that I am a little busy with other things for the moment,
and will take some time (a week or two) before I can come up with
something.