Friday, March 14, 2008

Publish Ruby gems to RubyForge in 10 minutes


A quick tutorial to how to publish your ruby gems to the rubyforge gem listing in just under 10 minutes.

This is a fat-reduced version of nuby on rails' tutorial. Thanks for the great info!


You want to share your code, right? Sharing your ruby code is *really easy*!


Using hoe. This assumes you already have a rubyforge account and a project approved. See to set up an account and to register a project.


sudo gem install hoe --include-dependencies

Set your environment EDITOR variable, if you haven't already. Edit ~/.profile or ~/.bash_login or equivelant, and put in

# ~/.bash_login
export EDITOR=/usr/bin/mate -w

Set up your computer to be able to talk to rubyforge. This will open a configuration file in your editor. Change the username and email

rubyforge setup
Log in to rubyforge

rubyforge login
Sow your project

For a project registered with rubygorge as object-stash you would do:

sow object-stash

This creates a directory object-stash with the files:


It will list in the command line what you need to fix in the auto generated files.

*Note* If your project name contains a dash - you will have to fix the the class name from "Object-stash" to ObjectStash in lib/object-stash.rb and Rakefile. A shortcoming of hoe, but a minor one.

If you want to auto-publish your documentation to the project main site, e.g., then edit Rakefile and add:

p.remote_rdoc_dir = '' # Release to root

Write your code

Add and edit files in lib



rake check_manifest

to make sure your Manifest file is correct. The lines with a - are listed in the Manifest but don’t exist on disk. The lines with a + are not in the Manifest but are on the disk.

*Note* Make sure the file ends with at least one blank line!

Now edit History.txt

== 1.0.1

* New version
* Features

Update the version number in your ruby class files:

# lib/object-stash.rb
class ObjectStash
VERSION = '1.0.1'

rake release VERSION=1.0.1

Publish your docs!

rake publish_docs

View docs and install your gem remotely

Go to your project's base url to view the docs, e.g.

Install your own gem! As easy as 1, 2,

sudo gem install object-stash

No comments: