Build a ruby gem and host it on in 4 easy steps

January 22, 2011

Building a ruby gem these days is really, really easy. Bundler provides a great framework generator to get you started. Bundler also lets you install a gem straight from a github repository, so now is the time to say goodbye to your git submodules and start packaging your code into gems.

  1. Sign up for a account
  2. $ bundle gem shiny_new_gem (This creates the framework for your gem)
  3. Edit ‘shiny_new_gem.gemspec’, and add your code in your gem’s lib folder. (When the gem is required, whatever is in ‘lib/shiny_new_gem.rb’ will be executed.)
  4. $ rake build               # Build the gem $ gem push pkg/shiny_new_gem-0.0.1.gem        # Push the gem up to  (you will be asked for your email and password)
Done! Now any rails developer can add gem “shiny_new_gem” to their Gemfile, and use your creation. Pretty soon you’ll be famous! You’ll be hired by important people! You’ll buy a boat!

Go build your gems!