FastRI is an alternative to the ri documentation browser for Ruby.
As of 0.3.0, FastRI can operate in standalone mode (without using a DRb
server, see below), so it can now fully replace ri for most intents and
purposes.
Why prefer it over ri? FastRI
* actually works
* is *much* faster than ri
* can perform fast full-text searching over all your rdoc documentation
* is smarter than ri, and can find classes anywhere in the hierarchy without
specifying the "full path"
* can be told to use different search strategies (completion, nested
namespaces, etc.)
* supports RubyGems much better than ri, and knows which gem a method/class
came from
* can serve RI documentation over DRb
Getting it
···
==========
Additional information, tarballs... at
http://eigenclass.org/hiki.rb?fastri
FastRI can be installed with RubyGems:
gem install fastri
(if you get an old version/a 404 error, please allow some time after the
release until the package propagates to the RubyForge mirrors). Please read
below for an important note regarding the RubyGems packages.
User-visible changes since version 0.2.1 (2006-11-23)
* get all the information about a class/module and its methods with --extended
* new search methods: complete namespace (-Om), partial completion on both
namespace and method name (-Of), and case-indep. variants.
* --local (-L) and --remote (-L) (default) options. --local makes fri operate
in standalone mode, without requiring fastri-server.
* new executable: qri, equivalent to fri -L (local, standalone mode)
* try to second-guess the correct method type if all search methods fail
and the type was explicitly given
Usage
Starting from 0.3.0, fri can be used in either local mode (--local, -L) or
remote mode (using a fastri-server, -R, --remote).
By default, fri will run in remote mode. There's a new executable named
qri that defaults to local mode (it behaves otherwise identically to fri).
Remote mode is slightly faster (typically about 150ms) , since the
documentation index is kept in memory and needs not be read from disk.
Local mode
----------
$ qri Array
----------------------------------------------------------- Class: Array
Arrays are ordered, integer-indexed collections of any object.
Array indexing starts at 0, as in C or Java. A negative index is
...
$ qri compact
---------------------------------------------------------- Array#compact
array.compact -> an_array
------------------------------------------------------------------------
Returns a copy of self with all nil elements removed.
Remote mode
-----------
There are two parts to using FastRI in remote mode:
* the server: fastri-server
* the client: fri
FastRI uses a Rinda Ring to allow servers to be discovered automatically
without needing to indicate the DRb URIs manually. It can work across
machines if you make sure the ring server is bound to the correct interface,
and the ACL permissions are correct.
Running in remote mode:
$ fastri-server (creates the index on the first run, blocks)
Later, (times measured with a cold cache):
$ time ruby bin/fri -f plain Array#fetch
------------------------------------------------------------ Array#fetch
array.fetch(index) -> obj
[...]
real 0m0.287s (real 0m0.127s with a hot cache)
user 0m0.048s
sys 0m0.008s
Compare to:
$ time ri -T -f plain Array#fetch
------------------------------------------------------------ Array#fetch
[...]
real 0m10.136s (real ~ 1.5s with a hot cache)
user 0m1.140s
sys 0m0.464s
This illustrates FastRI's ability to locate classes deep in the class
hierarchy:
$ fri Base
------------------------------------------------------ Multiple choices:
ActionMailer::Base, ActionView::Base, ActionWebService::API::Base,
ActionWebService::Base, ActionWebService::Client::Base,
ActiveRecord::Base, MapReduce::ActiveRecord::Base,
RSS::Maker::Base, Scruffy::Components::Base,
Scruffy::Formatters::Base, Scruffy::Layers::Base,
Scruffy::Renderers::Base, Scruffy::Themes::Base
$ fri Themes::Base
------------------------------------------- Class: Scruffy::Themes::Base
Scruffy::Themes::Base
Author: Brasten Sager
Date: August 14th, 2006
Compare to
$ ri Themes::Base .... several seconds later ...
Nothing known about Themes::Base
A small note about RubyGems + FastRI.
RubyGems adds a noticeable overhead to fri, making it run slower than if you
installed it directly from the tarball with setup.rb.
Compare the execution time when installed with RubyGems:
$ time fri -f plain String > /dev/null
real 0m0.385s
user 0m0.244s
sys 0m0.036s
to the time fri actually takes to run, without the overhead introduced by
RubyGems:
$ time ruby bin/fri -f plain String > /dev/null
real 0m0.088s
user 0m0.040s
sys 0m0.008s
If you care about those extra 300ms (and there are situations where they will
matter, e.g. when using fri for method completion), get FastRI from the
tarballs.
License
FastRI is licensed under the same terms as Ruby. See LICENSE.
Feedback
Bug reports, patches, comments... are appreciated.
You can contact the author via <mfp@acm.org>. Please add "fastri" to the
subject in order to bypass the spam filters.
--
Mauricio Fernandez - http://eigenclass.org - singular Ruby