FastRI 0.3.0: standalone mode (qri, DRb not needed), additio

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
eigenclass.org

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 S.

  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.

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: inopen’
from
c:/ruby/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/bin/fastri-server:32:
in `make_index’
from
c:/ruby/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/bin/fastri-server:130

    from c:/ruby/lib/ruby/1.8/optparse.rb:1247:in `call'
    from c:/ruby/lib/ruby/1.8/optparse.rb:1247:in `order!'
    from c:/ruby/lib/ruby/1.8/optparse.rb:1205:in `catch'
    from c:/ruby/lib/ruby/1.8/optparse.rb:1205:in `order!'
    from c:/ruby/lib/ruby/1.8/optparse.rb:1279:in `permute!'
    from c:/ruby/lib/ruby/1.8/optparse.rb:1300:in `parse!'
    from 

c:/ruby/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/bin/fastri-server:109

    from c:/ruby/bin/fastri-server:16:in `load'
    from c:/ruby/bin/fastri-server:16

Kind regards -botp

On Tue, Jan 30, 2007 at 02:05:00AM +0900, Peña, Botp wrote:

(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: inmake_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

Mauricio F. wrote:

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?

qri that defaults to local mode (it behaves otherwise identically to fri).

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

Mauricio F. wrote:

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: inmake_index’

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

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

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

Regards,

Dan

From Mauricio F. wrote:

> Does the C:\Documents and Settings\peñaijm directory exist?

> (maybe a problem with the eñe?)

the dir exist. i’ll have to check w the eñe later when i’m back home.
Btw, the other windows pc here i’m using works fine though using the -b
option, BUT if fails using -B option.

Indexing RI docs for win32console-1.0.8-i386 version mswin32. Indexing RI docs for windows-pr version 0.6.2. c:/ruby/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/bin/fastri-server:71: [BUG ] Segmentation fault ruby 1.8.5 (2006-08-25) [i386-mswin32] This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. C:\Documents and Settings\peñaijm>

I also notice i’m using an unpatched ruby ver. Maybe i’ll have to update
that too?

I’ll check the other env vars you mentioned too.

From: Daniel B. [mailto:[email protected]]

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

error?

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

that errs. I had to put double “\”, so Dir.entries(“C:\Documents and
Settings”) worked.

thanks and kind regards -botp

From: Devin M. [mailto:[email protected]]

Peña wrote:

c:/ruby/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/bin/fastri-serve

r:71: [BUG] Segmentation fault

> ruby 1.8.5 (2006-08-25) [i386-mswin32]

> This application has requested the Runtime to terminate it

> in an unusual way. Please contact the application’s support team

>for more information.

Random guess: Is it a fresh install? I’ve had problems resulting from

installing the one-click over an older install.

the one-click requires me to install fresh (it deletes the whole \ruby
dir). i have not updated my one-click yet (to ruby185-22). maybe i’ll
try experimenting with the mswin32
(ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/) version instead
(while waiting for the next release of the oneclick).

kind regards -botp

Peña wrote:

c:/ruby/lib/ruby/gems/1.8/gems/fastri-0.3.0.1/bin/fastri-server:71: [BUG
] Segmentation fault
ruby 1.8.5 (2006-08-25) [i386-mswin32]
This application has requested the Runtime to terminate it in an unusual
way. Please contact the application’s support team for more information.
Random guess: Is it a fresh install? I’ve had problems resulting from
installing the one-click over an older install.

Devin

From: Mauricio Julio Fernández Pradier :

Does the C:\Documents and Settings\peñaijm directory exist?

(maybe a problem with the eñe?)

verified, it’s the eñe alright. I logged in using a simple userid, it
works. On another pc, i used a different folder dir, just the root C:,
and it also works.

but i really would hope that there is a possible fix for this since i
and some of us here have eñe on their names/loginid. Is ruby mungling the
eñe-ed text?

kind regards -botp

On Tue, Jan 30, 2007 at 07:05:07AM +0900, bbiker wrote:

Mauricio F. wrote:

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?

There should be no need to; if you install with setup.rb it will just
overwrite 0.2.1.

qri that defaults to local mode (it behaves otherwise identically to fri).

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.

On Thu, Feb 01, 2007 at 04:27:12AM +0900, Hemant K. wrote:

On Mon, 2007-01-29 at 20:54 +0900, Mauricio F. wrote:

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 :slight_smile:
/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:inload’
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.

On Mon, 2007-01-29 at 20:54 +0900, Mauricio F. wrote:

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 . 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?

From: self :slight_smile:

From: Mauricio Julio Fernández Pradier :

# Does the C:\Documents and Settings\peñaijm directory exist?

# (maybe a problem with the eñe?)

verified, it’s the eñe alright. I logged in using a simple

userid, it works. On another pc, i used a different folder

dir, just the root C:, and it also works.

but i really would hope that there is a possible fix for this

since i and some of us here have eñe on their names/loginid.

Is ruby mungling the eñe-ed text?

arggh, I find discrepancy bw ruby and mswindows env vars :frowning:

C:\family\ruby>cat test.rb

environ tests

p “—ENV[‘USERPROFILE’]—”
p ENV[‘USERPROFILE’]
#p Dir.entries ENV[‘USERPROFILE’] # <-----THIS ERRS !!
p Dir.entries(‘C:\Documents and Settings\peñaijm’) #<-- this is fine

C:\family\ruby>ruby test.rb
“—ENV[‘USERPROFILE’]—”
“C:\Documents and Settings\pe\244aijm”
[".", “…”, “#test.rb#”, “#test.txt#”, “.irbrc”, “.irb_history”,
“.java”,
“.jedit”, “.jpi_cache”, “.plugin140_01.trace”, “.plugin141_01.trace”,
“.tm
econsole”, “.vimrc”, “.vimrc~”, “.wgetrc”, “.zsh_history”,
“1151730757-oem
30.inf”, “1151730757-oem30.PNF”, “1151730757-oem31.inf”,
“1151730757-oem31
.PNF”, “1151730757-oem32.inf”, “1151730757-oem32.PNF”,
“1151917885-oem30.i
nf”, “1151917885-oem30.PNF”, “1151917885-oem31.inf”,
"1151917885-oem31.PNF
", “1151917885-oem32.inf”, “1151917885-oem32.PNF”,
“1170304489-oem3.inf”,
“usbsermptxp.sys”, “USB_CMCS_2000.INF”, “USB_MOT_A1000.INF”,
“USB_MOT_BRIT.
INF”, “UserData”, “vimfiles”, “wengo”, “WINDOWS”, “WinVNC.log”, “yaml”,
“y
aml.1”, “yaml.2”, “yaml.3”, “zshrc”, “zshrc_old”, “zshrc~”, “_viminfo”]

Is there other way to get the userid in windows without going thru ENV?
Maybe, some spanish ruby hackers have some ideas here…

kind regards -botp