Module Gem
In: lib/rubygems/gem_openssl.rb
lib/rubygems/defaults.rb
lib/rubygems/psych_tree.rb
lib/rubygems/deprecate.rb
lib/rubygems/test_case.rb
lib/rubygems.rb

RubyGems is the Ruby standard for publishing and managing third party libraries.

For user documentation, see:

For gem developer documentation see:

Further RubyGems documentation can be found at:

RubyGems Plugins

As of RubyGems 1.3.2, RubyGems will load plugins installed in gems or $LOAD_PATH. Plugins must be named ‘rubygems_plugin’ (.rb, .so, etc) and placed at the root of your gem‘s require_path. Plugins are discovered via Gem::find_files then loaded. Take care when implementing a plugin as your plugin file may be loaded multiple times if multiple versions of your gem are installed.

For an example plugin, see the graph gem which adds a `gem graph` command.

RubyGems Defaults, Packaging

RubyGems defaults are stored in rubygems/defaults.rb. If you‘re packaging RubyGems or implementing Ruby you can change RubyGems’ defaults.

For RubyGems packagers, provide lib/rubygems/operating_system.rb and override any defaults from lib/rubygems/defaults.rb.

For Ruby implementers, provide lib/rubygems/#{RUBY_ENGINE}.rb and override any defaults from lib/rubygems/defaults.rb.

If you need RubyGems to perform extra work on install or uninstall, your defaults override file can set pre and post install and uninstall hooks. See Gem::pre_install, Gem::pre_uninstall, Gem::post_install, Gem::post_uninstall.

Bugs

You can submit bugs to the RubyGems bug tracker on RubyForge

Credits

RubyGems is currently maintained by Eric Hodel.

RubyGems was originally developed at RubyConf 2003 by:

  • Rich Kilmer — rich(at)infoether.com
  • Chad Fowler — chad(at)chadfowler.com
  • David Black — dblack(at)wobblini.net
  • Paul Brannan — paul(at)atdesk.com
  • Jim Weirch — jim(at)weirichhouse.org

Contributors:

  • Gavin Sinclair — gsinclair(at)soyabean.com.au
  • George Marrows — george.marrows(at)ntlworld.com
  • Dick Davies — rasputnik(at)hellooperator.net
  • Mauricio Fernandez — batsman.geo(at)yahoo.com
  • Simon Strandgaard — neoneye(at)adslhome.dk
  • Dave Glasser — glasser(at)mit.edu
  • Paul Duncan — pabs(at)pablotron.org
  • Ville Aine — vaine(at)cs.helsinki.fi
  • Eric Hodel — drbrain(at)segment7.net
  • Daniel Berger — djberg96(at)gmail.com
  • Phil Hagelberg — technomancy(at)gmail.com
  • Ryan Davis — ryand-ruby(at)zenspider.com
  • Evan Phoenix — evan@phx.io

(If your name is missing, PLEASE let us know!)

Thanks!

-The RubyGems Team

Methods

Classes and Modules

Module Gem::Commands
Module Gem::DefaultUserInteraction
Module Gem::Deprecate
Module Gem::Ext
Module Gem::GemcutterUtilities
Module Gem::InstallUpdateOptions
Module Gem::LocalRemoteOptions
Module Gem::Package
Module Gem::RequirePathsBuilder
Module Gem::Text
Module Gem::UserInteraction
Module Gem::VersionOption
Class Gem::Builder
Class Gem::Command
Class Gem::CommandLineError
Class Gem::CommandManager
Class Gem::ConfigFile
Class Gem::ConsoleUI
Class Gem::Dependency
Class Gem::DependencyError
Class Gem::DependencyInstaller
Class Gem::DependencyList
Class Gem::DependencyRemovalException
Class Gem::DocManager
Class Gem::DocumentError
Class Gem::EndOfYAMLException
Class Gem::ErrorReason
Class Gem::Exception
Class Gem::FakeFetcher
Class Gem::FilePermissionError
Class Gem::Format
Class Gem::FormatException
Class Gem::GemNotFoundException
Class Gem::GemNotInHomeException
Class Gem::GemPathSearcher
Class Gem::GemRunner
Class Gem::Indexer
Class Gem::InstallError
Class Gem::Installer
Class Gem::InstallerTestCase
Class Gem::InvalidSpecificationException
Class Gem::LoadError
Class Gem::MockGemUi
Class Gem::NoAliasYAMLTree
Class Gem::OldFormat
Class Gem::OperationNotSupportedError
Class Gem::PackageTask
Class Gem::PathSupport
Class Gem::Platform
Class Gem::PlatformMismatch
Class Gem::RemoteError
Class Gem::RemoteFetcher
Class Gem::RemoteInstallationCancelled
Class Gem::RemoteInstallationSkipped
Class Gem::RemoteSourceException
Class Gem::Requirement
Class Gem::Server
Class Gem::SilentUI
Class Gem::SourceIndex
Class Gem::SpecFetcher
Class Gem::Specification
Class Gem::StreamUI
Class Gem::SystemExitException
Class Gem::TestCase
Class Gem::Uninstaller
Class Gem::Validator
Class Gem::VerificationError
Class Gem::Version

Constants

QUICKLOADER_SUCKAGE = RUBY_VERSION =~ /^1\.9\.1/
GEM_PRELUDE_SUCKAGE = RUBY_VERSION =~ /^1\.9\.2/ && RUBY_ENGINE == "ruby"   Only MRI 1.9.2 has the custom prelude.
VERSION = '1.8.25'
WIN_PATTERNS = [ /bccwin/i, /cygwin/i, /djgpp/i, /mingw/i, /mswin/i, /wince/i, ]   An Array of Regexps that match windows ruby platforms.
MARSHAL_SPEC_DIR = "quick/Marshal.#{Gem.marshal_version}/"   Location of Marshal quick gemspecs on remote repositories

Attributes

loaded_specs  [R]  Hash of loaded Gem::Specification keyed by name
post_build_hooks  [R]  The list of hooks to be run before Gem::Install#install finishes installation
post_install_hooks  [R]  The list of hooks to be run before Gem::Install#install does any work
post_reset_hooks  [R]  The list of hooks to be run after Gem::Specification.reset is run.
post_uninstall_hooks  [R]  The list of hooks to be run before Gem::Uninstall#uninstall does any work
pre_install_hooks  [R]  The list of hooks to be run after Gem::Install#install is finished
pre_reset_hooks  [R]  The list of hooks to be run before Gem::Specification.reset is run.
pre_uninstall_hooks  [R]  The list of hooks to be run after Gem::Uninstall#uninstall is finished
ssl_available  [W]  Is SSL available?

Public Class methods

Activates an installed gem matching dep. The gem must satisfy requirements.

Returns true if the gem is activated, false if it is already loaded, or an exception otherwise.

Gem#activate adds the library paths in dep to $LOAD_PATH. Before a Gem is activated its required Gems are activated. If the version information is omitted, the highest version Gem of the supplied name is loaded. If a Gem is not found that meets the version requirements or a required Gem is not found, a Gem::LoadError is raised.

More information on version requirements can be found in the Gem::Requirement and Gem::Version documentation.

An Array of all possible load paths for all versions of all gems in the Gem installation.

See if a given gem is available.

Find the full path to the executable for gem name. If the exec_name is not given, the gem‘s default_executable is chosen, otherwise the specified executable‘s path is returned. requirements allows you to specify specific gem versions.

The mode needed to read a file as straight binary.

The path where gem executables are to be installed.

Get the appropriate cache path.

Pass a string to use a different base path, or nil/false (default) for Gem.dir.

Given a gem path, find the gem in cache.

Pass a string as the second argument to use a different base path, or nil/false (default) for Gem.dir.

Reset the dir and path values. The next time dir or path is requested, the values will be calculated from scratch. This is mainly used by the unit tests to provide test isolation.

The path to standard location of the user‘s .gemrc file.

The standard configuration object for gems.

Use the given configuration object (which implements the ConfigFile protocol) as the standard configuration object.

The path the the data directory specified by the gem name. If the package is not available as a gem, return nil.

The default directory for binaries

Default home directory path to be used if an alternate value is not specified in the environment

Deduce Ruby‘s —program-prefix and —program-suffix from its install name

Default gem load path

Paths where RubyGems’ .rb files and bin files are installed

An Array of the default sources that come with RubyGems

The default system-wide source info cache directory

The default user-specific source info cache directory

A Zlib::Deflate.deflate wrapper

The path where gems are to be installed.

Quietly ensure the named Gem directory contains all the proper subdirectories. If we can‘t create a directory due to a permission problem, then we will silently continue.

Ensure that SSL is available. Throw an exception if it is not.

Returns a list of paths matching glob that can be used by a gem to pick up features from other gems. For example:

  Gem.find_files('rdoc/discover').each do |path| load path end

if check_load_path is true (the default), then find_files also searches $LOAD_PATH for files as well as gems.

Note that find_files will return all files even if they are from different versions of the same gem.

Zlib::GzipReader wrapper that unzips data.

Zlib::GzipWriter wrapper that zips data.

Get the default RubyGems API host. This is normally rubygems.org.

Set the default RubyGems API host.

A Zlib::Inflate#inflate wrapper

Return a list of all possible load paths for the latest version for all gems in the Gem installation.

Find all ‘rubygems_plugin’ files in $LOAD_PATH and load them

The index to insert activated gem paths into the $LOAD_PATH.

Defaults to the site lib directory unless gem_prelude.rb has loaded paths, then it inserts the activated gem‘s paths before the gem_prelude.rb paths so you can override the gem_prelude.rb default $LOAD_PATH paths.

Load plugins as ruby files

Find all ‘rubygems_plugin’ files in installed gems and load them

Loads YAML, preferring Psych

The file name and line number of the caller of the caller of this method.

The version of the Marshal format for your Ruby.

Array of platforms this RubyGems supports.

Set array of platforms this RubyGems supports (primarily for testing).

Adds a post-build hook that will be passed an Gem::Installer instance when Gem::Installer#install is called. The hook is called after the gem has been extracted and extensions have been built but before the executables or gemspec has been written. If the hook returns false then the gem‘s files will be removed and the install will be aborted.

Adds a post-install hook that will be passed an Gem::Installer instance when Gem::Installer#install is called

Adds a hook that will get run after Gem::Specification.reset is run.

Adds a post-uninstall hook that will be passed a Gem::Uninstaller instance and the spec that was uninstalled when Gem::Uninstaller#uninstall is called

Adds a pre-install hook that will be passed an Gem::Installer instance when Gem::Installer#install is called. If the hook returns false then the install will be aborted.

Adds a hook that will get run before Gem::Specification.reset is run.

Adds a pre-uninstall hook that will be passed an Gem::Uninstaller instance and the spec that will be uninstalled when Gem::Uninstaller#uninstall is called

The directory prefix this RubyGems was installed at. If your prefix is in a standard location (ie, rubygems is installed where you‘d expect it to be), then prefix returns nil.

Promotes the load paths of the gem_name over the load paths of over_name. Useful for allowing one gem to override features in another using find_files.

Safely read a file in binary mode on all platforms.

Refresh source_index from disk and clear searcher.

Full path to libfile in gemname. Searches for the latest gem unless requirements is given.

The path to the running Ruby interpreter.

Allows setting path to ruby. This method is available when requiring ‘rubygems/test_case‘

A wrapper around RUBY_ENGINE const that may not be defined

A Gem::Version for the currently running ruby.

The GemPathSearcher object used to search for matching installed gems.

Allows setting the gem path searcher. This method is available when requiring ‘rubygems/test_case‘

Returns the Gem::SourceIndex of specifications that are in the Gem.path

Allows setting the default SourceIndex. This method is available when requiring ‘rubygems/test_case‘

Returns an Array of sources to fetch remote gems from. If the sources list is empty, attempts to load the "sources" gem, then uses default_sources if it is not installed.

Need to be able to set the sources without calling Gem.sources.replace since that would cause an infinite loop.

Is SSL (used by the signing commands) available on this platform?

Glob pattern for require-able path suffixes.

Suffixes for require-able paths.

Prints the amount of time the supplied block takes to run using the debug UI output.

Try to activate a gem containing path. Returns true if activation succeeded or wasn‘t needed because it was already activated. Returns false if it can‘t find the path in a gem.

Lazily loads DefaultUserInteraction and returns the default UI.

Use the home and paths values for Gem.dir and Gem.path. Used mainly by the unit tests to provide environment isolation.

Path for gems in the user‘s home directory

The home directory for the user.

Allows toggling Windows behavior. This method is available when requiring ‘rubygems/test_case‘

Is this a windows platform?

[Validate]