Skip to content

Commit

Permalink
Fixes for 1.9 r15873.
Browse files Browse the repository at this point in the history
git-svn-id: http://rubygems.rubyforge.org/svn/trunk@1779 3d4018f9-ac1a-0410-99e9-8a154d859a19
  • Loading branch information
drbrain committed Jun 17, 2008
1 parent 6061482 commit 9fb09bc
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 81 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -9,6 +9,7 @@
Patch from ruby trunk by nobu.
* lib/*: Spelling cleanup. Patch from trunk by Evan Farrar.
* test/*: Fixes for win32 test failures reported by Luis Lavena.
* util/gem_prelude.rb: Only remove methods added by gem_prelude.rb.

2008-06-16 Eric Hodel <drbrain@segment7.net>

Expand Down
6 changes: 5 additions & 1 deletion lib/rubygems/commands/install_command.rb
Expand Up @@ -50,7 +50,11 @@ def execute

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],
Expand Down
8 changes: 4 additions & 4 deletions lib/rubygems/commands/query_command.rb
Expand Up @@ -131,18 +131,18 @@ def output_query_results(spec_tuples)
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
Expand All @@ -154,7 +154,7 @@ def output_query_results(spec_tuples)
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

Expand Down
8 changes: 4 additions & 4 deletions lib/rubygems/commands/sources_command.rb
Expand Up @@ -111,10 +111,10 @@ def execute
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
Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/dependency_installer.rb
Expand Up @@ -133,7 +133,7 @@ def gather_dependencies
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
Expand Down
8 changes: 3 additions & 5 deletions lib/rubygems/source_index.rb
Expand Up @@ -300,14 +300,12 @@ def outdated
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'
Expand All @@ -320,7 +318,7 @@ def outdated

latest = remotes.sort.last

outdateds << name if latest and local.version < latest
outdateds << local.name if latest and local.version < latest
end

outdateds
Expand Down
6 changes: 3 additions & 3 deletions lib/rubygems/validator.rb
Expand Up @@ -42,7 +42,7 @@ def verify_gem(gem_data)
#
# 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
Expand Down Expand Up @@ -91,15 +91,15 @@ def alien

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
installed_files.delete remove_leading_dot_dir(entry['path'])

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")
Expand Down
9 changes: 2 additions & 7 deletions test/test_gem_source_index.rb
Expand Up @@ -128,13 +128,8 @@ def test_self_load_specification_syntax_error

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
Expand Down
2 changes: 1 addition & 1 deletion test/test_gem_validator.rb
Expand Up @@ -20,7 +20,7 @@ def setup

def test_verify_gem_file
gem_file = File.join @tempdir, 'simple_gem.gem'
File.open gem_file, 'wb' do |fp| fp.write @simple_gem end
File.open gem_file, 'wb:ascii-8bit' do |fp| fp.write @simple_gem end

assert_equal nil, @validator.verify_gem_file(gem_file)
end
Expand Down
102 changes: 47 additions & 55 deletions util/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
Expand All @@ -28,73 +24,69 @@ module Gem
: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 = {}
Expand Down

0 comments on commit 9fb09bc

Please sign in to comment.