ryanwold.net

A civic-minded citizen seeking the singularity

An entry

Creating my first Ruby .gem

Date: 2013-08-11
Status: draft
Tags: ruby .gem

Soon after discovering Ruby, I discovered Rubygems, which are packaged ruby code libraries that be easily installed and managed. For example, Rails is also a Ruby .gem.

After some time, I found myself writing some custom helpers that I like to use between projects, and I wanted to be able to release .gems for other people to use, so I decided to make my own.

Here's where I started:

http://gembundler.com/rubygems.html

bundle gem opengov  => creates an opengov directory and all the files I need to get started writing my gem.

In the 'opengov' directory, I ran 'git init' to start a Git repository, then I checked in the initial files that were generated.

I updated the 'opengov.gemspec' file to give the .gem a Description and a Summary, then ran build gem opengov.gemspec, which built the first version of the Ruby .gem, that was versioned 0.0.1, based on the /version.rb file.

I was able to publish the .gem to Rubygems because 'opengov' was not already taken, surprisingly. The command was 'gem push opengov-0.0.1.gem', which did the trick.

I proceeded to push the code to Github, where it is open-sourced and available for anybody to use.