2007-12-20 03:39:12 -05:00
|
|
|
module Gem
|
|
|
|
|
2008-10-25 18:58:43 -04:00
|
|
|
@post_install_hooks ||= []
|
|
|
|
@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
|
2008-06-17 18:04:18 -04:00
|
|
|
%w[http://gems.rubyforge.org/]
|
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
|
|
|
# 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
|
|
|
|
if defined? RUBY_FRAMEWORK_VERSION then
|
|
|
|
File.join File.dirname(ConfigMap[:sitedir]), 'Gems',
|
|
|
|
ConfigMap[:ruby_version]
|
2009-06-09 17:38:59 -04:00
|
|
|
# 1.9.2dev reverted to 1.8 style path
|
|
|
|
elsif RUBY_VERSION > '1.9' and RUBY_VERSION < '1.9.2' then
|
|
|
|
File.join(ConfigMap[:libdir], ConfigMap[:ruby_install_name], 'gems',
|
|
|
|
ConfigMap[:ruby_version])
|
2008-10-31 18:27:35 -04:00
|
|
|
else
|
2009-06-09 17:38:59 -04:00
|
|
|
File.join(ConfigMap[:libdir], ruby_engine, 'gems',
|
|
|
|
ConfigMap[:ruby_version])
|
2007-12-20 03:39:12 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
##
|
|
|
|
# Path for gems in the user's home directory
|
|
|
|
|
|
|
|
def self.user_dir
|
|
|
|
File.join(Gem.user_home, '.gem', ruby_engine,
|
|
|
|
ConfigMap[:ruby_version])
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Default gem load path
|
|
|
|
|
2007-12-20 03:39:12 -05:00
|
|
|
def self.default_path
|
2009-06-09 17:38:59 -04:00
|
|
|
if File.exist?(Gem.user_home)
|
|
|
|
[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
|
2009-06-09 17:38:59 -04:00
|
|
|
exec_format = ConfigMap[:ruby_install_name].sub('ruby', '%s') rescue '%s'
|
|
|
|
|
|
|
|
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
|
|
|
|
ConfigMap[:bindir]
|
|
|
|
end
|
2007-12-20 03:39:12 -05:00
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
##
|
|
|
|
# The default system-wide source info cache directory
|
|
|
|
|
2007-12-20 03:39:12 -05:00
|
|
|
def self.default_system_source_cache_dir
|
|
|
|
File.join Gem.dir, 'source_cache'
|
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
##
|
|
|
|
# The default user-specific source info cache directory
|
|
|
|
|
2007-12-20 03:39:12 -05:00
|
|
|
def self.default_user_source_cache_dir
|
|
|
|
File.join Gem.user_home, '.gem', 'source_cache'
|
|
|
|
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
|
|
|
|
|
2007-12-20 03:39:12 -05:00
|
|
|
end
|
|
|
|
|