Home » Ruby programming

Ruby Gems | Ruby Tools

Ruby Gems: Here, we are going to learn about the Ruby Gems, structure of Ruby Gems, using Ruby Gems, installing & uninstalling Ruby Gems, etc.
Submitted by Hrithik Chandra Prasad, on August 21, 2019

Ruby Gems

Every language has its package manager which helps it by providing libraries and a standard format to distribute Ruby program. It is a type of tool which is developed to easily facilitate the installation of Gems. The command-line tool is the interface used by Ruby gems which provide service in installing and managing libraries.

Structure of Gems

Every gem is identical by a version, platform and obviously, a name. The architecture of CPU, Type of Operating System and version are few of the factors which decide the working criteria of Gem.

Each gem comprises of:

  • Documentation
  • Code
  • Gemspec i.e. Gem specification

The organisation of code follows the structure which is mentioned below:

Ruby Gems | Ruby Tools

Now let us understand each term in a single line.

  • The bin directory contains the binary file.
  • The code for the gem is being stored by lib directory.
  • The testing is conducted by the test directory.
  • Generation of code and automation of test id done by Rake which used Rakefile.
  • README simply comprises documentation for most of the gems.
  • Information like the purpose of the gem, the time gem was created, author gem belongs to, is contained by Gem specification also known as gemspec.

Using Gems

Gem contains files to install along with package information. The practice of building gems directly is known as Rake. The gems are generally built from ".gemspec" files. Let us understand the following gem commands for various purposes listed below:

For installation, type the following in the terminal,

 gem install mygem

For uninstallation, use the following command,

 gem uninstall mygem

For listing installed gems, type the following,

 gem list

For listing available gem, write the following,

 gem list -r

In order to create RDoc documentation for all gems, type the following,

 gem rdoc -all

For adding a trusted certificate, type the following command,

 gem cert -a

If you want to download but you do not want to install the downloaded gem at that instant, for meeting that purpose type the following,

 gem fetch mygem

If you want to search the gems which are available for use, type the following command,

 gem search (STRING)  --remote

We have got a gem command which is available to provide help in building and maintaining ".gemspec" or ".gem" files. This process is known by the name of package building. If you want to build a .gem file from .gemspec file, use the following command on the gem terminal,

 gem build (gem_name).gemspec 



Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.