[ANN] FastRI 0.3.0: standalone mode (qri, DRb not needed), additional search methods, extended class

M

Mauricio Fernandez

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 <[email protected]>. Please add "fastri" to the
subject in order to bypass the spam filters.
 
M

Mauricio Fernandez

From: Mauricio Julio Fernández Pradier
Subject: [ANN] FastRI 0.3.0: standalone mode (qri, DRb not needed),
additional search methods, extended class info

Any kind soul pls tell my why my fri does not rebuild on my windows box
(linux box is fine)

Building index.
c:/ruby/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/bin/fastri-server:32:in `initializ
e': No such file or directory - C:\Documents and Settings\peñaijm/.fastri-index
(Errno::ENOENT)
from c:/ruby/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/bin/fastri-server:32:
in `open'
from c:/ruby/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/bin/fastri-server:32:
in `make_index'

Does the C:\Documents and Settings\peñaijm directory exist? (maybe a problem
with the eñe?)

It should work if you set the HOME or USERPROFILE environment variables so
they point to the actual directory (or alternatively HOMEDRIVE and HOMEPATH).
You can also specify the location of the index file to be built/used with
--index-file (both in fastri-server and fri/qri) --- some sort of alias (or
bat wrapper) would make this practical.

FastRI uses the following code to find the home directory:

# Returns the home directory (win32-aware).
def find_home
# stolen from RubyGems
['HOME', 'USERPROFILE'].each do |homekey|
return ENV[homekey] if ENV[homekey]
end
if ENV['HOMEDRIVE'] && ENV['HOMEPATH']
return "#{ENV['HOMEDRIVE']}:#{ENV['HOMEPATH']}"
end
begin
File.expand_path("~")
rescue StandardError => ex
if File::ALT_SEPARATOR
"C:/"
else
"/"
end
end
end
 
D

Daniel Berger

Mauricio said:
From: Mauricio Julio Fernández Pradier
Subject: [ANN] FastRI 0.3.0: standalone mode (qri, DRb not needed),
additional search methods, extended class info

Any kind soul pls tell my why my fri does not rebuild on my windows box
(linux box is fine)

Building index.
c:/ruby/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/bin/fastri-server:32:in `initializ
e': No such file or directory - C:\Documents and Settings\peñaijm/.fastri-index
(Errno::ENOENT)
from c:/ruby/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/bin/fastri-server:32:
in `open'
from c:/ruby/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/bin/fastri-server:32:
in `make_index'

Does the C:\Documents and Settings\peñaijm directory exist? (maybe a problem
with the eñe?)

<snip>

That would be my guess. Does this code snippet work or raise an
error?

Dir.entries(" C:\Documents and Settings")

Regards,

Dan
 
B

bbiker

Mauricio said:
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.

I currently have fastri 0.2.1 installed via the tarball.

Should I uninstall fastri 0.2.1 prior to installing fastri 0.3.0?
I have downloaded fastri 0.3.0 and unzipped...not setup yet.

I noticed that there is no "qri.rb" file in any of the folders. Did I
download the right version?
The readme.en file does not mention qri as far as I can see.

When and often should I rebuild the index with fastri-server -b

When and often should I rebuild the full-text index with fastri-server
-B

Thank you
 
M

Mauricio Fernandez

I currently have fastri 0.2.1 installed via the tarball.

Should I uninstall fastri 0.2.1 prior to installing fastri 0.3.0?

There should be no need to; if you install with setup.rb it will just
overwrite 0.2.1.
I have downloaded fastri 0.3.0 and unzipped...not setup yet.

I noticed that there is no "qri.rb" file in any of the folders. Did I
download the right version?

qri.rb is generated at install time by pre-install.rb (one of setup.rb's
hooks); it's just a copy of bin/fri (I'd use a symlink if it were supported on
all platforms).
The readme.en file does not mention qri as far as I can see.

I haven't updated README.en, but qri should be available once you install.
When and often should I rebuild the index with fastri-server -b

You need to run it once before you use fri(fastri-server)/qri. You can rebuild
the index when you install a gem whose documentation you want to access with
fri/qri. fastri-server -b will reindex all the available documentation, but it
only takes ~15s for over 110 installed gems on a slow computer (I might make
it incremental someday).
When and often should I rebuild the full-text index with fastri-server -B

Same as fastri-server -b, rebuild whenever you want newly installed
documentation to be searchable with fri/qri.
 
H

Hemant Kumar

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.
Feedback
========
Bug reports, patches, comments... are appreciated.
You can contact the author via <[email protected]>. Please add "fastri" to the
subject in order to bypass the spam filters.

Dunno, fastri used to work fine for me with 1.8.4 (installed from Ubuntu
repos) but since I complied Ruby and components manually, it stopped
working and throws wierd errors:

$ fri Array (fri Array#each and other stuff returns nil)
/usr/local/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/lib/fastri/ri_index.rb:354:in `initialize': No such file or directory - /usr/local/lib/ruby/gems/1.8/doc/mocha-0.3.2/ri/Array/cdesc-Array.yaml (Errno::ENOENT)

from /usr/local/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/lib/fastri/ri_index.rb:354:in `open'

from /usr/local/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/lib/fastri/ri_index.rb:354:in `get_class'

from /usr/local/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/lib/fastri/ri_index.rb:352:in `each'

from /usr/local/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/lib/fastri/ri_index.rb:352:in `get_class'

from /usr/local/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/lib/fastri/ri_service.rb:208:in `info'

from /usr/local/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/lib/fastri/ri_service.rb:418:in `capture_stdout'

from /usr/local/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/lib/fastri/ri_service.rb:207:in `info'

from /usr/local/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/bin/qri:325

from /usr/local/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/bin/qri:320:in
`each'

from /usr/local/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/bin/qri:320
from /usr/local/bin/qri:18:in `load'
from /usr/local/bin/qri:18

Am I missing something here?
 
M

Mauricio Fernandez

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.
[...]
Dunno, fastri used to work fine for me with 1.8.4 (installed from Ubuntu
repos) but since I complied Ruby and components manually, it stopped
working and throws wierd errors:

$ fri Array (fri Array#each and other stuff returns nil) ==== (actually qri :)
/usr/local/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/lib/fastri/ri_index.rb:354:in `initialize': No such file or directory - /usr/local/lib/ruby/gems/1.8/doc/mocha-0.3.2/ri/Array/cdesc-Array.yaml (Errno::ENOENT) [...]
from /usr/local/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/bin/qri:320
from /usr/local/bin/qri:18:in `load'
from /usr/local/bin/qri:18

Does this still happen after rebuilding the index with fastri-server -b?
If some gems have been removed, the index will have dangling pointers to
inexistent files.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top