¿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:
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
.