Easy gem creation using Bundler

Bundler makes it very easy to create and distribute gems. You still have to write the gem’s code yourself (Bundler is clever, but not that clever!) but everything else is done for you.

Here’s a summary of the steps you’ll need to follow to create and release your gem:

bundle gem new_magik_gem

This creates the project directory and the skeletal .gemspec file. Open your new .gemspec file and fill in the blanks with the appropriate details. Here is a good post on doing just that.

Also make sure that your ./lib/new_magik_gem/version.rb file exists – this is where the gem version is read from. You could also just hard code the gemspec file with the version.

Write tests. Write code. You are writing tests aren’t you? Good lad. Commit everything to Github. When you’re done, install the gem locally.

rake install

All good? Then release the gem and you’ll see your name in light on the RubyGems front page.

rake release

Make sure you have a RubyGems account setup, otherwise the release step will probably fail (or hang).

For more information about this, see this post.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s