Last Updated: February 25, 2016
· mose

Make a gem

Making and publishing your own gems is so incredibly simple. Here is my setp by step process when I want to publish one:

Make a Rubygems account

curl -u username > ~/.gem/credentials
Enter host password for user 'username':

chmod 0600 ~/.gem/credentials

Prepare the code

These steps are my typical path, nothing is really mandatory there.

  • create a repo at github (or wherever you want)
  • create a base gem skeleton bundle gem mycoolgem
  • update the, add some minimal information. The clearest you explain what it does the best chances people will adopt it. Add cypirght information
  • create a because when you publish something you need a clear log of your version changes
  • enable the tracking on codeclimate, travis, coveralls, gemnasium
  • add badges from in the because it helps to qualify the state of the code quickly
  • when the gem code don't need to have access to the version number, I found convenient to just remove the version file and add version in the .gemspec from the changelog file with spec.version ='../', __FILE__))[/([0-9]+\.[0-9]+\.[0-9]+)/] (so then when I version bump there is only one file to edit)
  • write the code (or copy it from the private app you extract it from)
  • add a spec/ or test/ dir and write some tests and try to reach a decent coverage

Release it

  • add the date in the changelog for the current version
  • rake release
  • bump the version to the next increment in the changelog (and version file if any)

Overall with the initial bundle command and the final rake task for release, it's pretty straightforward.

Also check