Gems

In Ruby, gems are open-source Ruby libraries or applications that lend extra utility to other Ruby programs. Each gem is composed of the following:

  • The source code it was built with (including any tests).
  • Any documentation with metadata such as the name, version, and platform.
  • A .gemspec file holding all Gem-related metadata.

Gems can be referenced, installed, and published from an online registry called RubyGems.

To install gems to the local machine:

gem install name-of-gem

To display a list of previously installed gems:

gem list

Some popular Ruby gems include:

  • Ruby on Rails for building robust, full-stack web applications.
  • Active Record for object-relational database management in Rails.
  • Pry for REPL-style inspection of programs at runtime.
  • OmniAuth for third-party authentication in applications.
  • Sinatra for a building relatively minimal, light websites.

Gems can be represented in a Gemfile either in general or with a specific version:

source 'https://rubygems.org'

gem 'pry'
gem 'rails', '3.0.0.beta3'
gem 'omniauth',  '>=1.0'

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn Ruby on Codecademy