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:

#!/bin/sh

if [ $(ps aux | grep -c "gem\s*server") -ge 1 ]
then
  echo "Gem Server already running..."
  ps aux | grep -e "gem\s*server"
else
  /usr/bin/gem server --daemon
fi
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]
Name=GemDocs
Comment=Browse gem documentation server
Exec=gemdocs
Icon=gemdocs
StartupNotify=true
Terminal=false
Type=Application
Categories=Documentation;Development;

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 26, 2008 (over 15 years ago)

Article tags: documentation, ruby

Comments (0)