Skip to content

Instantly share code, notes, and snippets.

@fernandoamz
Last active September 24, 2018 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fernandoamz/dbfff999a048c209cfc32b52209d53b3 to your computer and use it in GitHub Desktop.
Save fernandoamz/dbfff999a048c209cfc32b52209d53b3 to your computer and use it in GitHub Desktop.

How to make a RubyGem file

¿WHAT ARE RUBYGEMS FILES?

A RubyGem is a package written in Ruby, this package provides standard and auto-contained, we can call this files with command gem filename this files help to do more fast our develop.

PRE-REQUISITES:

  1. Ruby latest version(link).
  2. Rbenv(link) or RVM(link).
  3. Project.

STEPS:

STEP 1: ORGANIZING OUR FILES.

you need to organize your folder into project in this way, create the folder /lib and add your files .rb into, then create a file .gemspec in root.

1.- Folder structure.

STEP 2: CONFIGURING SPECIFICATIONS OF GEM.

Open the new file .gemspec and add the next lines:

2.- tictactoe.gemspec

We need write the .gemspec file, how the last image(2) add your own information.

STEP 3: CREATING GEM

go to the root file on mac/linux/windows terminal and write gem build tictactoe.gemspec, the command must return Successfully message, and ¡congrat the gem is created!.

STEP 4: INSTALLING OUR GEM

go to the root file on mac/linux/windows terminal and write irb, the command must return Ruby console.

And then run the next commands: require 'rubygem'

And we can access the methods from our gem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment