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.
.gemspecfile 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
A list of previously installed gems is displayed with the following command:
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'