2007-11-10 02:48:56 -05:00
|
|
|
# -*- ruby -*-
|
2013-02-07 00:56:53 -05:00
|
|
|
#--
|
2007-11-10 02:48:56 -05:00
|
|
|
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
|
|
|
# All rights reserved.
|
|
|
|
# See LICENSE.txt for permissions.
|
2013-02-07 00:56:53 -05:00
|
|
|
#++
|
2013-02-05 15:52:28 -05:00
|
|
|
|
|
|
|
require 'rbconfig'
|
2014-09-13 23:30:02 -04:00
|
|
|
require 'thread'
|
2013-02-05 15:52:28 -05:00
|
|
|
|
|
|
|
module Gem
|
2015-07-01 17:50:14 -04:00
|
|
|
VERSION = '2.5.0'
|
2013-02-05 15:52:28 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
# Must be first since it unloads the prelude from 1.9.2
|
|
|
|
require 'rubygems/compatibility'
|
|
|
|
|
|
|
|
require 'rubygems/defaults'
|
|
|
|
require 'rubygems/deprecate'
|
|
|
|
require 'rubygems/errors'
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
##
|
2009-06-09 17:38:59 -04:00
|
|
|
# RubyGems is the Ruby standard for publishing and managing third party
|
|
|
|
# libraries.
|
|
|
|
#
|
|
|
|
# For user documentation, see:
|
|
|
|
#
|
|
|
|
# * <tt>gem help</tt> and <tt>gem help [command]</tt>
|
2015-07-01 17:50:14 -04:00
|
|
|
# * {RubyGems User Guide}[http://guides.rubygems.org/]
|
|
|
|
# * {Frequently Asked Questions}[http://guides.rubygems.org/faqs]
|
2009-06-09 17:38:59 -04:00
|
|
|
#
|
|
|
|
# For gem developer documentation see:
|
|
|
|
#
|
2015-07-01 17:50:14 -04:00
|
|
|
# * {Creating Gems}[http://guides.rubygems.org/make-your-own-gem]
|
2009-06-09 17:38:59 -04:00
|
|
|
# * Gem::Specification
|
2010-02-21 21:52:35 -05:00
|
|
|
# * Gem::Version for version dependency notes
|
2009-06-09 17:38:59 -04:00
|
|
|
#
|
|
|
|
# Further RubyGems documentation can be found at:
|
|
|
|
#
|
2013-08-26 16:24:51 -04:00
|
|
|
# * {RubyGems Guides}[http://guides.rubygems.org]
|
2009-06-09 17:38:59 -04:00
|
|
|
# * {RubyGems API}[http://rubygems.rubyforge.org/rdoc] (also available from
|
|
|
|
# <tt>gem server</tt>)
|
|
|
|
#
|
|
|
|
# == RubyGems Plugins
|
|
|
|
#
|
|
|
|
# As of RubyGems 1.3.2, RubyGems will load plugins installed in gems or
|
2010-02-21 21:52:35 -05:00
|
|
|
# $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
|
2009-06-09 17:38:59 -04:00
|
|
|
# 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.
|
|
|
|
#
|
2014-09-13 23:30:02 -04:00
|
|
|
# For RubyGems packagers, provide lib/rubygems/defaults/operating_system.rb
|
|
|
|
# and override any defaults from lib/rubygems/defaults.rb.
|
2009-06-09 17:38:59 -04:00
|
|
|
#
|
2012-11-29 01:52:18 -05:00
|
|
|
# For Ruby implementers, provide lib/rubygems/defaults/#{RUBY_ENGINE}.rb and
|
|
|
|
# override any defaults from lib/rubygems/defaults.rb.
|
2009-06-09 17:38:59 -04:00
|
|
|
#
|
|
|
|
# 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
|
2012-11-29 01:52:18 -05:00
|
|
|
# {RubyGems bug tracker}[https://github.com/rubygems/rubygems/issues]
|
|
|
|
# on GitHub
|
2009-06-09 17:38:59 -04:00
|
|
|
#
|
|
|
|
# == Credits
|
|
|
|
#
|
|
|
|
# RubyGems is currently maintained by Eric Hodel.
|
|
|
|
#
|
|
|
|
# RubyGems was originally developed at RubyConf 2003 by:
|
|
|
|
#
|
2010-02-21 21:52:35 -05:00
|
|
|
# * Rich Kilmer -- rich(at)infoether.com
|
|
|
|
# * Chad Fowler -- chad(at)chadfowler.com
|
|
|
|
# * David Black -- dblack(at)wobblini.net
|
2009-06-09 17:38:59 -04:00
|
|
|
# * Paul Brannan -- paul(at)atdesk.com
|
2014-09-13 23:30:02 -04:00
|
|
|
# * Jim Weirich -- jim(at)weirichhouse.org
|
2009-06-09 17:38:59 -04:00
|
|
|
#
|
|
|
|
# Contributors:
|
|
|
|
#
|
2010-02-21 21:52:35 -05:00
|
|
|
# * Gavin Sinclair -- gsinclair(at)soyabean.com.au
|
|
|
|
# * George Marrows -- george.marrows(at)ntlworld.com
|
|
|
|
# * Dick Davies -- rasputnik(at)hellooperator.net
|
2009-06-09 17:38:59 -04:00
|
|
|
# * Mauricio Fernandez -- batsman.geo(at)yahoo.com
|
2010-02-21 21:52:35 -05:00
|
|
|
# * 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
|
2012-11-29 01:52:18 -05:00
|
|
|
# * Evan Phoenix -- evan(at)fallingsnow.net
|
|
|
|
# * Steve Klabnik -- steve(at)steveklabnik.com
|
2009-06-09 17:38:59 -04:00
|
|
|
#
|
|
|
|
# (If your name is missing, PLEASE let us know!)
|
|
|
|
#
|
2013-02-05 15:52:28 -05:00
|
|
|
# See {LICENSE.txt}[rdoc-ref:lib/rubygems/LICENSE.txt] for permissions.
|
|
|
|
#
|
2009-06-09 17:38:59 -04:00
|
|
|
# Thanks!
|
|
|
|
#
|
|
|
|
# -The RubyGems Team
|
2013-02-07 00:56:53 -05:00
|
|
|
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
module Gem
|
2011-03-01 04:41:32 -05:00
|
|
|
RUBYGEMS_DIR = File.dirname File.expand_path(__FILE__)
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
##
|
2013-09-14 04:59:02 -04:00
|
|
|
# An Array of Regexps that match windows Ruby platforms.
|
2008-03-31 18:40:06 -04:00
|
|
|
|
|
|
|
WIN_PATTERNS = [
|
|
|
|
/bccwin/i,
|
|
|
|
/cygwin/i,
|
|
|
|
/djgpp/i,
|
|
|
|
/mingw/i,
|
|
|
|
/mswin/i,
|
|
|
|
/wince/i,
|
|
|
|
]
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2012-12-22 19:35:09 -05:00
|
|
|
GEM_DEP_FILES = %w[
|
|
|
|
gem.deps.rb
|
|
|
|
Gemfile
|
|
|
|
Isolate
|
|
|
|
]
|
|
|
|
|
|
|
|
##
|
|
|
|
# Subdirectories in a gem repository
|
|
|
|
|
|
|
|
REPOSITORY_SUBDIRECTORIES = %w[
|
|
|
|
build_info
|
|
|
|
cache
|
|
|
|
doc
|
2013-10-15 20:14:16 -04:00
|
|
|
extensions
|
2012-12-22 19:35:09 -05:00
|
|
|
gems
|
|
|
|
specifications
|
|
|
|
]
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2013-09-14 04:59:02 -04:00
|
|
|
##
|
|
|
|
# Subdirectories in a gem repository for default gems
|
|
|
|
|
|
|
|
REPOSITORY_DEFAULT_GEM_SUBDIRECTORIES = %w[
|
|
|
|
gems
|
|
|
|
specifications/default
|
|
|
|
]
|
|
|
|
|
2007-11-10 02:48:56 -05:00
|
|
|
@@win_platform = nil
|
|
|
|
|
|
|
|
@configuration = nil
|
2015-07-01 17:50:14 -04:00
|
|
|
@gemdeps = nil
|
2007-11-10 02:48:56 -05:00
|
|
|
@loaded_specs = {}
|
2014-09-13 23:30:02 -04:00
|
|
|
LOADED_SPECS_MUTEX = Mutex.new
|
2012-11-29 01:52:18 -05:00
|
|
|
@path_to_default_spec_map = {}
|
2008-04-11 16:57:02 -04:00
|
|
|
@platforms = []
|
2007-11-10 02:48:56 -05:00
|
|
|
@ruby = nil
|
2013-10-15 20:14:16 -04:00
|
|
|
@ruby_api_version = nil
|
2011-05-31 23:45:05 -04:00
|
|
|
@sources = nil
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2011-01-19 16:23:04 -05:00
|
|
|
@post_build_hooks ||= []
|
2008-10-25 18:58:43 -04:00
|
|
|
@post_install_hooks ||= []
|
|
|
|
@post_uninstall_hooks ||= []
|
|
|
|
@pre_uninstall_hooks ||= []
|
|
|
|
@pre_install_hooks ||= []
|
2011-05-31 23:45:05 -04:00
|
|
|
@pre_reset_hooks ||= []
|
|
|
|
@post_reset_hooks ||= []
|
2008-09-25 06:13:50 -04:00
|
|
|
|
2011-01-18 19:08:49 -05:00
|
|
|
##
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
def self.try_activate path
|
2011-03-01 04:41:32 -05:00
|
|
|
# finds the _latest_ version... regardless of loaded specs and their deps
|
2012-11-29 01:52:18 -05:00
|
|
|
# if another gem had a requirement that would mean we shouldn't
|
2013-11-30 18:27:52 -05:00
|
|
|
# activate the latest version, then either it would already be activated
|
|
|
|
# or if it was ambiguous (and thus unresolved) the code in our custom
|
2012-11-29 01:52:18 -05:00
|
|
|
# require will try to activate the more specific version.
|
2011-03-01 04:41:32 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
spec = Gem::Specification.find_by_path path
|
|
|
|
return false unless spec
|
|
|
|
return true if spec.activated?
|
2011-01-18 19:08:49 -05:00
|
|
|
|
2011-03-01 04:41:32 -05:00
|
|
|
begin
|
2011-05-31 23:45:05 -04:00
|
|
|
spec.activate
|
2011-03-01 04:41:32 -05:00
|
|
|
rescue Gem::LoadError # this could fail due to gem dep collisions, go lax
|
2011-05-31 23:45:05 -04:00
|
|
|
Gem::Specification.find_by_name(spec.name).activate
|
2011-03-01 04:41:32 -05:00
|
|
|
end
|
|
|
|
|
2011-01-18 19:08:49 -05:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
def self.needs
|
|
|
|
rs = Gem::RequestSet.new
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
yield rs
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
finish_resolve rs
|
2011-03-01 04:41:32 -05:00
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
def self.finish_resolve(request_set=Gem::RequestSet.new)
|
|
|
|
request_set.import Gem::Specification.unresolved_deps.values
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
request_set.resolve_current.each do |s|
|
|
|
|
s.full_spec.activate
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-06-09 17:38:59 -04:00
|
|
|
##
|
|
|
|
# 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
|
2011-01-18 19:08:49 -05:00
|
|
|
# specified executable's path is returned. +requirements+ allows
|
2010-04-22 04:24:42 -04:00
|
|
|
# you to specify specific gem versions.
|
2009-06-09 17:38:59 -04:00
|
|
|
|
2011-01-18 19:08:49 -05:00
|
|
|
def self.bin_path(name, exec_name = nil, *requirements)
|
2011-05-31 23:45:05 -04:00
|
|
|
# TODO: fails test_self_bin_path_bin_file_gone_in_latest
|
|
|
|
# Gem::Specification.find_by_name(name, *requirements).bin_file exec_name
|
|
|
|
|
|
|
|
raise ArgumentError, "you must supply exec_name" unless exec_name
|
|
|
|
|
2011-01-18 19:08:49 -05:00
|
|
|
requirements = Gem::Requirement.default if
|
|
|
|
requirements.empty?
|
2011-05-31 23:45:05 -04:00
|
|
|
|
2014-12-06 19:53:01 -05:00
|
|
|
dep = Gem::Dependency.new name, requirements
|
|
|
|
|
|
|
|
loaded = Gem.loaded_specs[name]
|
|
|
|
|
|
|
|
return loaded.bin_file exec_name if loaded && dep.matches_spec?(loaded)
|
|
|
|
|
|
|
|
specs = dep.matching_specs(true)
|
2009-06-09 17:38:59 -04:00
|
|
|
|
|
|
|
raise Gem::GemNotFoundException,
|
2011-01-18 19:08:49 -05:00
|
|
|
"can't find gem #{name} (#{requirements})" if specs.empty?
|
2009-06-09 17:38:59 -04:00
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
specs = specs.find_all { |spec|
|
|
|
|
spec.executables.include? exec_name
|
|
|
|
} if exec_name
|
2009-06-09 17:38:59 -04:00
|
|
|
|
2011-01-18 19:08:49 -05:00
|
|
|
unless spec = specs.last
|
|
|
|
msg = "can't find gem #{name} (#{requirements}) with executable #{exec_name}"
|
|
|
|
raise Gem::GemNotFoundException, msg
|
2009-06-09 17:38:59 -04:00
|
|
|
end
|
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
spec.bin_file exec_name
|
2009-06-09 17:38:59 -04:00
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
##
|
|
|
|
# The mode needed to read a file as straight binary.
|
|
|
|
|
|
|
|
def self.binary_mode
|
2009-10-04 01:01:12 -04:00
|
|
|
'rb'
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# The path where gem executables are to be installed.
|
|
|
|
|
|
|
|
def self.bindir(install_dir=Gem.dir)
|
2011-05-31 23:45:05 -04:00
|
|
|
return File.join install_dir, 'bin' unless
|
|
|
|
install_dir.to_s == Gem.default_dir.to_s
|
2008-03-31 18:40:06 -04:00
|
|
|
Gem.default_bindir
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
2007-11-10 02:48:56 -05:00
|
|
|
# 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.
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2007-11-10 02:48:56 -05:00
|
|
|
def self.clear_paths
|
2011-05-31 23:45:05 -04:00
|
|
|
@paths = nil
|
|
|
|
@user_home = nil
|
|
|
|
Gem::Specification.reset
|
2013-09-09 20:52:14 -04:00
|
|
|
Gem::Security.reset if defined?(Gem::Security)
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
##
|
|
|
|
# The path to standard location of the user's .gemrc file.
|
|
|
|
|
|
|
|
def self.config_file
|
2011-05-31 23:45:05 -04:00
|
|
|
@config_file ||= File.join Gem.user_home, '.gemrc'
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
##
|
2008-03-31 18:40:06 -04:00
|
|
|
# The standard configuration object for gems.
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
def self.configuration
|
2008-09-25 06:13:50 -04:00
|
|
|
@configuration ||= Gem::ConfigFile.new []
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
##
|
|
|
|
# Use the given configuration object (which implements the ConfigFile
|
|
|
|
# protocol) as the standard configuration object.
|
|
|
|
|
|
|
|
def self.configuration=(config)
|
|
|
|
@configuration = config
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
##
|
2014-09-13 23:30:02 -04:00
|
|
|
# The path to the data directory specified by the gem name. If the
|
2008-03-31 18:40:06 -04:00
|
|
|
# package is not available as a gem, return nil.
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
def self.datadir(gem_name)
|
2012-11-29 01:52:18 -05:00
|
|
|
# TODO: deprecate and move to Gem::Specification
|
|
|
|
# and drop the extra ", gem_name" which is uselessly redundant
|
2008-03-31 18:40:06 -04:00
|
|
|
spec = @loaded_specs[gem_name]
|
|
|
|
return nil if spec.nil?
|
2011-05-31 23:45:05 -04:00
|
|
|
File.join spec.full_gem_path, "data", gem_name
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2008-06-17 18:04:18 -04:00
|
|
|
##
|
|
|
|
# A Zlib::Deflate.deflate wrapper
|
|
|
|
|
|
|
|
def self.deflate(data)
|
2008-10-25 18:58:43 -04:00
|
|
|
require 'zlib'
|
2008-06-17 18:04:18 -04:00
|
|
|
Zlib::Deflate.deflate data
|
|
|
|
end
|
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
# Retrieve the PathSupport object that RubyGems uses to
|
|
|
|
# lookup files.
|
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
def self.paths
|
|
|
|
@paths ||= Gem::PathSupport.new
|
|
|
|
end
|
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
# Initialize the filesystem paths to use from +env+.
|
|
|
|
# +env+ is a hash-like object (typically ENV) that
|
|
|
|
# is queried for 'GEM_HOME', 'GEM_PATH', and 'GEM_SPEC_CACHE'
|
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
def self.paths=(env)
|
|
|
|
clear_paths
|
|
|
|
@paths = Gem::PathSupport.new env
|
2013-11-18 19:34:13 -05:00
|
|
|
Gem::Specification.dirs = @paths.path
|
2011-05-31 23:45:05 -04:00
|
|
|
end
|
|
|
|
|
2007-11-10 02:48:56 -05:00
|
|
|
##
|
2008-03-31 18:40:06 -04:00
|
|
|
# The path where gems are to be installed.
|
2011-05-31 23:45:05 -04:00
|
|
|
#--
|
|
|
|
# FIXME deprecate these once everything else has been done -ebh
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
def self.dir
|
2011-05-31 23:45:05 -04:00
|
|
|
paths.home
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.path
|
|
|
|
paths.path
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2013-09-14 04:59:02 -04:00
|
|
|
def self.spec_cache_dir
|
|
|
|
paths.spec_cache_dir
|
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
##
|
2013-03-05 18:02:00 -05:00
|
|
|
# Quietly ensure the Gem directory +dir+ contains all the proper
|
2008-03-31 18:40:06 -04:00
|
|
|
# subdirectories. If we can't create a directory due to a permission
|
|
|
|
# problem, then we will silently continue.
|
2013-03-05 18:02:00 -05:00
|
|
|
#
|
|
|
|
# If +mode+ is given, missing directories are created with this mode.
|
|
|
|
#
|
|
|
|
# World-writable directories will never be created.
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2013-03-05 18:02:00 -05:00
|
|
|
def self.ensure_gem_subdirectories dir = Gem.dir, mode = nil
|
2013-09-14 04:59:02 -04:00
|
|
|
ensure_subdirectories(dir, mode, REPOSITORY_SUBDIRECTORIES)
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Quietly ensure the Gem directory +dir+ contains all the proper
|
|
|
|
# subdirectories for handling default gems. If we can't create a
|
|
|
|
# directory due to a permission problem, then we will silently continue.
|
|
|
|
#
|
|
|
|
# If +mode+ is given, missing directories are created with this mode.
|
|
|
|
#
|
|
|
|
# World-writable directories will never be created.
|
|
|
|
|
|
|
|
def self.ensure_default_gem_subdirectories dir = Gem.dir, mode = nil
|
|
|
|
ensure_subdirectories(dir, mode, REPOSITORY_DEFAULT_GEM_SUBDIRECTORIES)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.ensure_subdirectories dir, mode, subdirs # :nodoc:
|
2012-04-17 17:17:56 -04:00
|
|
|
old_umask = File.umask
|
2012-04-17 20:04:12 -04:00
|
|
|
File.umask old_umask | 002
|
|
|
|
|
|
|
|
require 'fileutils'
|
2012-04-17 17:17:56 -04:00
|
|
|
|
2013-03-05 18:02:00 -05:00
|
|
|
options = {}
|
|
|
|
|
|
|
|
options[:mode] = mode if mode
|
|
|
|
|
2013-09-14 04:59:02 -04:00
|
|
|
subdirs.each do |name|
|
2011-05-31 23:45:05 -04:00
|
|
|
subdir = File.join dir, name
|
|
|
|
next if File.exist? subdir
|
2013-03-05 18:02:00 -05:00
|
|
|
FileUtils.mkdir_p subdir, options rescue nil
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
2011-08-04 21:00:01 -04:00
|
|
|
ensure
|
|
|
|
File.umask old_umask
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2013-10-17 17:03:49 -04:00
|
|
|
##
|
|
|
|
# The extension API version of ruby. This includes the static vs non-static
|
|
|
|
# distinction as extensions cannot be shared between the two.
|
|
|
|
|
|
|
|
def self.extension_api_version # :nodoc:
|
|
|
|
if 'no' == RbConfig::CONFIG['ENABLE_SHARED'] then
|
|
|
|
"#{ruby_api_version}-static"
|
|
|
|
else
|
|
|
|
ruby_api_version
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
##
|
2011-01-18 19:08:49 -05:00
|
|
|
# Returns a list of paths matching +glob+ that can be used by a gem to pick
|
2008-09-25 06:13:50 -04:00
|
|
|
# up features from other gems. For example:
|
|
|
|
#
|
|
|
|
# Gem.find_files('rdoc/discover').each do |path| load path end
|
|
|
|
#
|
2011-01-18 19:08:49 -05:00
|
|
|
# if +check_load_path+ is true (the default), then find_files also searches
|
|
|
|
# $LOAD_PATH for files as well as gems.
|
2009-06-09 17:38:59 -04:00
|
|
|
#
|
|
|
|
# Note that find_files will return all files even if they are from different
|
2013-09-14 04:59:02 -04:00
|
|
|
# versions of the same gem. See also find_latest_files
|
2008-09-25 06:13:50 -04:00
|
|
|
|
2011-01-18 19:08:49 -05:00
|
|
|
def self.find_files(glob, check_load_path=true)
|
|
|
|
files = []
|
2009-06-09 17:38:59 -04:00
|
|
|
|
2013-09-14 04:59:02 -04:00
|
|
|
files = find_files_from_load_path glob if check_load_path
|
2008-09-25 06:13:50 -04:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
files.concat Gem::Specification.stubs.map { |spec|
|
2011-05-31 23:45:05 -04:00
|
|
|
spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}")
|
|
|
|
}.flatten
|
2011-01-18 19:08:49 -05:00
|
|
|
|
|
|
|
# $LOAD_PATH might contain duplicate entries or reference
|
|
|
|
# the spec dirs directly, so we prune.
|
|
|
|
files.uniq! if check_load_path
|
|
|
|
|
|
|
|
return files
|
2008-09-25 06:13:50 -04:00
|
|
|
end
|
|
|
|
|
2013-09-14 04:59:02 -04:00
|
|
|
def self.find_files_from_load_path glob # :nodoc:
|
|
|
|
$LOAD_PATH.map { |load_path|
|
|
|
|
Dir["#{File.expand_path glob, load_path}#{Gem.suffix_pattern}"]
|
|
|
|
}.flatten.select { |file| File.file? file.untaint }
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Returns a list of paths matching +glob+ from the latest gems that can be
|
|
|
|
# used by a gem to pick up features from other gems. For example:
|
|
|
|
#
|
|
|
|
# Gem.find_latest_files('rdoc/discover').each do |path| load path end
|
|
|
|
#
|
|
|
|
# if +check_load_path+ is true (the default), then find_latest_files also
|
|
|
|
# searches $LOAD_PATH for files as well as gems.
|
|
|
|
#
|
|
|
|
# Unlike find_files, find_latest_files will return only files from the
|
|
|
|
# latest version of a gem.
|
|
|
|
|
|
|
|
def self.find_latest_files(glob, check_load_path=true)
|
|
|
|
files = []
|
|
|
|
|
|
|
|
files = find_files_from_load_path glob if check_load_path
|
|
|
|
|
|
|
|
files.concat Gem::Specification.latest_specs(true).map { |spec|
|
|
|
|
spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}")
|
|
|
|
}.flatten
|
|
|
|
|
|
|
|
# $LOAD_PATH might contain duplicate entries or reference
|
|
|
|
# the spec dirs directly, so we prune.
|
|
|
|
files.uniq! if check_load_path
|
|
|
|
|
|
|
|
return files
|
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
##
|
|
|
|
# Finds the user's home directory.
|
2011-01-18 19:08:49 -05:00
|
|
|
#--
|
|
|
|
# Some comments from the ruby-talk list regarding finding the home
|
|
|
|
# directory:
|
|
|
|
#
|
|
|
|
# I have HOME, USERPROFILE and HOMEDRIVE + HOMEPATH. Ruby seems
|
|
|
|
# to be depending on HOME in those code samples. I propose that
|
|
|
|
# it should fallback to USERPROFILE and HOMEDRIVE + HOMEPATH (at
|
|
|
|
# least on Win32).
|
2011-03-01 04:41:32 -05:00
|
|
|
#++
|
2011-05-31 23:45:05 -04:00
|
|
|
#--
|
|
|
|
#
|
|
|
|
# FIXME move to pathsupport
|
|
|
|
#
|
|
|
|
#++
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
def self.find_home
|
2011-05-31 23:45:05 -04:00
|
|
|
windows = File::ALT_SEPARATOR
|
|
|
|
if not windows or RUBY_VERSION >= '1.9' then
|
|
|
|
File.expand_path "~"
|
|
|
|
else
|
|
|
|
['HOME', 'USERPROFILE'].each do |key|
|
|
|
|
return File.expand_path ENV[key] if ENV[key]
|
2011-01-18 19:08:49 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
if ENV['HOMEDRIVE'] && ENV['HOMEPATH'] then
|
2011-05-31 23:45:05 -04:00
|
|
|
File.expand_path "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}"
|
2011-01-18 19:08:49 -05:00
|
|
|
end
|
|
|
|
end
|
2009-01-04 03:07:22 -05:00
|
|
|
rescue
|
2011-05-31 23:45:05 -04:00
|
|
|
if windows then
|
|
|
|
File.expand_path File.join(ENV['HOMEDRIVE'] || ENV['SystemDrive'], '/')
|
2009-01-04 03:07:22 -05:00
|
|
|
else
|
2011-05-31 23:45:05 -04:00
|
|
|
File.expand_path "/"
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
private_class_method :find_home
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
# FIXME deprecate these in 3.0
|
|
|
|
|
2008-06-17 18:04:18 -04:00
|
|
|
##
|
|
|
|
# Zlib::GzipReader wrapper that unzips +data+.
|
|
|
|
|
|
|
|
def self.gunzip(data)
|
2013-11-18 19:34:13 -05:00
|
|
|
require 'rubygems/util'
|
|
|
|
Gem::Util.gunzip data
|
2008-06-17 18:04:18 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Zlib::GzipWriter wrapper that zips +data+.
|
|
|
|
|
|
|
|
def self.gzip(data)
|
2013-11-18 19:34:13 -05:00
|
|
|
require 'rubygems/util'
|
|
|
|
Gem::Util.gzip data
|
2008-06-17 18:04:18 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# A Zlib::Inflate#inflate wrapper
|
|
|
|
|
|
|
|
def self.inflate(data)
|
2013-11-18 19:34:13 -05:00
|
|
|
require 'rubygems/util'
|
|
|
|
Gem::Util.inflate data
|
2008-06-17 18:04:18 -04:00
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
##
|
|
|
|
# Top level install helper method. Allows you to install gems interactively:
|
|
|
|
#
|
|
|
|
# % irb
|
|
|
|
# >> Gem.install "minitest"
|
|
|
|
# Fetching: minitest-3.0.1.gem (100%)
|
|
|
|
# => [#<Gem::Specification:0x1013b4528 @name="minitest", ...>]
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
def self.install name, version = Gem::Requirement.default, *options
|
2012-11-29 01:52:18 -05:00
|
|
|
require "rubygems/dependency_installer"
|
2014-09-13 23:30:02 -04:00
|
|
|
inst = Gem::DependencyInstaller.new(*options)
|
2012-11-29 01:52:18 -05:00
|
|
|
inst.install name, version
|
|
|
|
inst.installed_gems
|
|
|
|
end
|
|
|
|
|
2011-01-18 19:08:49 -05:00
|
|
|
##
|
|
|
|
# Get the default RubyGems API host. This is normally
|
|
|
|
# <tt>https://rubygems.org</tt>.
|
|
|
|
|
|
|
|
def self.host
|
2011-05-31 23:45:05 -04:00
|
|
|
# TODO: move to utils
|
2012-11-29 01:52:18 -05:00
|
|
|
@host ||= Gem::DEFAULT_HOST
|
2011-01-18 19:08:49 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
## Set the default RubyGems API host.
|
|
|
|
|
|
|
|
def self.host= host
|
2011-05-31 23:45:05 -04:00
|
|
|
# TODO: move to utils
|
2011-01-18 19:08:49 -05:00
|
|
|
@host = host
|
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
##
|
2013-12-21 20:16:22 -05:00
|
|
|
# The index to insert activated gem paths into the $LOAD_PATH. The activated
|
|
|
|
# gem's paths are inserted before site lib directory by default.
|
2008-03-31 18:40:06 -04:00
|
|
|
|
|
|
|
def self.load_path_insert_index
|
2015-07-02 01:15:53 -04:00
|
|
|
$LOAD_PATH.each_with_index do |path, i|
|
|
|
|
return i if path.instance_variable_defined?(:@gem_prelude_index)
|
|
|
|
end
|
|
|
|
|
2014-01-06 20:19:28 -05:00
|
|
|
index = $LOAD_PATH.index RbConfig::CONFIG['sitelibdir']
|
2011-01-18 19:08:49 -05:00
|
|
|
|
|
|
|
index
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2012-04-17 20:04:12 -04:00
|
|
|
@yaml_loaded = false
|
|
|
|
|
2011-01-18 19:08:49 -05:00
|
|
|
##
|
|
|
|
# Loads YAML, preferring Psych
|
|
|
|
|
|
|
|
def self.load_yaml
|
2012-04-17 20:04:12 -04:00
|
|
|
return if @yaml_loaded
|
2012-11-29 03:34:52 -05:00
|
|
|
return unless defined?(gem)
|
2012-04-17 16:50:00 -04:00
|
|
|
|
2012-04-17 20:04:12 -04:00
|
|
|
test_syck = ENV['TEST_SYCK']
|
2012-04-17 16:50:00 -04:00
|
|
|
|
2015-10-29 20:54:12 -04:00
|
|
|
# Only Ruby 1.8 and 1.9 have syck
|
|
|
|
test_syck = false unless /^1\./ =~ RUBY_VERSION
|
|
|
|
|
2012-04-17 20:04:12 -04:00
|
|
|
unless test_syck
|
|
|
|
begin
|
2015-07-01 17:50:14 -04:00
|
|
|
gem 'psych', '>= 1.2.1'
|
2012-04-17 20:04:12 -04:00
|
|
|
rescue Gem::LoadError
|
|
|
|
# It's OK if the user does not have the psych gem installed. We will
|
|
|
|
# attempt to require the stdlib version
|
|
|
|
end
|
|
|
|
|
|
|
|
begin
|
|
|
|
# Try requiring the gem version *or* stdlib version of psych.
|
|
|
|
require 'psych'
|
|
|
|
rescue ::LoadError
|
|
|
|
# If we can't load psych, thats fine, go on.
|
|
|
|
else
|
|
|
|
# If 'yaml' has already been required, then we have to
|
|
|
|
# be sure to switch it over to the newly loaded psych.
|
|
|
|
if defined?(YAML::ENGINE) && YAML::ENGINE.yamler != "psych"
|
|
|
|
YAML::ENGINE.yamler = "psych"
|
2012-04-17 17:17:56 -04:00
|
|
|
end
|
2012-04-17 20:04:12 -04:00
|
|
|
|
|
|
|
require 'rubygems/psych_additions'
|
|
|
|
require 'rubygems/psych_tree'
|
|
|
|
end
|
2012-04-17 17:17:56 -04:00
|
|
|
end
|
2012-04-17 20:04:12 -04:00
|
|
|
|
|
|
|
require 'yaml'
|
|
|
|
|
|
|
|
# If we're supposed to be using syck, then we may have to force
|
|
|
|
# activate it via the YAML::ENGINE API.
|
|
|
|
if test_syck and defined?(YAML::ENGINE)
|
|
|
|
YAML::ENGINE.yamler = "syck" unless YAML::ENGINE.syck?
|
|
|
|
end
|
|
|
|
|
|
|
|
# Now that we're sure some kind of yaml library is loaded, pull
|
|
|
|
# in our hack to deal with Syck's DefaultKey ugliness.
|
|
|
|
require 'rubygems/syck_hack'
|
|
|
|
|
|
|
|
@yaml_loaded = true
|
2010-07-07 11:40:52 -04:00
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
##
|
|
|
|
# The file name and line number of the caller of the caller of this method.
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
def self.location_of_caller
|
2009-06-09 17:38:59 -04:00
|
|
|
caller[1] =~ /(.*?):(\d+).*?$/i
|
2008-10-25 18:58:43 -04:00
|
|
|
file = $1
|
|
|
|
lineno = $2.to_i
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
[file, lineno]
|
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
##
|
|
|
|
# The version of the Marshal format for your Ruby.
|
2008-02-10 03:00:19 -05:00
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
def self.marshal_version
|
|
|
|
"#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}"
|
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
##
|
2008-04-11 16:57:02 -04:00
|
|
|
# Set array of platforms this RubyGems supports (primarily for testing).
|
|
|
|
|
|
|
|
def self.platforms=(platforms)
|
|
|
|
@platforms = platforms
|
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2008-04-11 16:57:02 -04:00
|
|
|
##
|
|
|
|
# Array of platforms this RubyGems supports.
|
2008-06-17 18:04:18 -04:00
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
def self.platforms
|
2008-04-11 16:57:02 -04:00
|
|
|
@platforms ||= []
|
|
|
|
if @platforms.empty?
|
|
|
|
@platforms = [Gem::Platform::RUBY, Gem::Platform.local]
|
|
|
|
end
|
|
|
|
@platforms
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2011-01-19 16:23:04 -05:00
|
|
|
##
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
def self.post_build(&hook)
|
|
|
|
@post_build_hooks << hook
|
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
##
|
|
|
|
# Adds a post-install hook that will be passed an Gem::Installer instance
|
|
|
|
# when Gem::Installer#install is called
|
|
|
|
|
|
|
|
def self.post_install(&hook)
|
|
|
|
@post_install_hooks << hook
|
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
##
|
|
|
|
# Adds a post-installs hook that will be passed a Gem::DependencyInstaller
|
|
|
|
# and a list of installed specifications when
|
|
|
|
# Gem::DependencyInstaller#install is complete
|
|
|
|
|
|
|
|
def self.done_installing(&hook)
|
|
|
|
@done_installing_hooks << hook
|
|
|
|
end
|
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
##
|
|
|
|
# Adds a hook that will get run after Gem::Specification.reset is
|
|
|
|
# run.
|
|
|
|
|
|
|
|
def self.post_reset(&hook)
|
|
|
|
@post_reset_hooks << hook
|
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
##
|
|
|
|
# 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
|
|
|
|
|
|
|
|
def self.post_uninstall(&hook)
|
|
|
|
@post_uninstall_hooks << hook
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Adds a pre-install hook that will be passed an Gem::Installer instance
|
2011-01-19 16:23:04 -05:00
|
|
|
# when Gem::Installer#install is called. If the hook returns +false+ then
|
|
|
|
# the install will be aborted.
|
2008-09-25 06:13:50 -04:00
|
|
|
|
|
|
|
def self.pre_install(&hook)
|
|
|
|
@pre_install_hooks << hook
|
|
|
|
end
|
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
##
|
|
|
|
# Adds a hook that will get run before Gem::Specification.reset is
|
|
|
|
# run.
|
|
|
|
|
|
|
|
def self.pre_reset(&hook)
|
|
|
|
@pre_reset_hooks << hook
|
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
##
|
|
|
|
# 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
|
|
|
|
|
|
|
|
def self.pre_uninstall(&hook)
|
|
|
|
@pre_uninstall_hooks << hook
|
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
##
|
2011-03-01 04:41:32 -05:00
|
|
|
# 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.
|
2007-12-24 18:28:35 -05:00
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
def self.prefix
|
2011-03-01 04:41:32 -05:00
|
|
|
prefix = File.dirname RUBYGEMS_DIR
|
2008-02-10 03:00:19 -05:00
|
|
|
|
2014-01-06 20:19:28 -05:00
|
|
|
if prefix != File.expand_path(RbConfig::CONFIG['sitelibdir']) and
|
|
|
|
prefix != File.expand_path(RbConfig::CONFIG['libdir']) and
|
2011-03-01 04:41:32 -05:00
|
|
|
'lib' == File.basename(RUBYGEMS_DIR) then
|
2010-02-21 21:52:35 -05:00
|
|
|
prefix
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2009-06-09 17:38:59 -04:00
|
|
|
##
|
2012-11-29 01:52:18 -05:00
|
|
|
# Refresh available gems from disk.
|
2008-04-11 16:57:02 -04:00
|
|
|
|
|
|
|
def self.refresh
|
2011-05-31 23:45:05 -04:00
|
|
|
Gem::Specification.reset
|
2008-04-11 16:57:02 -04:00
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
##
|
|
|
|
# Safely read a file in binary mode on all platforms.
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
def self.read_binary(path)
|
2013-12-18 22:05:37 -05:00
|
|
|
open path, 'rb+' do |f|
|
2013-12-12 19:51:04 -05:00
|
|
|
f.flock(File::LOCK_EX)
|
2013-12-12 19:56:06 -05:00
|
|
|
f.read
|
2013-12-12 19:51:04 -05:00
|
|
|
end
|
2014-01-06 20:19:28 -05:00
|
|
|
rescue Errno::EACCES
|
|
|
|
open path, 'rb' do |f|
|
|
|
|
f.read
|
|
|
|
end
|
2015-10-29 20:54:12 -04:00
|
|
|
rescue Errno::ENOLCK # NFS
|
|
|
|
if Thread.main != Thread.current
|
|
|
|
raise
|
|
|
|
else
|
|
|
|
open path, 'rb' do |f|
|
|
|
|
f.read
|
|
|
|
end
|
|
|
|
end
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# The path to the running Ruby interpreter.
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
def self.ruby
|
|
|
|
if @ruby.nil? then
|
2014-01-06 20:19:28 -05:00
|
|
|
@ruby = File.join(RbConfig::CONFIG['bindir'],
|
|
|
|
"#{RbConfig::CONFIG['ruby_install_name']}#{RbConfig::CONFIG['EXEEXT']}")
|
2008-09-25 06:13:50 -04:00
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
@ruby = "\"#{@ruby}\"" if @ruby =~ /\s/
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
@ruby
|
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2013-10-15 20:14:16 -04:00
|
|
|
##
|
|
|
|
# Returns a String containing the API compatibility version of Ruby
|
|
|
|
|
|
|
|
def self.ruby_api_version
|
2014-01-06 20:19:28 -05:00
|
|
|
@ruby_api_version ||= RbConfig::CONFIG['ruby_version'].dup
|
2013-10-15 20:14:16 -04:00
|
|
|
end
|
|
|
|
|
2012-12-22 19:35:09 -05:00
|
|
|
##
|
|
|
|
# Returns the latest release-version specification for the gem +name+.
|
|
|
|
|
2011-03-01 04:41:32 -05:00
|
|
|
def self.latest_spec_for name
|
2012-12-22 19:35:09 -05:00
|
|
|
dependency = Gem::Dependency.new name
|
|
|
|
fetcher = Gem::SpecFetcher.fetcher
|
|
|
|
spec_tuples, = fetcher.spec_for_dependency dependency
|
2011-03-01 04:41:32 -05:00
|
|
|
|
2012-12-22 19:35:09 -05:00
|
|
|
spec, = spec_tuples.first
|
2011-03-01 04:41:32 -05:00
|
|
|
|
2012-12-22 19:35:09 -05:00
|
|
|
spec
|
2011-03-01 04:41:32 -05:00
|
|
|
end
|
|
|
|
|
2012-12-22 19:35:09 -05:00
|
|
|
##
|
|
|
|
# Returns the latest release version of RubyGems.
|
2011-03-01 04:41:32 -05:00
|
|
|
|
|
|
|
def self.latest_rubygems_version
|
2012-12-22 19:35:09 -05:00
|
|
|
latest_version_for('rubygems-update') or
|
2012-11-29 01:52:18 -05:00
|
|
|
raise "Can't find 'rubygems-update' in any repo. Check `gem source list`."
|
2011-03-01 04:41:32 -05:00
|
|
|
end
|
|
|
|
|
2012-12-22 19:35:09 -05:00
|
|
|
##
|
|
|
|
# Returns the version of the latest release-version of gem +name+
|
|
|
|
|
|
|
|
def self.latest_version_for name
|
|
|
|
spec = latest_spec_for name
|
|
|
|
spec and spec.version
|
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
##
|
2013-09-14 04:59:02 -04:00
|
|
|
# A Gem::Version for the currently running Ruby.
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
def self.ruby_version
|
|
|
|
return @ruby_version if defined? @ruby_version
|
|
|
|
version = RUBY_VERSION.dup
|
2009-06-09 17:38:59 -04:00
|
|
|
|
|
|
|
if defined?(RUBY_PATCHLEVEL) && RUBY_PATCHLEVEL != -1 then
|
|
|
|
version << ".#{RUBY_PATCHLEVEL}"
|
|
|
|
elsif defined?(RUBY_REVISION) then
|
|
|
|
version << ".dev.#{RUBY_REVISION}"
|
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
@ruby_version = Gem::Version.new version
|
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
##
|
2012-11-29 01:52:18 -05:00
|
|
|
# A Gem::Version for the currently running RubyGems
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
def self.rubygems_version
|
|
|
|
return @rubygems_version if defined? @rubygems_version
|
|
|
|
@rubygems_version = Gem::Version.new Gem::VERSION
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
##
|
2012-11-29 01:52:18 -05:00
|
|
|
# Returns an Array of sources to fetch remote gems from. Uses
|
|
|
|
# default_sources if the sources list is empty.
|
2008-03-31 18:40:06 -04:00
|
|
|
|
|
|
|
def self.sources
|
2012-11-29 01:52:18 -05:00
|
|
|
@sources ||= Gem::SourceList.from(default_sources)
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
##
|
|
|
|
# Need to be able to set the sources without calling
|
|
|
|
# Gem.sources.replace since that would cause an infinite loop.
|
2012-11-29 01:52:18 -05:00
|
|
|
#
|
|
|
|
# DOC: This comment is not documentation about the method itself, it's
|
|
|
|
# more of a code comment about the implementation.
|
2008-09-25 06:13:50 -04:00
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
def self.sources= new_sources
|
2012-11-29 01:52:18 -05:00
|
|
|
if !new_sources
|
|
|
|
@sources = nil
|
|
|
|
else
|
|
|
|
@sources = Gem::SourceList.from(new_sources)
|
|
|
|
end
|
2008-09-25 06:13:50 -04:00
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
##
|
|
|
|
# Glob pattern for require-able path suffixes.
|
|
|
|
|
|
|
|
def self.suffix_pattern
|
|
|
|
@suffix_pattern ||= "{#{suffixes.join(',')}}"
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Suffixes for require-able paths.
|
|
|
|
|
|
|
|
def self.suffixes
|
2011-01-18 19:08:49 -05:00
|
|
|
@suffixes ||= ['',
|
|
|
|
'.rb',
|
|
|
|
*%w(DLEXT DLEXT2).map { |key|
|
|
|
|
val = RbConfig::CONFIG[key]
|
2011-01-19 16:23:04 -05:00
|
|
|
next unless val and not val.empty?
|
|
|
|
".#{val}"
|
2011-01-18 19:08:49 -05:00
|
|
|
}
|
|
|
|
].compact.uniq
|
|
|
|
end
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2009-06-09 17:38:59 -04:00
|
|
|
##
|
|
|
|
# Prints the amount of time the supplied block takes to run using the debug
|
|
|
|
# UI output.
|
|
|
|
|
|
|
|
def self.time(msg, width = 0, display = Gem.configuration.verbose)
|
|
|
|
now = Time.now
|
|
|
|
|
|
|
|
value = yield
|
|
|
|
|
|
|
|
elapsed = Time.now - now
|
|
|
|
|
|
|
|
ui.say "%2$*1$s: %3$3.3fs" % [-width, msg, elapsed] if display
|
|
|
|
|
|
|
|
value
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Lazily loads DefaultUserInteraction and returns the default UI.
|
|
|
|
|
|
|
|
def self.ui
|
|
|
|
require 'rubygems/user_interaction'
|
|
|
|
|
|
|
|
Gem::DefaultUserInteraction.ui
|
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
##
|
|
|
|
# Use the +home+ and +paths+ values for Gem.dir and Gem.path. Used mainly
|
|
|
|
# by the unit tests to provide environment isolation.
|
|
|
|
|
2011-08-23 18:58:06 -04:00
|
|
|
def self.use_paths(home, *paths)
|
|
|
|
paths = nil if paths == [nil]
|
|
|
|
paths = paths.first if Array === Array(paths).first
|
2011-05-31 23:45:05 -04:00
|
|
|
self.paths = { "GEM_HOME" => home, "GEM_PATH" => paths }
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# The home directory for the user.
|
|
|
|
|
|
|
|
def self.user_home
|
2012-11-29 01:52:18 -05:00
|
|
|
@user_home ||= find_home.untaint
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Is this a windows platform?
|
|
|
|
|
|
|
|
def self.win_platform?
|
|
|
|
if @@win_platform.nil? then
|
2013-03-05 17:40:53 -05:00
|
|
|
ruby_platform = RbConfig::CONFIG['host_os']
|
|
|
|
@@win_platform = !!WIN_PATTERNS.find { |r| ruby_platform =~ r }
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
@@win_platform
|
|
|
|
end
|
|
|
|
|
2010-04-22 04:24:42 -04:00
|
|
|
##
|
2013-09-14 04:59:02 -04:00
|
|
|
# Load +plugins+ as Ruby files
|
2010-04-22 04:24:42 -04:00
|
|
|
|
2013-09-14 04:59:02 -04:00
|
|
|
def self.load_plugin_files plugins # :nodoc:
|
2010-04-22 04:24:42 -04:00
|
|
|
plugins.each do |plugin|
|
|
|
|
|
|
|
|
# Skip older versions of the GemCutter plugin: Its commands are in
|
|
|
|
# RubyGems proper now.
|
|
|
|
|
|
|
|
next if plugin =~ /gemcutter-0\.[0-3]/
|
|
|
|
|
|
|
|
begin
|
|
|
|
load plugin
|
|
|
|
rescue ::Exception => e
|
|
|
|
details = "#{plugin.inspect}: #{e.message} (#{e.class})"
|
|
|
|
warn "Error loading RubyGems plugin #{details}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-01-18 19:08:49 -05:00
|
|
|
##
|
2013-09-14 04:59:02 -04:00
|
|
|
# Find the 'rubygems_plugin' files in the latest installed gems and load
|
|
|
|
# them
|
2011-01-18 19:08:49 -05:00
|
|
|
|
|
|
|
def self.load_plugins
|
2013-09-14 04:59:02 -04:00
|
|
|
# Remove this env var by at least 3.0
|
|
|
|
if ENV['RUBYGEMS_LOAD_ALL_PLUGINS']
|
|
|
|
load_plugin_files find_files('rubygems_plugin', false)
|
|
|
|
else
|
|
|
|
load_plugin_files find_latest_files('rubygems_plugin', false)
|
|
|
|
end
|
2011-01-18 19:08:49 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Find all 'rubygems_plugin' files in $LOAD_PATH and load them
|
|
|
|
|
|
|
|
def self.load_env_plugins
|
|
|
|
path = "rubygems_plugin"
|
|
|
|
|
|
|
|
files = []
|
|
|
|
$LOAD_PATH.each do |load_path|
|
|
|
|
globbed = Dir["#{File.expand_path path, load_path}#{Gem.suffix_pattern}"]
|
|
|
|
|
|
|
|
globbed.each do |load_path_file|
|
|
|
|
files << load_path_file if File.file?(load_path_file.untaint)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
load_plugin_files files
|
|
|
|
end
|
|
|
|
|
2013-11-21 18:27:30 -05:00
|
|
|
##
|
2014-09-13 23:30:02 -04:00
|
|
|
# Looks for a gem dependency file at +path+ and activates the gems in the
|
|
|
|
# file if found. If the file is not found an ArgumentError is raised.
|
|
|
|
#
|
|
|
|
# If +path+ is not given the RUBYGEMS_GEMDEPS environment variable is used,
|
|
|
|
# but if no file is found no exception is raised.
|
|
|
|
#
|
|
|
|
# If '-' is given for +path+ RubyGems searches up from the current working
|
|
|
|
# directory for gem dependency files (gem.deps.rb, Gemfile, Isolate) and
|
|
|
|
# activates the gems in the first one found.
|
2013-11-21 18:27:30 -05:00
|
|
|
#
|
2013-11-22 13:53:21 -05:00
|
|
|
# You can run this automatically when rubygems starts. To enable, set
|
|
|
|
# the <code>RUBYGEMS_GEMDEPS</code> environment variable to either the path
|
2014-09-13 23:30:02 -04:00
|
|
|
# of your gem dependencies file or "-" to auto-discover in parent
|
|
|
|
# directories.
|
2013-11-22 13:53:21 -05:00
|
|
|
#
|
|
|
|
# NOTE: Enabling automatic discovery on multiuser systems can lead to
|
|
|
|
# execution of arbitrary code when used from directories outside your
|
|
|
|
# control.
|
2013-11-21 18:27:30 -05:00
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
def self.use_gemdeps path = nil
|
|
|
|
raise_exception = path
|
|
|
|
|
|
|
|
path ||= ENV['RUBYGEMS_GEMDEPS']
|
|
|
|
return unless path
|
|
|
|
|
2013-11-25 14:14:49 -05:00
|
|
|
path = path.dup
|
2013-11-21 18:27:30 -05:00
|
|
|
|
2013-11-25 14:14:49 -05:00
|
|
|
if path == "-" then
|
|
|
|
require 'rubygems/util'
|
2013-11-21 18:27:30 -05:00
|
|
|
|
2013-11-25 14:14:49 -05:00
|
|
|
Gem::Util.traverse_parents Dir.pwd do |directory|
|
|
|
|
dep_file = GEM_DEP_FILES.find { |f| File.file?(f) }
|
2013-11-21 18:27:30 -05:00
|
|
|
|
2013-11-25 14:14:49 -05:00
|
|
|
next unless dep_file
|
2013-11-21 18:27:30 -05:00
|
|
|
|
2013-11-25 14:14:49 -05:00
|
|
|
path = File.join directory, dep_file
|
|
|
|
break
|
2013-11-21 18:27:30 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
path.untaint
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
unless File.file? path then
|
|
|
|
return unless raise_exception
|
|
|
|
|
|
|
|
raise ArgumentError, "Unable to find gem dependencies file at #{path}"
|
|
|
|
end
|
2013-11-21 18:27:30 -05:00
|
|
|
|
|
|
|
rs = Gem::RequestSet.new
|
2015-07-01 17:50:14 -04:00
|
|
|
@gemdeps = rs.load_gemdeps path
|
2013-11-21 18:27:30 -05:00
|
|
|
|
|
|
|
rs.resolve_current.map do |s|
|
|
|
|
sp = s.full_spec
|
|
|
|
sp.activate
|
|
|
|
sp
|
|
|
|
end
|
2014-09-13 23:30:02 -04:00
|
|
|
rescue Gem::LoadError, Gem::UnsatisfiableDependencyError => e
|
|
|
|
warn e.message
|
|
|
|
warn "You may need to `gem install -g` to install missing gems"
|
|
|
|
warn ""
|
2013-11-21 18:27:30 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
class << self
|
2013-11-25 14:14:49 -05:00
|
|
|
##
|
|
|
|
# TODO remove with RubyGems 3.0
|
|
|
|
|
2013-11-21 18:27:30 -05:00
|
|
|
alias detect_gemdeps use_gemdeps # :nodoc:
|
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
# FIX: Almost everywhere else we use the `def self.` way of defining class
|
|
|
|
# methods, and then we switch over to `class << self` here. Pick one or the
|
|
|
|
# other.
|
2008-03-31 18:40:06 -04:00
|
|
|
class << self
|
|
|
|
|
2009-06-09 17:38:59 -04:00
|
|
|
##
|
|
|
|
# Hash of loaded Gem::Specification keyed by name
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
attr_reader :loaded_specs
|
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
##
|
|
|
|
# GemDependencyAPI object, which is set when .use_gemdeps is called.
|
|
|
|
# This contains all the information from the Gemfile.
|
|
|
|
|
|
|
|
attr_reader :gemdeps
|
|
|
|
|
2011-01-19 16:23:04 -05:00
|
|
|
##
|
2013-09-14 04:59:02 -04:00
|
|
|
# Register a Gem::Specification for default gem.
|
|
|
|
#
|
|
|
|
# Two formats for the specification are supported:
|
|
|
|
#
|
|
|
|
# * MRI 2.0 style, where spec.files contains unprefixed require names.
|
|
|
|
# The spec's filenames will be registered as-is.
|
|
|
|
# * New style, where spec.files contains files prefixed with paths
|
|
|
|
# from spec.require_paths. The prefixes are stripped before
|
|
|
|
# registering the spec's filenames. Unprefixed files are omitted.
|
|
|
|
#
|
2012-11-29 01:52:18 -05:00
|
|
|
|
|
|
|
def register_default_spec(spec)
|
2013-09-14 04:59:02 -04:00
|
|
|
new_format = Gem.default_gems_use_full_paths? || spec.require_paths.any? {|path| spec.files.any? {|f| f.start_with? path } }
|
|
|
|
|
|
|
|
if new_format
|
|
|
|
prefix_group = spec.require_paths.map {|f| f + "/"}.join("|")
|
|
|
|
prefix_pattern = /^(#{prefix_group})/
|
|
|
|
end
|
|
|
|
|
2013-08-26 16:24:51 -04:00
|
|
|
spec.files.each do |file|
|
2013-09-14 04:59:02 -04:00
|
|
|
if new_format
|
|
|
|
file = file.sub(prefix_pattern, "")
|
|
|
|
next unless $~
|
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
@path_to_default_spec_map[file] = spec
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Find a Gem::Specification of default gem from +path+
|
|
|
|
|
|
|
|
def find_unresolved_default_spec(path)
|
|
|
|
Gem.suffixes.each do |suffix|
|
|
|
|
spec = @path_to_default_spec_map["#{path}#{suffix}"]
|
|
|
|
return spec if spec
|
|
|
|
end
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Remove needless Gem::Specification of default gem from
|
|
|
|
# unresolved default gem list
|
|
|
|
|
|
|
|
def remove_unresolved_default_spec(spec)
|
|
|
|
spec.files.each do |file|
|
|
|
|
@path_to_default_spec_map.delete(file)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
2013-12-08 14:32:07 -05:00
|
|
|
# Clear default gem related variables. It is for test
|
2012-11-29 01:52:18 -05:00
|
|
|
|
|
|
|
def clear_default_specs
|
|
|
|
@path_to_default_spec_map.clear
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# The list of hooks to be run after Gem::Installer#install extracts files
|
|
|
|
# and builds extensions
|
2011-01-19 16:23:04 -05:00
|
|
|
|
|
|
|
attr_reader :post_build_hooks
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
##
|
2012-11-29 01:52:18 -05:00
|
|
|
# The list of hooks to be run after Gem::Installer#install completes
|
|
|
|
# installation
|
2008-09-25 06:13:50 -04:00
|
|
|
|
|
|
|
attr_reader :post_install_hooks
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
##
|
|
|
|
# The list of hooks to be run after Gem::DependencyInstaller installs a
|
|
|
|
# set of gems
|
|
|
|
|
|
|
|
attr_reader :done_installing_hooks
|
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
##
|
|
|
|
# The list of hooks to be run after Gem::Specification.reset is run.
|
|
|
|
|
|
|
|
attr_reader :post_reset_hooks
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
##
|
2012-11-29 01:52:18 -05:00
|
|
|
# The list of hooks to be run after Gem::Uninstaller#uninstall completes
|
|
|
|
# installation
|
2008-09-25 06:13:50 -04:00
|
|
|
|
|
|
|
attr_reader :post_uninstall_hooks
|
|
|
|
|
|
|
|
##
|
2012-11-29 01:52:18 -05:00
|
|
|
# The list of hooks to be run before Gem::Installer#install does any work
|
2008-09-25 06:13:50 -04:00
|
|
|
|
|
|
|
attr_reader :pre_install_hooks
|
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
##
|
|
|
|
# The list of hooks to be run before Gem::Specification.reset is run.
|
|
|
|
|
|
|
|
attr_reader :pre_reset_hooks
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
##
|
2012-11-29 01:52:18 -05:00
|
|
|
# The list of hooks to be run before Gem::Uninstaller#uninstall does any
|
|
|
|
# work
|
2008-09-25 06:13:50 -04:00
|
|
|
|
|
|
|
attr_reader :pre_uninstall_hooks
|
2011-03-01 04:41:32 -05:00
|
|
|
end
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2009-06-09 17:38:59 -04:00
|
|
|
##
|
|
|
|
# Location of Marshal quick gemspecs on remote repositories
|
|
|
|
|
2008-06-17 18:04:18 -04:00
|
|
|
MARSHAL_SPEC_DIR = "quick/Marshal.#{Gem.marshal_version}/"
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2012-12-01 04:52:39 -05:00
|
|
|
autoload :ConfigFile, 'rubygems/config_file'
|
|
|
|
autoload :Dependency, 'rubygems/dependency'
|
|
|
|
autoload :DependencyList, 'rubygems/dependency_list'
|
2013-11-18 19:34:13 -05:00
|
|
|
autoload :DependencyResolver, 'rubygems/resolver'
|
2013-12-12 19:51:04 -05:00
|
|
|
autoload :Installer, 'rubygems/installer'
|
2015-09-08 18:46:43 -04:00
|
|
|
autoload :Licenses, 'rubygems/util/licenses'
|
2012-12-01 04:52:39 -05:00
|
|
|
autoload :PathSupport, 'rubygems/path_support'
|
|
|
|
autoload :Platform, 'rubygems/platform'
|
|
|
|
autoload :RequestSet, 'rubygems/request_set'
|
|
|
|
autoload :Requirement, 'rubygems/requirement'
|
2013-12-12 19:51:04 -05:00
|
|
|
autoload :Resolver, 'rubygems/resolver'
|
|
|
|
autoload :Source, 'rubygems/source'
|
2012-12-01 04:52:39 -05:00
|
|
|
autoload :SourceList, 'rubygems/source_list'
|
|
|
|
autoload :SpecFetcher, 'rubygems/spec_fetcher'
|
|
|
|
autoload :Specification, 'rubygems/specification'
|
|
|
|
autoload :Version, 'rubygems/version'
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
require "rubygems/specification"
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
require 'rubygems/exceptions'
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
# REFACTOR: This should be pulled out into some kind of hacks file.
|
2011-01-28 18:46:47 -05:00
|
|
|
gem_preluded = Gem::GEM_PRELUDE_SUCKAGE and defined? Gem
|
2011-01-18 19:08:49 -05:00
|
|
|
unless gem_preluded then # TODO: remove guard after 1.9.2 dropped
|
2008-06-17 18:04:18 -04:00
|
|
|
begin
|
2010-04-22 04:24:42 -04:00
|
|
|
##
|
2011-01-18 19:08:49 -05:00
|
|
|
# Defaults the operating system (or packager) wants to provide for RubyGems.
|
2010-04-22 04:24:42 -04:00
|
|
|
|
2011-01-18 19:08:49 -05:00
|
|
|
require 'rubygems/defaults/operating_system'
|
2008-06-17 18:04:18 -04:00
|
|
|
rescue LoadError
|
|
|
|
end
|
2008-09-25 06:13:50 -04:00
|
|
|
|
2011-01-18 19:08:49 -05:00
|
|
|
if defined?(RUBY_ENGINE) then
|
|
|
|
begin
|
|
|
|
##
|
2013-09-14 04:59:02 -04:00
|
|
|
# Defaults the Ruby implementation wants to provide for RubyGems
|
2010-07-20 14:30:46 -04:00
|
|
|
|
2011-01-18 19:08:49 -05:00
|
|
|
require "rubygems/defaults/#{RUBY_ENGINE}"
|
|
|
|
rescue LoadError
|
|
|
|
end
|
2010-07-20 14:30:46 -04:00
|
|
|
end
|
|
|
|
end
|
2010-07-07 11:40:52 -04:00
|
|
|
|
2011-01-18 19:08:49 -05:00
|
|
|
##
|
2012-11-29 01:52:18 -05:00
|
|
|
# Loads the default specs.
|
|
|
|
Gem::Specification.load_defaults
|
2010-02-21 21:52:35 -05:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
require 'rubygems/core_ext/kernel_gem'
|
|
|
|
require 'rubygems/core_ext/kernel_require'
|
2010-02-21 21:52:35 -05:00
|
|
|
|
2013-11-25 14:14:49 -05:00
|
|
|
Gem.use_gemdeps
|