Ruby Gems

Sashini Shihara
3 min readOct 29, 2021

--

Ruby Gems

RubyGems is a Ruby package manager that includes a standard format for distributing Ruby applications and libraries, as well as a tool to manage gem installation and a server to distribute them. It was developed at RubyConf 2004 by Chad Fowler, Jim Weirich, David Alan Black, Paul Brannan, and Richard Kilmer.
RubyGems is controlled by gem, a command-line utility that installs and manages libraries (the gems). RubyGems works with the Ruby run-time loader to assist locate and load gems from standardized library directories. Although a private RubyGems repository is feasible, the public repository is the most usually utilized for gem administration.
Users may utilize the public repository to locate gems, resolve dependencies, and install them. As of Ruby 1.9, RubyGems is included in the standard Ruby package.

A gem’s structure

Every gem has a name, version, and platform associated with it. Only ruby written for a certain platform, based on CPU architecture and operating system type and version, works with gems.

Each gem is made up of the following elements:

  • Code
  • Documentation
  • Specifications for gems (Gemspec)

For a gem, the code is organized in the following way:

Find Gems

You may use the search command to look for distant gems by name. Regular expression characters can be used in your query.

You may add the details option to a gem if you want additional information on it. However, you should only do this with a minimal number of gems because showing gems with information necessitates downloading extra files.

Install Gems

The install command downloads and installs the gem as well as any required dependencies, and then creates documentation for the gems that have been installed.

List Gems

The list command displays the gems that are installed locally.

Uninstall Gems

The gems you’ve installed will be removed using the uninstall command.
RubyGems will prompt you for confirmation if you remove a gem’s dependency.

Fetch Gems

If you want to see the contents of a gem without downloading it, use the fetch command to get the .gem file and then use the unpack command to extract the contents.
You may also unpack a gem you’ve installed, change a few files, and then use the updated gem instead of the one you’ve loaded.

--

--

Sashini Shihara

Software Engineer at Pearson Lanka, Reading for MSc in INformation Technology at Cardiff Metropolitan University, Graduated from University of Colombo