This is my personal note on what needs to be done to create a new ruby gem and to update it during development process.
Updating the tools
First of all, let’s update our tools. Skip this step if you’re in a hurry or have updated recently
$ curl -L get.rvm.io | bash -s stable --ruby $
This may take a while.
However, this will nowadays install ruby 2.0. If you still stick to ruby 1.9.3, remove the
--ruby switch and install
the latest ruby version manually:
$ curl -L get.rvm.io | bash -s stable $ rvm install 1.9.3 $
Create the gem
Choose a location for your source. I’ll put them in ~/Projects/Gems, so
$ cd ~/Projects/Gems $ bundle gem ultimate-gemname $ cd ultimate-gemname $ git ci $
This will commit the initially created structure as master commit. I use to add the commands I executed to the commit message, so my message looks like
Create new gem Commands: bundle gem ultimate-gemname
Now we have our first commit saved locally.
To push this to github we use the
$ hub create $
Assuming you have set up the necessary values for your github repo in
~/.gitconfig, you should see the new repository
when browsing to https://github.com/.
Now it’s a good time to check the
LICENSE.txt and edit the
README.md file and push the changes afterwards with
$ git push -u origin master $
Now write a test, let it fail, add the code, commit, refactor, commit, …
Then push it.
Using the gem
First install it locally
$ rake install $
Then use it elsewhere. Be careful with using the same ruby version if you’re using
After a change, you have to uninstall it first.
$ gem uninstall ultimate-gemname $ rake install $
Not tried yet, but a simple
$ rake release $
should do the trick.