A sip of better doc

Posted by yudi
on Friday, January 04

I still remember the sweet time that we had open book finals for a couple of basic computing classes (100 level). As the professor said, as a programmer we all keep a handy book while writing code in order to look up.

For ruby, we got ri, but there is a lot faster and much more intelligent tool called fast-ri. I happen to read it in the textmate changlog today. After a little digging around, here is what I find:

Start by install it with the command:


sudo gem install fastri

Then build index with:


sudo fastri-server -b

You may use qri command to access local fast-ri:

Or, because fast-ri is DRb enabled, you can also use command fri.

Since I don’t have a fast-ri setup, I’ll just compare the speed between qri and ri

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
~ $ time qri -f plain Array#insert
----------------------------------------------------------- Array#insert
     array.insert(index, obj...)  -> array
------------------------------------------------------------------------
     Inserts the given values before the element with the given index
     (which may be negative).

        a = %w{ a b c d }
        a.insert(2, 99)         #=> ["a", "b", 99, "c", "d"]
        a.insert(-2, 1, 2, 3)   #=> ["a", "b", 99, "c", 1, 2, 3, "d"]


real        0m0.243s
user        0m0.181s
sys        0m0.042s
~ $
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
~ $ time ri -T -f plain Array#insert
----------------------------------------------------------- Array#insert
     array.insert(index, obj...)  -> array
------------------------------------------------------------------------
     Inserts the given values before the element with the given index
     (which may be negative).

        a = %w{ a b c d }
        a.insert(2, 99)         #=> ["a", "b", 99, "c", "d"]
        a.insert(-2, 1, 2, 3)   #=> ["a", "b", 99, "c", 1, 2, 3, "d"]


real        0m1.193s
user        0m0.738s
sys        0m0.441s

Power of index made the search 5 times faster (real) on fast-ri. Not to mention, it looks beautiful under terminal:

Also, Nathan contributed a command for textmate to have it support fast-ri as well. Here is my screen-shot:

returns:

The fast-ri author http://eigenclass.org is offline right now. I hope they can be up as soon as possible.

Here is the link to the fast-ri author page: http://eigenclass.org//hiki.rb?fastri

If you don’t use textmate and unix, there are ajax-flavored apis for you to look-up:

noobkit.com

gotapi.com

Comments

Leave a response