Paul Philippov

home is where ~/ is

All gem documentation within a click

Tonight I came across a useful bit of code made to ease your life as a ruby developer. It’s a shell script to browse documentation for installed gems through rubygems built-in web server. The script will check for running instance of the server, fire one if no running server found, and then open the server with the default web browser. Here’s the code with slight modifications from me:


if [ $(ps aux | grep -c "gem\s*server") -ge 1 ]
  echo "Gem Server already running..."
  ps aux | grep -e "gem\s*server"
  /usr/bin/gem server --daemon
xdg-open http://localhost:8808/

Grab the code and save it as /usr/local/bin/gemdocs. Don’t forget to run

$ chmod 755 /usr/local/bin/gemdocs

to make the script executable. To make it look pretty on Desktop or/and in Menu I’ve created an icon. Get it from here and put into /usr/share/pixmaps/ directory.

Create file /usr/share/applications/gemdocs.desktop with the following contents:

[Desktop Entry]
Comment=Browse gem documentation server

make a soft link or copy the file to your desktop:

$ cp /usr/share/applications/gemdocs.desktop ~/Desktop/

Now you should see the gemdocs launcher on your desktop. Also GemDocs menu item should emerge in Applications -> Programming menu (valid for GNOME desktop environment).

Please note, you may need to become a superuser in order to get access to those directories.

PS: Thanks to Antono Vasiljev for the idea.

Published on November 25, 2008 (almost 7 years ago)

Article tags: documentation, ruby