Gem Mining
Mining my first gem When we decided to open-source our Instagram RSS generator, I took on the task of creating a gem to distribute it. I had never created a gem before and saw a lot of conflicting information, so I thought it would be useful to catalog my journey.
Naming I knew I wanted the name of the gem to be Instagram::RssGenerator, but determining the correct directory structure while following the rubygems naming convention proved tricky.
Bundler to the Rescue Bundler has been a favorite tool among the ruby community for many years, and one of its features is scaffolding a gem using the command bundle gem my_gem. In order to set up my namespace correctly, I replaced my_gem from the example with instagram-rss_generator and this worked like magic! The mix of the - and _ looks strange at first, but it’s necessary in order to namespace and capitalize correctly.
Gemspec One of the files created by bundler is the Gemspec file.
The only things you need to modify in this file are the required fields and the gem’s dependencies.
Version The last hiccup I ran into was putting the version into the correct module. Since Instagram is the module and RssGenerator is the class, I only needed to put the version number on the module and not the class itself.
Polishing Thoughts After getting over the few bumps in the road, posting to rubygems was almost too easy, and now I definitely understand why you can’t trust code you just find on rubygems or npm.
Publishing this gem was a great way to contribute to the ruby community and I look forward to continuing to contribute. Check out the source (along with installation and usage instructions) on github and the gem on rubygems.