2007-12-20 03:39:12 -05:00
|
|
|
module Gem
|
2012-11-29 01:52:18 -05:00
|
|
|
DEFAULT_HOST = "https://rubygems.org"
|
2011-05-31 23:45:05 -04:00
|
|
|
|
2008-10-25 18:58:43 -04:00
|
|
|
@post_install_hooks ||= []
|
2012-11-29 01:52:18 -05:00
|
|
|
@done_installing_hooks ||= []
|
2008-10-25 18:58:43 -04:00
|
|
|
@post_uninstall_hooks ||= []
|
|
|
|
@pre_uninstall_hooks ||= []
|
|
|
|
@pre_install_hooks ||= []
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
##
|
|
|
|
# An Array of the default sources that come with RubyGems
|
|
|
|
|
2007-12-20 03:39:12 -05:00
|
|
|
def self.default_sources
|
2013-02-28 17:25:55 -05:00
|
|
|
%w[https://rubygems.org/]
|
2007-12-20 03:39:12 -05:00
|
|
|
end
|
|
|
|
|
2013-09-14 04:59:02 -04:00
|
|
|
##
|
|
|
|
# Default spec directory path to be used if an alternate value is not
|
|
|
|
# specified in the environment
|
|
|
|
|
|
|
|
def self.default_spec_cache_dir
|
|
|
|
File.join Gem.user_home, '.gem', 'specs'
|
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
##
|
2007-12-20 03:39:12 -05:00
|
|
|
# Default home directory path to be used if an alternate value is not
|
2008-09-25 06:13:50 -04:00
|
|
|
# specified in the environment
|
|
|
|
|
2007-12-20 03:39:12 -05:00
|
|
|
def self.default_dir
|
2011-05-31 23:45:05 -04:00
|
|
|
path = if defined? RUBY_FRAMEWORK_VERSION then
|
|
|
|
[
|
2014-01-06 20:19:28 -05:00
|
|
|
File.dirname(RbConfig::CONFIG['sitedir']),
|
2011-05-31 23:45:05 -04:00
|
|
|
'Gems',
|
2014-01-06 20:19:28 -05:00
|
|
|
RbConfig::CONFIG['ruby_version']
|
2011-05-31 23:45:05 -04:00
|
|
|
]
|
2014-01-06 20:19:28 -05:00
|
|
|
elsif RbConfig::CONFIG['rubylibprefix'] then
|
2011-05-31 23:45:05 -04:00
|
|
|
[
|
2014-01-06 20:19:28 -05:00
|
|
|
RbConfig::CONFIG['rubylibprefix'],
|
2011-05-31 23:45:05 -04:00
|
|
|
'gems',
|
2014-01-06 20:19:28 -05:00
|
|
|
RbConfig::CONFIG['ruby_version']
|
2011-05-31 23:45:05 -04:00
|
|
|
]
|
|
|
|
else
|
|
|
|
[
|
2014-01-06 20:19:28 -05:00
|
|
|
RbConfig::CONFIG['libdir'],
|
2011-05-31 23:45:05 -04:00
|
|
|
ruby_engine,
|
|
|
|
'gems',
|
2014-01-06 20:19:28 -05:00
|
|
|
RbConfig::CONFIG['ruby_version']
|
2011-05-31 23:45:05 -04:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
@default_dir ||= File.join(*path)
|
2007-12-20 03:39:12 -05:00
|
|
|
end
|
|
|
|
|
2013-12-12 19:51:04 -05:00
|
|
|
##
|
|
|
|
# Returns binary extensions dir for specified RubyGems base dir or nil
|
|
|
|
# if such directory cannot be determined.
|
|
|
|
#
|
|
|
|
# By default, the binary extensions are located side by side with their
|
|
|
|
# Ruby counterparts, therefore nil is returned
|
|
|
|
|
|
|
|
def self.default_ext_dir_for base_dir
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2012-04-17 20:04:12 -04:00
|
|
|
##
|
|
|
|
# Paths where RubyGems' .rb files and bin files are installed
|
|
|
|
|
|
|
|
def self.default_rubygems_dirs
|
|
|
|
nil # default to standard layout
|
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
##
|
|
|
|
# Path for gems in the user's home directory
|
|
|
|
|
|
|
|
def self.user_dir
|
2013-07-08 18:41:03 -04:00
|
|
|
parts = [Gem.user_home, '.gem', ruby_engine]
|
2014-01-06 20:19:28 -05:00
|
|
|
parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty?
|
2013-07-08 18:41:03 -04:00
|
|
|
File.join parts
|
2008-09-25 06:13:50 -04:00
|
|
|
end
|
|
|
|
|
2012-11-29 19:23:15 -05:00
|
|
|
##
|
|
|
|
# How String Gem paths should be split. Overridable for esoteric platforms.
|
|
|
|
|
|
|
|
def self.path_separator
|
|
|
|
File::PATH_SEPARATOR
|
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
##
|
|
|
|
# Default gem load path
|
|
|
|
|
2007-12-20 03:39:12 -05:00
|
|
|
def self.default_path
|
2012-11-29 01:52:18 -05:00
|
|
|
if Gem.user_home && File.exist?(Gem.user_home) then
|
2009-06-09 17:38:59 -04:00
|
|
|
[user_dir, default_dir]
|
|
|
|
else
|
|
|
|
[default_dir]
|
|
|
|
end
|
2007-12-20 03:39:12 -05:00
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
##
|
|
|
|
# Deduce Ruby's --program-prefix and --program-suffix from its install name
|
|
|
|
|
2007-12-20 03:39:12 -05:00
|
|
|
def self.default_exec_format
|
2014-01-06 20:19:28 -05:00
|
|
|
exec_format = RbConfig::CONFIG['ruby_install_name'].sub('ruby', '%s') rescue '%s'
|
2009-06-09 17:38:59 -04:00
|
|
|
|
|
|
|
unless exec_format =~ /%s/ then
|
|
|
|
raise Gem::Exception,
|
|
|
|
"[BUG] invalid exec_format #{exec_format.inspect}, no %s"
|
|
|
|
end
|
|
|
|
|
|
|
|
exec_format
|
2007-12-20 03:39:12 -05:00
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
##
|
2007-12-20 03:39:12 -05:00
|
|
|
# The default directory for binaries
|
2008-09-25 06:13:50 -04:00
|
|
|
|
2007-12-20 03:39:12 -05:00
|
|
|
def self.default_bindir
|
2008-03-31 18:40:06 -04:00
|
|
|
if defined? RUBY_FRAMEWORK_VERSION then # mac framework support
|
|
|
|
'/usr/bin'
|
|
|
|
else # generic install
|
2014-01-06 20:19:28 -05:00
|
|
|
RbConfig::CONFIG['bindir']
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
2007-12-20 03:39:12 -05:00
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
##
|
|
|
|
# A wrapper around RUBY_ENGINE const that may not be defined
|
|
|
|
|
|
|
|
def self.ruby_engine
|
|
|
|
if defined? RUBY_ENGINE then
|
|
|
|
RUBY_ENGINE
|
|
|
|
else
|
|
|
|
'ruby'
|
|
|
|
end
|
|
|
|
end
|
2013-06-04 17:54:58 -04:00
|
|
|
|
|
|
|
##
|
|
|
|
# The default signing key path
|
|
|
|
|
|
|
|
def self.default_key_path
|
|
|
|
File.join Gem.user_home, ".gem", "gem-private_key.pem"
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# The default signing certificate chain path
|
|
|
|
|
|
|
|
def self.default_cert_path
|
|
|
|
File.join Gem.user_home, ".gem", "gem-public_cert.pem"
|
|
|
|
end
|
2013-09-14 04:59:02 -04:00
|
|
|
|
|
|
|
##
|
|
|
|
# Whether to expect full paths in default gems - true for non-MRI
|
|
|
|
# ruby implementations
|
|
|
|
def self.default_gems_use_full_paths?
|
|
|
|
ruby_engine != 'ruby'
|
|
|
|
end
|
2013-12-16 15:18:29 -05:00
|
|
|
|
|
|
|
##
|
|
|
|
# Install extensions into lib as well as into the extension directory.
|
|
|
|
|
|
|
|
def self.install_extension_in_lib # :nodoc:
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2007-12-20 03:39:12 -05:00
|
|
|
end
|