summaryrefslogtreecommitdiff
path: root/gem_prelude.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-09 21:38:59 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-09 21:38:59 +0000
commit31c94ffeb5f09d09ac2c86fc9e6614e38251a43d (patch)
tree10e44506238c7af3d7c9d822111996731726e38d /gem_prelude.rb
parenta6afbaeb3be396c0fdea3b9077d9256c59edcfca (diff)
Update to RubyGems 1.3.4 r2223
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gem_prelude.rb')
-rw-r--r--gem_prelude.rb126
1 files changed, 76 insertions, 50 deletions
diff --git a/gem_prelude.rb b/gem_prelude.rb
index 65f3481fea..aa874c88ea 100644
--- a/gem_prelude.rb
+++ b/gem_prelude.rb
@@ -2,12 +2,15 @@
# vim: filetype=ruby
# THIS FILE WAS AUTOGENERATED, DO NOT EDIT
-# NOTICE: Ruby is during initialization here.
-# * Encoding.default_external does not reflects -E.
-# * Should not expect Encoding.default_internal.
-# * Locale encoding is available.
+# NOTICE: Ruby is during initialization here.
+# * Encoding.default_external does not reflects -E.
+# * Should not expect Encoding.default_internal.
+# * Locale encoding is available.
+
if defined?(Gem) then
+ # :stopdoc:
+
module Kernel
def gem(gem_name, *version_requirements)
@@ -18,20 +21,17 @@ if defined?(Gem) then
module Gem
- class LoadError < ::LoadError
- end
-
ConfigMap = {
- :sitedir => RbConfig::CONFIG["sitedir"],
- :ruby_version => RbConfig::CONFIG["ruby_version"],
- :rubylibprefix => RbConfig::CONFIG["rubylibprefix"],
- :libdir => RbConfig::CONFIG["libdir"],
- :sitelibdir => RbConfig::CONFIG["sitelibdir"],
- :arch => RbConfig::CONFIG["arch"],
- :bindir => RbConfig::CONFIG["bindir"],
- :EXEEXT => RbConfig::CONFIG["EXEEXT"],
- :RUBY_SO_NAME => RbConfig::CONFIG["RUBY_SO_NAME"],
- :ruby_install_name => RbConfig::CONFIG["ruby_install_name"]
+ :EXEEXT => RbConfig::CONFIG["EXEEXT"],
+ :RUBY_SO_NAME => RbConfig::CONFIG["RUBY_SO_NAME"],
+ :arch => RbConfig::CONFIG["arch"],
+ :bindir => RbConfig::CONFIG["bindir"],
+ :libdir => RbConfig::CONFIG["libdir"],
+ :ruby_install_name => RbConfig::CONFIG["ruby_install_name"],
+ :ruby_version => RbConfig::CONFIG["ruby_version"],
+ :rubylibprefix => RbConfig::CONFIG["rubylibprefix"],
+ :sitedir => RbConfig::CONFIG["sitedir"],
+ :sitelibdir => RbConfig::CONFIG["sitelibdir"],
}
def self.dir
@@ -67,24 +67,30 @@ if defined?(Gem) then
end
def self.set_home(home)
+ home = home.gsub File::ALT_SEPARATOR, File::SEPARATOR if File::ALT_SEPARATOR
@gem_home = home
- ensure_gem_subdirectories(@gem_home)
end
def self.set_paths(gpaths)
if gpaths
@gem_path = gpaths.split(File::PATH_SEPARATOR)
+
+ if File::ALT_SEPARATOR then
+ @gem_path.map! do |path|
+ path.gsub File::ALT_SEPARATOR, File::SEPARATOR
+ end
+ end
+
@gem_path << Gem.dir
else
+ # TODO: should this be Gem.default_path instead?
@gem_path = [Gem.dir]
end
- @gem_path.uniq!
- @gem_path.each do |gp| ensure_gem_subdirectories(gp) end
- end
- def self.ensure_gem_subdirectories(path)
+ @gem_path.uniq!
end
+ # begin rubygems/defaults
@post_install_hooks ||= []
@post_uninstall_hooks ||= []
@@ -106,8 +112,13 @@ if defined?(Gem) then
if defined? RUBY_FRAMEWORK_VERSION then
File.join File.dirname(ConfigMap[:sitedir]), 'Gems',
ConfigMap[:ruby_version]
+ # 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])
else
- ConfigMap[:sitelibdir].sub(%r'/site_ruby/(?=[^/]+)', '/gems/')
+ File.join(ConfigMap[:libdir], ruby_engine, 'gems',
+ ConfigMap[:ruby_version])
end
end
@@ -123,15 +134,25 @@ if defined?(Gem) then
# Default gem load path
def self.default_path
- [user_dir, default_dir]
+ if File.exist?(Gem.user_home)
+ [user_dir, default_dir]
+ else
+ [default_dir]
+ end
end
##
# Deduce Ruby's --program-prefix and --program-suffix from its install name
def self.default_exec_format
- baseruby = ConfigMap[:BASERUBY] || 'ruby'
- ConfigMap[:RUBY_INSTALL_NAME].sub(baseruby, '%s') rescue '%s'
+ 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
end
##
@@ -171,7 +192,9 @@ if defined?(Gem) then
end
+ # end rubygems/defaults
+ ##
# Methods before this line will be removed when QuickLoader is replaced
# with the real RubyGems
@@ -179,7 +202,7 @@ if defined?(Gem) then
begin
verbose, debug = $VERBOSE, $DEBUG
- $DEBUG = $VERBOSE = nil
+ $VERBOSE = $DEBUG = nil
begin
require 'rubygems/defaults/operating_system'
@@ -226,14 +249,14 @@ if defined?(Gem) then
def push_gem_version_on_load_path(gem_name, *version_requirements)
if version_requirements.empty?
- unless GemPaths.has_key?(gem_name)
- raise Gem::LoadError.new("Could not find RubyGem #{gem_name} (>= 0)\n")
+ unless GemPaths.has_key?(gem_name) then
+ raise Gem::LoadError, "Could not find RubyGem #{gem_name} (>= 0)\n"
end
# highest version gems already active
return false
else
- if version_requirements.length > 1
+ if version_requirements.length > 1 then
QuickLoader.load_full_rubygems_library
return gem(gem_name, *version_requirements)
end
@@ -241,26 +264,24 @@ if defined?(Gem) then
requirement, version = version_requirements[0].split
requirement.strip!
- if loaded_version = GemVersions[gem_name]
+ if loaded_version = GemVersions[gem_name] then
case requirement
- when ">", ">="
- if (loaded_version <=> Gem.calculate_integers_for_gem_version(version)) >= 0
- return false
- end
- when "~>"
- required_version = Gem.calculate_integers_for_gem_version(version)
- if (loaded_version[0] == required_version[0])
- return false
- end
+ when ">", ">=" then
+ return false if
+ (loaded_version <=> Gem.integers_for(version)) >= 0
+ when "~>" then
+ required_version = Gem.integers_for version
+
+ return false if loaded_version.first == required_version.first
end
end
QuickLoader.load_full_rubygems_library
- gem(gem_name, *version_requirements)
+ gem gem_name, *version_requirements
end
end
- def calculate_integers_for_gem_version(gem_version)
+ def integers_for(gem_version)
numbers = gem_version.split(".").collect {|n| n.to_i}
numbers.pop while numbers.last == 0
numbers << 0 if numbers.empty?
@@ -270,16 +291,20 @@ if defined?(Gem) then
def push_all_highest_version_gems_on_load_path
Gem.path.each do |path|
gems_directory = File.join(path, "gems")
- if File.exist?(gems_directory)
+
+ if File.exist?(gems_directory) then
Dir.entries(gems_directory).each do |gem_directory_name|
next if gem_directory_name == "." || gem_directory_name == ".."
+
dash = gem_directory_name.rindex("-")
next if dash.nil?
+
gem_name = gem_directory_name[0...dash]
current_version = GemVersions[gem_name]
- new_version = calculate_integers_for_gem_version(gem_directory_name[dash+1..-1])
- if current_version
- if (current_version <=> new_version) == -1
+ new_version = integers_for(gem_directory_name[dash+1..-1])
+
+ if current_version then
+ if (current_version <=> new_version) == -1 then
GemVersions[gem_name] = new_version
GemPaths[gem_name] = File.join(gems_directory, gem_directory_name)
end
@@ -309,7 +334,7 @@ if defined?(Gem) then
# "tag" the first require_path inserted into the $LOAD_PATH to enable
# indexing correctly with rubygems proper when it inserts an explicitly
# gem version
- unless require_paths.empty?
+ unless require_paths.empty? then
require_paths.first.instance_variable_set(:@gem_prelude_index, true)
end
# gem directories must come after -I and ENV['RUBYLIB']
@@ -318,8 +343,9 @@ if defined?(Gem) then
def const_missing(constant)
QuickLoader.load_full_rubygems_library
- if Gem.const_defined?(constant)
- Gem.const_get(constant)
+
+ if Gem.const_defined?(constant) then
+ Gem.const_get constant
else
super
end
@@ -338,7 +364,7 @@ if defined?(Gem) then
begin
Gem.push_all_highest_version_gems_on_load_path
- $" << File.join(Gem::ConfigMap[:rubylibprefix],
+ $" << File.join(Gem::ConfigMap[:rubylibprefix],
Gem::ConfigMap[:ruby_version], "rubygems.rb")
rescue Exception => e
puts "Error loading gem paths on load path in gem_prelude"