How to run FastRI on Ruby 1.9.1

July 6, 2009

Alrighty, FastRI is a sweet program written by Mauricio Fernandez (of eigenclass.org, which is down currently for some reason) for doing RI (Ruby Documentation) lookups very quickly, it supports doing all sorts of neat things like running a DRb server for lookups and other cool things :)

Anyway, if you found this, you probably don’t want to listen to me blabber, you want to know how to get it running on Ruby 1.9.x, so I humbly present a patch!

Download the patch here (older version) version 2

Download the patch here, version 3.

First, download the FastRI tarball (version 0.3.1 is latest at the time of this writing) from rubyforge.

Here’s how to install the patch:

% tar zxf fastri-0.3.1.tar.gz
% cd fastri-0.3.1
% patch -p1 < ../fastri-0.3.1-ruby1.9.1.v2.patch
patching file bin/fastri-server
patching file lib/fastri/ri_index.rb
patching file lib/fastri/ri_service.rb
patching file lib/fastri/util.rb
patching file test/test_functional_ri_service.rb
% sudo ruby setup.rb

And you’re done! Now you’ll need to make sure to do a ‘fastri-server -b‘ to build the cache, and from there you can use FastRI the same as it was in Ruby 1.8, see:

[hinmanm@Xanadu:~]% qri String.each_codepoint
-------------------------------------------------- String#each_codepoint
str.each_codepoint {|integer| block }    => str
From
------------------------------------------------------------------------
Passes the Integer ordinal of each character in str, also known as
a codepoint when applied to Unicode strings to the given block.
"hello\u0639".each_codepoint {|c| print c, ' ' }
produces:
104 101 108 108 111 1593

Notes/Caveats/Disclaimers & Warnings:

This patch is a WORK IN PROGRESS, it may hang, crash, steal your wallet and/or delete files. I hacked it up in a day looking at FastRI because I really like using ‘qri’ for everything and was consistently annoyed by getting docs intended for 1.8. I assume no responsibility for these things.

Also, note that all tests don’t pass with this patch, I’m still working on it.

Feel free to leave any feedback for me :)

UPDATE:
New version of the patch that fixes doing a lookup on a base class instead of a method. so… version 3 right now. (link above)

UPDATE2:
I created a github project for fastri to build a gem, so you can install the gem (without patching!) using this command:

sudo gem install dakrone-fastri -s http://gems.github.com

tags: , , , , , ,
posted in fastri, fri, patch, qri, ruby by Lee

13 Comments to "How to run FastRI on Ruby 1.9.1"

  1. roger rubygems wrote:

    could you perhaps create a github project for it? Then we could all install your gem more easily like “gem install xxx-fastri” and enjoy the bliss.
    Or I could if you so desire.
    -r

  2. roger rubygems wrote:

    oops forgot to check the “notify me of followup comments” box–this comment so that it will do so :)

  3. Lee wrote:

    Sure, I will create a github project for it later tonight and update the post with it. Good suggestion.

  4. Lee wrote:

    @Roger,
    Alrighty, I’ve set up a project and had github build a gem, you can install it with ‘sudo gem install dakrone-fastri’. Enjoy!

  5. roger wrote:

    suh weet. Maybe advertise it on ruby talk so people know? :)
    =r

  6. Lee wrote:

    Next time someone mentions FastRI I will :)

  7. Bhrgunatha wrote:

    I came across another problem – trying to build a full text index using fastri-server -B fails.

    You can fix it by changing line 57 of fastri-server (in the make_full_text_index method) from:

    paths = [ RI::Paths::SYSDIR, RI::Paths::SITEDIR, RI::Paths::HOMEDIR ].find_all do |p|

    to

    paths = [ ::RDoc::RI::Paths::SYSDIR, ::RDoc::RI::Paths::SITEDIR, ::RDoc::RI::Paths::HOMEDIR ].find_all do |p|

  8. Moritz Bunkus wrote:

    Unfortunately your patch doesn’t work right for me. It applies cleanly to fastri 0.3.1, no error messages, but whenever I invoke “fri” the output from fastri-server goes to fastri-server’s stdout, and “fri” itself only outputs a single blank line.

    Any idea how to fix that?

  9. roger wrote:

    AS a note newer versions of RDoc have an ri lookup that is *much* faster.
    Doing a gem install rdoc helps much in this regard.

    For those looking for irb fastri you could checkout ri_for
    http://github.com/rdp/ri_for

    or such (or use fastri from here). That’s about your only options :)

    -r

  10. Moritz Bunkus wrote:

    My point is that “the fastri from here” doesn’t work properly for me. fastri-server outputs to its stdout which is totally useless as fastri-server is usually started as a daemon.

    As for fastri in rb: yes, I did use it and I love it’s tab completion (well, that’s actually provided by “irb_lookup”). I didn’t know ri_for and will give it a try. irb_lookup has code for invoking ri instead of fri, so I’ll try that as well combined with the newer ri gem.

  11. Leonardo Valeri Manera wrote:

    Here its failing with a superclass mismatch for class Paragraph from rdoc/markup/fragments.rb:4 on 1.9.1p429 Winstaller as soon as any part of fastri is called …

  12. Arnaud Meuret wrote:

    Yes, same thing on Linux, it has been broken since at least ruby 1.9.1p376 (2009-12-07 revision 26041).

    Sad.

  13. Arnaud Meuret wrote:

    Solved the superclass mismatch problem; now it works nicely.

    All I had to do (after understanding the message, thanks to http://jackndempsey.blogspot.com/2008/06/superclass-mismatch.html) was get rid of old rdoc gems (sudo gem uni rdoc).

 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org