Cheat Sheet for Creating Your Own RubyGem

Feature thumb snip20170624 41

Below are the commands and steps needed to create, configure and deploy a RubyGem.

Use Bundler to generate the initial gem files:

Update the .gemspec file to remove the TODO items and provide additional gem metadata, and example is below:

If you need to add other dependancies, such as other gems, you can also add them to the Gem::Specification block, such as the example below:

After saving the file, run bundle install to install the full set of dependancies.


Now add the code implementation to the main file. This will be the first file you see in the lib/ directory. Here is a screenshot of what mine looks like:

If you added specs to test your functionality (as you really should), they should all be passing now.


Next, create a repo on GitHub for your project and push your code up to it. Make sure to also update the README with usage instructions.

From there you can run the command:

And this will push the gem to and you and others can use the gem!

Checkout this guide if you want more information: