Permalink
Browse files

Fix indexer for gems with platform of empty string.

git-svn-id: http://rubygems.rubyforge.org/svn/trunk@1821 3d4018f9-ac1a-0410-99e9-8a154d859a19
  • Loading branch information...
1 parent ffc8523 commit df3bb81a2a8a9aea95caa1df65cb34a887812478 drbrain committed Jun 25, 2008
Showing with 60 additions and 9 deletions.
  1. +7 −0 ChangeLog
  2. +15 −6 lib/rubygems/indexer.rb
  3. +3 −2 lib/rubygems/installer.rb
  4. +35 −1 test/test_gem_indexer.rb
View
@@ -1,4 +1,11 @@
# -*- coding: utf-8 -*-
+2008-06-24 Eric Hodel <drbrain@segment7.net>
+
+ * lib/rubygems/remote_fetcher.rb: Cleanup to support
+ if-modified-since requests. pair: Ryan Davis
+ * lib/rubygems/indexer: Force platform to Gem::Platform::RUBY when
+ nil or blank. Fixes various uninstallable gems.
+
2008-06-24 Phil Hagelberg <technomancy@gmail.com>
* lib/rubygems/installer.rb: Fall back on ~/.gem if GEM_HOME is
View
@@ -116,7 +116,7 @@ def build_indicies(index)
open @specs_index, 'wb' do |io|
specs = index.sort.map do |_, spec|
platform = spec.original_platform
- platform = Gem::Platform::RUBY if platform.nil?
+ platform = Gem::Platform::RUBY if platform.nil? or platform.empty?
[spec.name, spec.version, platform]
end
@@ -129,7 +129,9 @@ def build_indicies(index)
open @latest_specs_index, 'wb' do |io|
specs = index.latest_specs.sort.map do |spec|
- [spec.name, spec.version, spec.original_platform]
+ platform = spec.original_platform
+ platform = Gem::Platform::RUBY if platform.nil? or platform.empty?
+ [spec.name, spec.version, platform]
end
specs = compact_specs specs
@@ -283,10 +285,7 @@ def gem_file_list
# Builds and installs indexicies.
def generate_index
- FileUtils.rm_rf @directory
- FileUtils.mkdir_p @directory, :mode => 0700
- FileUtils.mkdir_p @quick_marshal_dir
-
+ make_temp_directories
index = collect_specs
build_indicies index
install_indicies
@@ -322,6 +321,15 @@ def install_indicies
end
end
+ ##
+ # Make directories for index generation
+
+ def make_temp_directories
+ FileUtils.rm_rf @directory
+ FileUtils.mkdir_p @directory, :mode => 0700
+ FileUtils.mkdir_p @quick_marshal_dir
+ end
+
##
# Ensure +path+ and path with +extension+ are identical.
@@ -344,6 +352,7 @@ def sanitize(spec)
spec.description = sanitize_string(spec.description)
spec.post_install_message = sanitize_string(spec.post_install_message)
spec.authors = spec.authors.collect { |a| sanitize_string(a) }
+
spec
end
@@ -85,9 +85,10 @@ def initialize(gem, options={})
raise Gem::InstallError, "invalid gem format for #{@gem}"
end
- if !File.writable? @gem_home or
+ if not File.writable? @gem_home or
# TODO: Shouldn't have to test for existence of bindir; tests need it.
- (File.exist? Gem.bindir and !File.writable? Gem.bindir)
+ (@gem_home.to_s == Gem.dir and File.exist? Gem.bindir and
+ not File.writable? Gem.bindir)
if options[:user_install] == false # You explicitly don't want to use ~
raise Gem::FilePermissionError, @gem_home
elsif options[:user_install].nil?
View
@@ -21,7 +21,6 @@ def setup
util_make_gems
@d2_0 = quick_gem 'd', '2.0'
- write_file File.join(*%W[gems #{@d2_0.original_name} lib code.rb]) do end
util_build_gem @d2_0
gems = File.join(@tempdir, 'gems')
@@ -38,6 +37,41 @@ def test_initialize
@indexer.directory
end
+ def test_build_indicies
+ spec = quick_gem 'd', '2.0'
+ spec.instance_variable_set :@original_platform, ''
+
+ @indexer.make_temp_directories
+
+ index = Gem::SourceIndex.new
+ index.add_spec spec
+
+ use_ui @ui do
+ @indexer.build_indicies index
+ end
+
+ specs_path = File.join @indexer.directory, "specs.#{@marshal_version}"
+ specs_dump = Gem.read_binary specs_path
+ specs = Marshal.load specs_dump
+
+ expected = [
+ ['d', Gem::Version.new('2.0'), 'ruby'],
+ ]
+
+ assert_equal expected, specs, 'specs'
+
+ latest_specs_path = File.join @indexer.directory,
+ "latest_specs.#{@marshal_version}"
+ latest_specs_dump = Gem.read_binary latest_specs_path
+ latest_specs = Marshal.load latest_specs_dump
+
+ expected = [
+ ['d', Gem::Version.new('2.0'), 'ruby'],
+ ]
+
+ assert_equal expected, latest_specs, 'latest_specs'
+ end
+
def test_generate_index
use_ui @ui do
@indexer.generate_index

0 comments on commit df3bb81

Please sign in to comment.