Skip to end of metadata
Go to start of metadata

A RubyGem, commonly called just a gem, is a packaged Ruby library, which installation allows you use the functionality of a common library in your application. This tutorial is meant to explain how to create and deploy a RubyGem.

0. Prerequisites

Make sure the following prerequisites are met:

1. Creating a New Gem App

Creating a new gem can be done by going to File | New Project... and choosing Ruby Gem:

Choose Ruby SDK supposed to be used for the project and set Create bin folder and Create test folder if these folder are required to be generated for the project:

The skeleton of the application is automatically generated:

2. Configuring Git Root

Unregistered Git root notification appears as soon as the application structure is ready:

Press Configure or go to Settings -> Version Control and add application root to version control if required:

3. Adding Working Code

Navigate to the main module (⌘O/Ctrl+N) and add the code expected to be doing something:

Then navigate to Gemspec file (⌘⇧O/Ctrl+Shift+N) and set up the summary and description sections:

4. Building Gem

Go to the Tools | Gem menu and select Build Gem option. After the gem is built a file with the gem extension can be found in the project view:

5. Installing Gem Locally

Before being uploaded to RubyGems repository the gem needs to be tested, so lets install the gem. Go to Run | Edit Configurations... and add a new Gem Command as described:

Apply the changes and run the configuration (⌃R/Shift+F10), wait for the gem being installed:

6. Smoke Testing with IRB

To test the gem run IRB console (Tools | Run IRB Console...) and call the methods of the newly installed gem:

7. Gem Publishing

RubyMine uses RubyGems.org as a default gem repository. If it is the first time you're publishing your gem, make sure you are signed up to RubyGems and your credentials are set. Read more in RubyGems guides.

Gem can now be pushed with Tools | Gem -> Push Gem option:

If you want to use your own gem repository, please change your .gemspec file according to RubyGems guides:

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.