rdoc info Was: Re: [stlruby] rush, the ruby shell

0 views
Skip to first unread message

Ed Howland

unread,
Nov 18, 2009, 5:10:44 PM11/18/09
to stl...@googlegroups.com
Hi,

I wanted to play with rush too, but something has been bothering me
for a while. Gems install ri and rdoc files. With all the systems I'm
running, finding these has been a chore. Fortunately the 'gem
environment' command comes to the rescue.

RubyGems Environment:
- RUBYGEMS VERSION: 1.3.5
- RUBY VERSION: 1.9.1 (2009-07-16 patchlevel 243) [i386-darwin10.0.0]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9.1
...
- GEM PATHS:
- /usr/local/lib/ruby/gems/1.9.1
- /Users/edh/.gem/ruby/1.9.1
- GEM CONFIGURATION:
...

I've written a shell script and function to make this more accessible:

(Assumes you have a ~/bin and it's in your path)

~/bin/rdoc.sh

#!/usr/bin/env bash
# rdoc.sh - find rdoc based on gem environment
rdoc=`gem environment | grep -C2 "GEM P"|tail -2|head -1|awk -v A=$1
'{print $2 "/doc/" A "*" "/rdoc/index.html" }'`
echo $rdoc

rdoc.sh rush
/usr/local/lib/ruby/gems/1.9.1/doc/rush-0.6.4/rdoc/index.html

... on a 1.9.1 Ruby install on my Mac


[Note: There can be multiple GEM_PATHS as in my case. I'm assuming you
only want the standard path, not the local gems path. If you want the
other one, make a rdoc-local.sh script and change the above to filter
the second line.]

Then you can create a shell function
# firefox the rdoc of a given gem
function rdoc
{
rd=`~/bin/rdoc.sh $1`
ff $rd
}

On my Mac ff is aliases to
alias ff='open -a firefox'

You can substitute safari for firefox, or change the shell function to
open firefox directly on *nix systems:

function rdoc
{
rd=`~/bin/rdoc.sh $1`
firefox $rd
}

Regards,
Ed



On Wed, Nov 18, 2009 at 2:24 PM, Robert Citek <robert...@gmail.com> wrote:
> Excellent, as I'm running 1.8.6 on Ubuntu 8.04:
>
> $ ruby -v
> ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]
>
> Will give rush a whirl.
>
> Regards,
> - Robert
>
> On Wed, Nov 18, 2009 at 1:50 PM, Amos King <amos....@gmail.com> wrote:
>> 1.8
>
> --
>
> You received this message because you are subscribed to the Google Groups "Saint Louis Ruby Users Group" group.
> To post to this group, send email to stl...@googlegroups.com.
> To unsubscribe from this group, send email to stlruby+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/stlruby?hl=en.
>
>
>



--
Ed Howland
http://greenprogrammer.blogspot.com
http://twitter.com/ed_howland
Reply all
Reply to author
Forward
0 new messages