summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-17 23:59:31 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-17 23:59:31 +0000
commit215fbc639fc63d4300a91ae4c8e30865f6a03f3c (patch)
tree13f0bc33bcdd0dca931c0af17a6ac1b70dd282f8
parent9d4f37f51fb2ffdef5e318afb3cb81516dcba4f7 (diff)
Fix RubyGems for 1.9, r1780
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--gem_prelude.rb102
-rw-r--r--lib/rubygems/commands/install_command.rb6
-rw-r--r--lib/rubygems/commands/query_command.rb8
-rw-r--r--lib/rubygems/commands/sources_command.rb8
-rw-r--r--lib/rubygems/dependency_installer.rb2
-rw-r--r--lib/rubygems/rubygems_version.rb2
-rw-r--r--lib/rubygems/source_index.rb8
-rwxr-xr-xlib/rubygems/validator.rb6
-rw-r--r--test/rubygems/test_gem_source_index.rb9
10 files changed, 77 insertions, 81 deletions
diff --git a/ChangeLog b/ChangeLog
index 1809b795522..292514277ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Jun 18 08:58:16 2008 Eric Hodel <drbrain@segment7.net>
+
+ * lib/rubygems/*: Fix errors for 1.9.
+
+ * gem_prelude.rb: Only remove methods from gem_prelude.rb when
+ loading real RubyGems.
+
Wed Jun 18 07:03:30 2008 Eric Hodel <drbrain@egment7.net>
* lib/rubygems/*: Update to RubyGems r1778 (pre 1.2).
diff --git a/gem_prelude.rb b/gem_prelude.rb
index ec9f1f4f334..28bbd8372fb 100644
--- a/gem_prelude.rb
+++ b/gem_prelude.rb
@@ -1,9 +1,5 @@
# depends on: array.rb dir.rb env.rb file.rb hash.rb module.rb regexp.rb
-# empty gem_prelude.rb
-#
-# p defined?(Gem)
-
if defined?(Gem) then
module Kernel
@@ -28,73 +24,69 @@ if defined?(Gem) then
:ruby_install_name => RbConfig::CONFIG["ruby_install_name"]
}
- class << self
-
- def default_dir
- if defined? RUBY_FRAMEWORK_VERSION
- return File.join(File.dirname(ConfigMap[:sitedir]), "Gems")
- else
- File.join(ConfigMap[:libdir], 'ruby', 'gems', ConfigMap[:ruby_version])
- end
- end
-
- def dir
- @gem_home ||= nil
- set_home(ENV['GEM_HOME'] || default_dir) unless @gem_home
- @gem_home
+ def self.default_dir
+ if defined? RUBY_FRAMEWORK_VERSION
+ return File.join(File.dirname(ConfigMap[:sitedir]), "Gems")
+ else
+ File.join(ConfigMap[:libdir], 'ruby', 'gems', ConfigMap[:ruby_version])
end
+ end
- def path
- @gem_path ||= nil
- unless @gem_path
- paths = [ENV['GEM_PATH']]
- paths << APPLE_GEM_HOME if defined? APPLE_GEM_HOME
- set_paths(paths.compact.join(File::PATH_SEPARATOR))
- end
- @gem_path
- end
+ def self.dir
+ @gem_home ||= nil
+ set_home(ENV['GEM_HOME'] || default_dir) unless @gem_home
+ @gem_home
+ end
- # Set the Gem home directory (as reported by +dir+).
- def set_home(home)
- @gem_home = home
- ensure_gem_subdirectories(@gem_home)
+ def self.path
+ @gem_path ||= nil
+ unless @gem_path
+ paths = [ENV['GEM_PATH']]
+ paths << APPLE_GEM_HOME if defined? APPLE_GEM_HOME
+ set_paths(paths.compact.join(File::PATH_SEPARATOR))
end
+ @gem_path
+ end
- def set_paths(gpaths)
- if gpaths
- @gem_path = gpaths.split(File::PATH_SEPARATOR)
- @gem_path << Gem.dir
- else
- @gem_path = [Gem.dir]
- end
- @gem_path.uniq!
- @gem_path.each do |gp| ensure_gem_subdirectories(gp) end
- end
+ # Set the Gem home directory (as reported by +dir+).
+ def self.set_home(home)
+ @gem_home = home
+ ensure_gem_subdirectories(@gem_home)
+ end
- def ensure_gem_subdirectories(path)
+ def self.set_paths(gpaths)
+ if gpaths
+ @gem_path = gpaths.split(File::PATH_SEPARATOR)
+ @gem_path << Gem.dir
+ else
+ @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)
end
+ GEM_PRELUDE_METHODS = Gem.methods(false)
+
module QuickLoader
- class << self
- def load_full_rubygems_library
- class << Gem
- Gem.methods(false).each do |method_name|
- undef_method method_name
- end
+ def self.load_full_rubygems_library
+ class << Gem
+ Gem::GEM_PRELUDE_METHODS.each do |method_name|
+ undef_method method_name
end
+ end
- Kernel.module_eval do
- undef_method :gem if method_defined? :gem
- end
+ Kernel.module_eval do
+ undef_method :gem if method_defined? :gem
+ end
- $".delete File.join(Gem::ConfigMap[:libdir], 'ruby',
- Gem::ConfigMap[:ruby_version], 'rubygems.rb')
+ $".delete File.join(Gem::ConfigMap[:libdir], 'ruby',
+ Gem::ConfigMap[:ruby_version], 'rubygems.rb')
- require 'rubygems'
- end
+ require 'rubygems'
end
GemPaths = {}
diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb
index 48cd3869f95..dad19380ea4 100644
--- a/lib/rubygems/commands/install_command.rb
+++ b/lib/rubygems/commands/install_command.rb
@@ -50,7 +50,11 @@ class Gem::Commands::InstallCommand < Gem::Command
installed_gems = []
- ENV['GEM_PATH'] = options[:install_dir] # HACK what does this do?
+ if options[:install_dir].nil? and RUBY_VERSION > '1.9' then
+ ENV.delete 'GEM_PATH'
+ else
+ ENV['GEM_PATH'] = options[:install_dir] # HACK what does this do?
+ end
install_options = {
:env_shebang => options[:env_shebang],
diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb
index cc81f3f07ed..f4d6120bcd0 100644
--- a/lib/rubygems/commands/query_command.rb
+++ b/lib/rubygems/commands/query_command.rb
@@ -131,18 +131,18 @@ class Gem::Commands::QueryCommand < Gem::Command
versions[spec_tuple.first] << [spec_tuple, source_uri]
end
- versions = versions.sort_by do |(name,),|
+ versions = versions.sort_by do |(name,_),_|
name.downcase
end
versions.each do |gem_name, matching_tuples|
- matching_tuples = matching_tuples.sort_by do |(name, version,),|
+ matching_tuples = matching_tuples.sort_by do |(name, version,_),_|
version
end.reverse
seen = {}
- matching_tuples.delete_if do |(name, version,),|
+ matching_tuples.delete_if do |(name, version,_),_|
if seen[version] then
true
else
@@ -154,7 +154,7 @@ class Gem::Commands::QueryCommand < Gem::Command
entry = gem_name.dup
if options[:versions] then
- versions = matching_tuples.map { |(name, version,),| version }.uniq
+ versions = matching_tuples.map { |(name, version,_),_| version }.uniq
entry << " (#{versions.join ', '})"
end
diff --git a/lib/rubygems/commands/sources_command.rb b/lib/rubygems/commands/sources_command.rb
index f45438463c6..9aabb77cb12 100644
--- a/lib/rubygems/commands/sources_command.rb
+++ b/lib/rubygems/commands/sources_command.rb
@@ -111,10 +111,10 @@ Will cause RubyGems to revert to legacy indexes, degrading performance.
fetcher = Gem::SpecFetcher.fetcher
if fetcher.legacy_repos.empty? then
- Gem.sources.each do |source_uri|
- source_uri = URI.parse source_uri
- fetcher.load_specs source_uri, 'specs'
- fetcher.load_specs source_uri, 'latest_specs'
+ Gem.sources.each do |update_uri|
+ update_uri = URI.parse update_uri
+ fetcher.load_specs update_uri, 'specs'
+ fetcher.load_specs update_uri, 'latest_specs'
end
else
Gem::SourceInfoCache.cache true
diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb
index b849d37245f..8636599fbc2 100644
--- a/lib/rubygems/dependency_installer.rb
+++ b/lib/rubygems/dependency_installer.rb
@@ -133,7 +133,7 @@ class Gem::DependencyInstaller
deps.each do |dep|
results = find_gems_with_sources(dep).reverse
- results.reject! do |spec,|
+ results.reject! do
@source_index.any? do |_, installed_spec|
dep.name == installed_spec.name and
dep.version_requirements.satisfied_by? installed_spec.version
diff --git a/lib/rubygems/rubygems_version.rb b/lib/rubygems/rubygems_version.rb
index d4d4af05587..453f9b57b60 100644
--- a/lib/rubygems/rubygems_version.rb
+++ b/lib/rubygems/rubygems_version.rb
@@ -2,5 +2,5 @@
# This file is auto-generated by build scripts.
# See: rake update_version
module Gem
- RubyGemsVersion = '1.1.1.1778'
+ RubyGemsVersion = '1.1.1'
end
diff --git a/lib/rubygems/source_index.rb b/lib/rubygems/source_index.rb
index b940b83cf87..1eefd8c1490 100644
--- a/lib/rubygems/source_index.rb
+++ b/lib/rubygems/source_index.rb
@@ -300,14 +300,12 @@ class Gem::SourceIndex
outdateds = []
latest_specs.each do |local|
- name = local.name
-
- dependency = Gem::Dependency.new name, ">= #{local.version}"
+ dependency = Gem::Dependency.new local.name, ">= #{local.version}"
begin
fetcher = Gem::SpecFetcher.fetcher
remotes = fetcher.find_matching dependency
- remotes = remotes.map { |(name, version,),| version }
+ remotes = remotes.map { |(name, version,_),_| version }
rescue Gem::RemoteFetcher::FetchError => e
raise unless fetcher.warn_legacy e do
require 'rubygems/source_info_cache'
@@ -320,7 +318,7 @@ class Gem::SourceIndex
latest = remotes.sort.last
- outdateds << name if latest and local.version < latest
+ outdateds << local.name if latest and local.version < latest
end
outdateds
diff --git a/lib/rubygems/validator.rb b/lib/rubygems/validator.rb
index 41c457c3cfc..8aaaa5a413a 100755
--- a/lib/rubygems/validator.rb
+++ b/lib/rubygems/validator.rb
@@ -42,7 +42,7 @@ module Gem
#
# gem_path:: [String] Path to gem file
def verify_gem_file(gem_path)
- File.open gem_path, 'rb' do |file|
+ open gem_path, Gem.binary_mode do |file|
gem_data = file.read
verify_gem gem_data
end
@@ -91,7 +91,7 @@ module Gem
begin
verify_gem_file(gem_path)
- File.open(gem_path, 'rb') do |file|
+ open gem_path, Gem.binary_mode do |file|
format = Gem::Format.from_file_by_path(gem_path)
format.file_entries.each do |entry, data|
# Found this file. Delete it from list
@@ -99,7 +99,7 @@ module Gem
next unless data # HACK `gem check -a mkrf`
- File.open(File.join(gem_directory, entry['path']), 'rb') do |f|
+ open File.join(gem_directory, entry['path']), Gem.binary_mode do |f|
unless Gem::MD5.hexdigest(f.read).to_s ==
Gem::MD5.hexdigest(data).to_s then
errors[gem_name] << ErrorData.new(entry['path'], "installed file doesn't match original from gem")
diff --git a/test/rubygems/test_gem_source_index.rb b/test/rubygems/test_gem_source_index.rb
index adb9037caa1..263826759ab 100644
--- a/test/rubygems/test_gem_source_index.rb
+++ b/test/rubygems/test_gem_source_index.rb
@@ -128,13 +128,8 @@ WARNING: Invalid .gemspec format in '#{spec_file}'
assert_equal '', @ui.output
- expected = <<-EOF
-WARNING: compile error
-#{spec_file}:1: syntax error, unexpected $end
-WARNING: 1 +
- EOF
-
- assert_equal expected, @ui.error
+ assert_match(/syntax error/, @ui.error)
+ assert_match(/1 \+/, @ui.error)
end
def test_self_load_specification_system_exit