DEV Community

Cover image for How do I make a ruby gem ?
Fion L
Fion L

Posted on • Updated on

How do I make a ruby gem ?

I am starting a new ruby gem creation project, as a challenge to actually be a software developer and not just someone who does apps, and also a chance to contribute to the open source community. Largely this article is looking at the dev ops approach. The purpose of the gem is for a future article.

Firstly, let's get started with a working gem. In a new Ruby file run bundler, hence, gem install bundler. Next run an existing gem, bundle gem its-name.

However, building a gem will be different for everyone. I will be continually updating this thread as the gem progresses, in the meantime, comments are encouraged.

Here's what I have done so far ...

Step 1

Create a new github repository for your gem and download the repo to your local computer:

$ git clone https://github.com/your_github_name/your_gem_name_gem

Step 2

Create an account on https://rubygems.org/sign_up, RubyGems.org
Find the curl command RubyGems has generated,

curl -u your-ruby-gems-name...

When you run the curl command in the bash terminal this command will connect the GitHub repo to RubyGems.

Creation of the Gem

Don't forget the version: as part of http convention, you need a version.

What about Gemfile.lock?

Gemfile.lock is a snapshot of the versions of all gems in the Gemfile at a single point of time. If you studied accounting, then this reference to a balance sheet might help.
It get's automatically generated by bundle install so it's advised not to alter it yourself.

More updates to follow ...

Top comments (1)

Collapse
 
fion21 profile image
Fion L

Dont forget the versioning!