Gem

Gem

A gem is a packaged Ruby application or library. It has a name and a version.

RubyGems

RubyGems is the name of the project that developed the gem packaging system and the gem command. You can get RubyGems from the main rubygems.org repository. RubyGems is now part of the standard library from Ruby version 1.9.

Command 'gem'

The gem command is used to build, upload, download, and install Gem packages.

Usage

Installation

Using a gem in your code

Uninstallation

Bundler

Bundler keeps ruby applications running the same code on every machine. It does this by managing the gems that the application depends on. Given a list of gems, it can automatically download and install those gems, as well as any other gems needed by the gems that are listed. Before installing gems, it checks the versions of every gem to make sure that they are compatible, and can all be loaded at the same time. After the gems have been installed, Bundler can help you update some or all of them when new versions become available. Finally, it records the exact versions that have been installed, so that others can install the exact same gems.

Bundler installation

Bundle init

Gemfile

Bundle install

Bundle update

Gemfile.lock

Creating gem

Preparing environment

Installing bundler

Creating gem with bundler

Gem structure

Gemspec

new_gem.gemspec

Gem structure

lib/new_gem/version.rb

Gemfile

new_gem.gemspec

Gem structure

lib/new_gem.rb

Rakefile

Testing

Add rspec to new_gem.gemspec

spec/spec_helper.rb

spec/new_gem_spec.rb

Testing

lib/new_gem.rb

Running tests

Build and push gem to RubyGems.org

Rakefile

Rake tasks

Build gem

/

#