1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Update to RubyGems 0.9.5

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2007-11-20 05:56:43 +00:00
parent cae4fb76dc
commit db74541efe
19 changed files with 275 additions and 95 deletions

View file

@ -1,3 +1,7 @@
Tue Nov 20 14:55:37 2007 Eric Hodel <drbrain@segment7.net>
* lib/rubygems*: Update to RubyGems 0.9.5.
Tue Nov 20 13:00:44 2007 NAKAMURA Usaku <usa@ruby-lang.org>
* include/ruby/win32.h win32/win32.c (rb_w32_pipe_exec): use dual fd

View file

@ -138,7 +138,14 @@ module Gem
##
# An Array of Regexps that match windows ruby platforms.
WIN_PATTERNS = [/mswin/i, /mingw/i, /bccwin/i, /wince/i]
WIN_PATTERNS = [
/bccwin/i,
/cygwin/i,
/djgpp/i,
/mingw/i,
/mswin/i,
/wince/i,
]
##
# Is this a windows platform?
@ -212,8 +219,7 @@ module Gem
install_dir.to_s == Gem.default_dir
if defined? RUBY_FRAMEWORK_VERSION then # mac framework support
File.join(File.dirname(Config::CONFIG["sitedir"]),
File.basename(Config::CONFIG["bindir"]))
'/usr/bin'
else # generic install
Config::CONFIG['bindir']
end
@ -225,7 +231,11 @@ module Gem
#
def path
@gem_path ||= nil
set_paths(ENV['GEM_PATH']) unless @gem_path
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
@ -519,7 +529,7 @@ module Gem
# not specified in the environment.
def default_dir
if defined? RUBY_FRAMEWORK_VERSION
return File.join(File.dirname(Config::CONFIG["sitedir"]), "Gems")
return File.join(File.dirname(Config::CONFIG["sitedir"]), "Gems", Config::CONFIG['ruby_version'])
else
File.join(Config::CONFIG['libdir'], 'ruby', 'gems', Config::CONFIG['ruby_version'])
end

View file

@ -124,12 +124,25 @@ class Gem::DependencyInstaller
case scheme
when 'http' then
unless File.exist? local_gem_path then
say "Downloading gem #{gem_file_name}" if
Gem.configuration.really_verbose
begin
say "Downloading gem #{gem_file_name}" if
Gem.configuration.really_verbose
remote_gem_path = source_uri + "gems/#{gem_file_name}"
remote_gem_path = source_uri + "gems/#{gem_file_name}"
gem = Gem::RemoteFetcher.fetcher.fetch_path remote_gem_path
gem = Gem::RemoteFetcher.fetcher.fetch_path remote_gem_path
rescue Gem::RemoteFetcher::FetchError
raise if spec.original_platform == spec.platform
alternate_name = "#{spec.name}-#{spec.version}-#{spec.original_platform}.gem"
say "Failed, downloading gem #{alternate_name}" if
Gem.configuration.really_verbose
remote_gem_path = source_uri + "gems/#{alternate_name}"
gem = Gem::RemoteFetcher.fetcher.fetch_path remote_gem_path
end
File.open local_gem_path, 'wb' do |fp|
fp.write gem

View file

@ -60,16 +60,8 @@ class Gem::Indexer
begin
spec = Gem::Format.from_file_by_path(gemfile).spec
original_name = if spec.platform == Gem::Platform::RUBY or
spec.platform.nil? then
spec.full_name
else
"#{spec.name}-#{spec.version}-#{spec.original_platform}"
end
unless gemfile =~ /\/#{Regexp.escape spec.full_name}.*\.gem\z/i or
gemfile =~ /\/#{Regexp.escape original_name}.*\.gem\z/i then
alert_warning "Skipping misnamed gem: #{gemfile} => #{spec.full_name} (#{original_name})"
unless gemfile =~ /\/#{Regexp.escape spec.original_name}.*\.gem\z/i then
alert_warning "Skipping misnamed gem: #{gemfile} => #{spec.full_name} (#{spec.original_name})"
next
end
@ -80,7 +72,7 @@ class Gem::Indexer
@quick_index.add spec
@marshal_index.add spec
progress.updated spec.full_name
progress.updated spec.original_name
rescue SignalException => e
alert_error "Recieved signal, exiting"

View file

@ -3,6 +3,15 @@ require 'rubygems/indexer'
# Construct the master Gem index file.
class Gem::Indexer::MarshalIndexBuilder < Gem::Indexer::MasterIndexBuilder
def end_index
@file.write @index.dump
gems = {}
index = Gem::SourceIndex.new
@index.each do |name, gemspec|
gems[gemspec.original_name] = gemspec
end
index.instance_variable_get(:@gems).replace gems
@file.write index.dump
end
end

View file

@ -10,7 +10,16 @@ class Gem::Indexer::MasterIndexBuilder < Gem::Indexer::AbstractIndexBuilder
def end_index
super
@file.puts @index.to_yaml
@file.puts "--- !ruby/object:#{@index.class}"
@file.puts "gems:"
gems = @index.sort_by { |name, gemspec| gemspec.sort_obj }
gems.each do |name, gemspec|
yaml = gemspec.to_yaml.gsub(/^/, ' ')
yaml = yaml.sub(/\A ---/, '') # there's a needed extra ' ' here
@file.print " #{gemspec.original_name}:"
@file.puts yaml
end
end
def cleanup

View file

@ -22,13 +22,13 @@ class Gem::Indexer::QuickIndexBuilder < Gem::Indexer::AbstractIndexBuilder
end
def add(spec)
@file.puts spec.full_name
@file.puts spec.original_name
add_yaml(spec)
add_marshal(spec)
end
def add_yaml(spec)
fn = File.join @directory, "#{spec.full_name}.gemspec.rz"
fn = File.join @directory, "#{spec.original_name}.gemspec.rz"
zipped = zip spec.to_yaml
File.open fn, "wb" do |gsfile| gsfile.write zipped end
end
@ -38,7 +38,7 @@ class Gem::Indexer::QuickIndexBuilder < Gem::Indexer::AbstractIndexBuilder
FileUtils.mkdir_p File.join(@directory, "Marshal.#{Gem.marshal_version}")
fn = File.join @directory, "Marshal.#{Gem.marshal_version}",
"#{spec.full_name}.gemspec.rz"
"#{spec.original_name}.gemspec.rz"
zipped = zip Marshal.dump(spec)
File.open fn, "wb" do |gsfile| gsfile.write zipped end

View file

@ -27,7 +27,7 @@ class Gem::Platform
def self.new(arch) # :nodoc:
case arch
when Gem::Platform::RUBY, nil then
when Gem::Platform::RUBY, nil, '' then
Gem::Platform::RUBY
else
super

View file

@ -2,5 +2,5 @@
# This file is auto-generated by build scripts.
# See: rake update_version
module Gem
RubyGemsVersion = '0.9.4.6'
RubyGemsVersion = '0.9.5'
end

View file

@ -243,14 +243,15 @@ module Gem
@summary,
@required_ruby_version,
@required_rubygems_version,
@new_platform,
@original_platform,
@dependencies,
@rubyforge_project,
@email,
@authors,
@description,
@homepage,
@has_rdoc
@has_rdoc,
@new_platform,
]
end
@ -277,9 +278,7 @@ module Gem
spec.instance_variable_set :@summary, array[5]
spec.instance_variable_set :@required_ruby_version, array[6]
spec.instance_variable_set :@required_rubygems_version, array[7]
spec.instance_variable_set :@new_platform, array[8]
spec.instance_variable_set :@original_platform, array[8]
spec.instance_variable_set :@platform, array[8].to_s
spec.instance_variable_set :@dependencies, array[9]
spec.instance_variable_set :@rubyforge_project, array[10]
spec.instance_variable_set :@email, array[11]
@ -287,6 +286,8 @@ module Gem
spec.instance_variable_set :@description, array[13]
spec.instance_variable_set :@homepage, array[14]
spec.instance_variable_set :@has_rdoc, array[15]
spec.instance_variable_set :@new_platform, array[16]
spec.instance_variable_set :@platform, array[16].to_s
spec.instance_variable_set :@loaded, false
spec
@ -377,7 +378,10 @@ module Gem
end
overwrite_accessor :platform= do |platform|
@original_platform = platform if @original_platform.nil?
if @original_platform.nil? or
@original_platform == Gem::Platform::RUBY then
@original_platform = platform
end
case platform
when Gem::Platform::CURRENT then
@ -657,6 +661,17 @@ module Gem
end
end
# Returns the full name (name-version) of this gemspec using the original
# platform.
#
def original_name # :nodoc:
if platform == Gem::Platform::RUBY or platform.nil? then
"#{@name}-#{@version}"
else
"#{@name}-#{@version}-#{@original_platform}"
end
end
# The full path to the gem (install path + full name).
#
# return:: [String] the full gem path
@ -664,8 +679,7 @@ module Gem
def full_gem_path
path = File.join installation_path, 'gems', full_name
return path if File.directory? path
File.join installation_path, 'gems',
"#{name}-#{version}-#{@original_platform}"
File.join installation_path, 'gems', original_name
end
# The default (generated) file name of the gem.
@ -724,18 +738,34 @@ module Gem
hash_code + n
}
end
# Export methods (YAML and Ruby code) ----------------------------
# Returns an array of attribute names to be used when generating a
# YAML representation of this object. If an attribute still has
# its default value, it is omitted.
def to_yaml_properties
def to_yaml(opts = {}) # :nodoc:
mark_version
@@attributes.map { |name, default| "@#{name}" }
attributes = @@attributes.map { |name,| name.to_s }.sort
attributes = attributes - %w[name version platform]
yaml = YAML.quick_emit object_id, opts do |out|
out.map taguri, to_yaml_style do |map|
map.add 'name', @name
map.add 'version', @version
platform = if String === @original_platform then
@original_platform
else
@original_platform.to_s
end
map.add 'platform', platform
attributes.each do |name|
map.add name, instance_variable_get("@#{name}")
end
end
end
end
def yaml_initialize(tag, vals)
def yaml_initialize(tag, vals) # :nodoc:
vals.each do |ivar, val|
instance_variable_set "@#{ivar}", val
end
@ -754,6 +784,9 @@ module Gem
result << " s.name = #{ruby_code name}"
result << " s.version = #{ruby_code version}"
unless platform.nil? or platform == Gem::Platform::RUBY then
result << " s.platform = #{ruby_code original_platform}"
end
result << ""
result << " s.specification_version = #{specification_version} if s.respond_to? :specification_version="
result << ""
@ -762,6 +795,7 @@ module Gem
handled = [
:dependencies,
:name,
:platform,
:required_rubygems_version,
:specification_version,
:version,

View file

@ -39,7 +39,7 @@ class FakeFetcher
@paths << path
raise ArgumentError, 'need full URI' unless path =~ %r'^http://'
data = @data[path]
raise OpenURI::HTTPError.new("no data for #{path}", nil) if data.nil?
raise Gem::RemoteFetcher::FetchError, "no data for #{path}" if data.nil?
data.respond_to?(:call) ? data.call : data
end
@ -48,7 +48,7 @@ class FakeFetcher
@paths << path
raise ArgumentError, 'need full URI' unless path =~ %r'^http://'
data = @data[path]
raise OpenURI::HTTPError.new("no data for #{path}", nil) if data.nil?
raise Gem::RemoteFetcher::FetchError, "no data for #{path}" if data.nil?
data.respond_to?(:call) ? data.call : data.length
end
@ -189,7 +189,8 @@ class RubyGemTestCase < Test::Unit::TestCase
Gem::Builder.new(spec).build
end
FileUtils.mv "#{spec.full_name}.gem", File.join(@gemhome, 'cache')
FileUtils.mv "#{spec.full_name}.gem",
File.join(@gemhome, 'cache', "#{spec.original_name}.gem")
end
end
@ -203,13 +204,22 @@ class RubyGemTestCase < Test::Unit::TestCase
@a0_0_2 = quick_gem('a', '0.0.2', &spec)
@b0_0_2 = quick_gem('b', '0.0.2', &spec)
@c1_2 = quick_gem('c', '1.2', &spec)
@pl1 = quick_gem 'pl', '1' do |s| # l for legacy
s.files = %w[lib/code.rb]
s.require_paths = %w[lib]
s.platform = Gem::Platform.new 'i386-linux'
s.instance_variable_set :@original_platform, 'i386-linux'
end
write_file File.join(*%w[gems a-0.0.1 lib code.rb]) do end
write_file File.join(*%w[gems a-0.0.2 lib code.rb]) do end
write_file File.join(*%w[gems b-0.0.2 lib code.rb]) do end
write_file File.join(*%w[gems c-1.2 lib code.rb]) do end
write_file File.join(*%W[gems #{@a0_0_1.original_name} lib code.rb]) do end
write_file File.join(*%W[gems #{@a0_0_2.original_name} lib code.rb]) do end
write_file File.join(*%W[gems #{@b0_0_2.original_name} lib code.rb]) do end
write_file File.join(*%W[gems #{@c1_2.original_name} lib code.rb]) do end
write_file File.join(*%W[gems #{@pl1.original_name} lib code.rb]) do end
[@a0_0_1, @a0_0_2, @b0_0_2, @c1_2].each { |spec| util_build_gem spec }
[@a0_0_1, @a0_0_2, @b0_0_2, @c1_2, @pl1].each { |spec| util_build_gem spec }
FileUtils.rm_r File.join(@gemhome, 'gems', @pl1.original_name)
Gem.source_index = nil
end

View file

@ -10,17 +10,18 @@ class TestGem < RubyGemTestCase
super
@additional = %w[a b].map { |d| File.join @tempdir, d }
@default_dir_re = %r|/ruby/gems/[0-9.]+|
@default_dir_re = %r|/[Rr]uby/[Gg]ems/[0-9.]+|
end
def test_self_all_load_paths
util_make_gems
expected = [
File.join(@tempdir, *%w[gemhome gems a-0.0.1 lib]),
File.join(@tempdir, *%w[gemhome gems a-0.0.2 lib]),
File.join(@tempdir, *%w[gemhome gems b-0.0.2 lib]),
File.join(@tempdir, *%w[gemhome gems c-1.2 lib]),
File.join(@gemhome, *%W[gems #{@a0_0_1.full_name} lib]),
File.join(@gemhome, *%W[gems #{@a0_0_2.full_name} lib]),
File.join(@gemhome, *%W[gems #{@b0_0_2.full_name} lib]),
File.join(@gemhome, *%W[gems #{@c1_2.full_name} lib]),
File.join(@gemhome, *%W[gems #{@pl1.full_name} lib]),
]
assert_equal expected, Gem.all_load_paths.sort
@ -34,8 +35,9 @@ class TestGem < RubyGemTestCase
def test_self_bindir_default_dir
default = Gem.default_dir
assert_equal Config::CONFIG['bindir'], Gem.bindir(default)
assert_equal Config::CONFIG['bindir'], Gem.bindir(Pathname.new(default))
bindir = (defined? RUBY_FRAMEWORK_VERSION) ? '/usr/bin' : Config::CONFIG['bindir']
assert_equal bindir, Gem.bindir(default)
assert_equal bindir, Gem.bindir(Pathname.new(default))
end
def test_self_clear_paths
@ -172,9 +174,10 @@ class TestGem < RubyGemTestCase
util_make_gems
expected = [
File.join(@tempdir, *%w[gemhome gems a-0.0.2 lib]),
File.join(@tempdir, *%w[gemhome gems b-0.0.2 lib]),
File.join(@tempdir, *%w[gemhome gems c-1.2 lib]),
File.join(@gemhome, *%W[gems #{@a0_0_2.full_name} lib]),
File.join(@gemhome, *%W[gems #{@b0_0_2.full_name} lib]),
File.join(@gemhome, *%W[gems #{@c1_2.full_name} lib]),
File.join(@gemhome, *%W[gems #{@pl1.full_name} lib]),
]
assert_equal expected, Gem.latest_load_paths.sort
@ -195,13 +198,15 @@ class TestGem < RubyGemTestCase
end
def test_self_path_ENV_PATH
Gem.clear_paths
path_count = Gem.path.size
Gem.clear_paths
util_ensure_gem_dirs
ENV['GEM_PATH'] = @additional.join(File::PATH_SEPARATOR)
assert_equal @additional, Gem.path[0,2]
assert_equal 3, Gem.path.size
assert_equal path_count + @additional.size, Gem.path.size
assert_match Gem.dir, Gem.path.last
end
@ -214,7 +219,9 @@ class TestGem < RubyGemTestCase
ENV['GEM_PATH'] = dirs.join File::PATH_SEPARATOR
assert_equal @gemhome, Gem.dir
assert_equal @additional + [Gem.dir], Gem.path
paths = [Gem.dir]
paths << APPLE_GEM_HOME if defined? APPLE_GEM_HOME
assert_equal @additional + paths, Gem.path
end
def test_self_path_overlap
@ -225,7 +232,9 @@ class TestGem < RubyGemTestCase
ENV['GEM_PATH'] = @additional.join(File::PATH_SEPARATOR)
assert_equal @gemhome, Gem.dir
assert_equal @additional + [Gem.dir], Gem.path
paths = [Gem.dir]
paths.insert(0, APPLE_GEM_HOME) if defined? APPLE_GEM_HOME
assert_equal @additional + paths, Gem.path
end
def test_self_platforms

View file

@ -22,13 +22,14 @@ class TestGemCommandsEnvironmentCommand < RubyGemTestCase
assert_match %r|RUBYGEMS VERSION: (\d\.)+\d \((\d\.)+\d\)|, @ui.output
assert_match %r|RUBY VERSION: \d\.\d\.\d \(.*\) \[.*\]|, @ui.output
assert_match %r|INSTALLATION DIRECTORY: #{@gemhome}|, @ui.output
assert_match %r|INSTALLATION DIRECTORY: #{Regexp.escape @gemhome}|,
@ui.output
assert_match %r|RUBYGEMS PREFIX: |, @ui.output
assert_match %r|RUBY EXECUTABLE:.*ruby|, @ui.output
assert_match %r|RUBYGEMS PLATFORMS:|, @ui.output
assert_match %r|- #{Gem::Platform.local}|, @ui.output
assert_match %r|GEM PATHS:|, @ui.output
assert_match %r|- #{@gemhome}|, @ui.output
assert_match %r|- #{Regexp.escape @gemhome}|, @ui.output
assert_match %r|GEM CONFIGURATION:|, @ui.output
assert_match %r|:verbose => |, @ui.output
assert_match %r|REMOTE SOURCES:|, @ui.output

View file

@ -92,13 +92,13 @@ class TestGemDependencyInstaller < RubyGemTestCase
end
def test_install_dependency_old
@e1, @e1_gem = util_gem 'e', '1'
@f1, @f1_gem = util_gem 'f', '1' do |s| s.add_dependency 'e' end
@f2, @f2_gem = util_gem 'f', '2'
e1, e1_gem = util_gem 'e', '1'
f1, f1_gem = util_gem 'f', '1' do |s| s.add_dependency 'e' end
f2, f2_gem = util_gem 'f', '2'
FileUtils.mv @e1_gem, @tempdir
FileUtils.mv @f1_gem, @tempdir
FileUtils.mv @f2_gem, @tempdir
FileUtils.mv e1_gem, @tempdir
FileUtils.mv f1_gem, @tempdir
FileUtils.mv f2_gem, @tempdir
inst = nil
Dir.chdir @tempdir do
@ -333,7 +333,7 @@ class TestGemDependencyInstaller < RubyGemTestCase
assert_equal %w[d-2], inst.installed_gems.map { |s| s.full_name }
end
def test_download_gem
def test_download
a1_data = nil
File.open @a1_gem, 'rb' do |fp|
a1_data = fp.read
@ -349,7 +349,7 @@ class TestGemDependencyInstaller < RubyGemTestCase
assert File.exist?(a1_cache_gem)
end
def test_download_gem_cached
def test_download_cached
FileUtils.mv @a1_gem, @cache_dir
inst = Gem::DependencyInstaller.new 'a'
@ -358,7 +358,7 @@ class TestGemDependencyInstaller < RubyGemTestCase
inst.download(@a1, 'http://gems.example.com')
end
def test_download_gem_local
def test_download_local
FileUtils.mv @a1_gem, @tempdir
local_path = File.join @tempdir, "#{@a1.full_name}.gem"
inst = nil
@ -371,7 +371,7 @@ class TestGemDependencyInstaller < RubyGemTestCase
inst.download(@a1, local_path)
end
def test_download_gem_install_dir
def test_download_install_dir
a1_data = nil
File.open @a1_gem, 'rb' do |fp|
a1_data = fp.read
@ -390,7 +390,7 @@ class TestGemDependencyInstaller < RubyGemTestCase
end
unless win_platform? then # File.chmod doesn't work
def test_download_gem_local_read_only
def test_download_local_read_only
FileUtils.mv @a1_gem, @tempdir
local_path = File.join @tempdir, "#{@a1.full_name}.gem"
inst = nil
@ -407,7 +407,30 @@ class TestGemDependencyInstaller < RubyGemTestCase
end
end
def test_download_gem_unsupported
def test_download_platform_legacy
original_platform = 'old-platform'
e1, e1_gem = util_gem 'e', '1' do |s|
s.platform = Gem::Platform::CURRENT
s.instance_variable_set :@original_platform, original_platform
end
e1_data = nil
File.open e1_gem, 'rb' do |fp|
e1_data = fp.read
end
@fetcher.data["http://gems.example.com/gems/e-1-#{original_platform}.gem"] = e1_data
inst = Gem::DependencyInstaller.new 'a'
e1_cache_gem = File.join(@gemhome, 'cache', "#{e1.full_name}.gem")
assert_equal e1_cache_gem, inst.download(e1, 'http://gems.example.com')
assert File.exist?(e1_cache_gem)
end
def test_download_unsupported
inst = Gem::DependencyInstaller.new 'a'
e = assert_raise Gem::InstallError do
@ -503,8 +526,8 @@ class TestGemDependencyInstaller < RubyGemTestCase
util_build_gem spec
cache_file = File.join @tempdir, 'gems', "#{spec.full_name}.gem"
FileUtils.mv File.join(@gemhome, 'cache', "#{spec.full_name}.gem"),
cache_file = File.join @tempdir, 'gems', "#{spec.original_name}.gem"
FileUtils.mv File.join(@gemhome, 'cache', "#{spec.original_name}.gem"),
cache_file
FileUtils.rm File.join(@gemhome, 'specifications',
"#{spec.full_name}.gemspec")

View file

@ -49,7 +49,7 @@ class TestGemExtConfigureBuilder < RubyGemTestCase
expected = %r|configure failed:
sh \./configure --prefix=#{@dest_path}
sh \./configure --prefix=#{Regexp.escape @dest_path}
.*?: \./configure: No such file or directory
|

View file

@ -17,6 +17,24 @@ class TestGemFormat < RubyGemTestCase
@simple_gem = SIMPLE_GEM
end
def test_from_file_by_path
util_make_gems
gems = Dir[File.join(@gemhome, 'cache', '*.gem')]
names = [@a0_0_1, @a0_0_2, @b0_0_2, @c1_2, @pl1].map do |spec|
spec.original_name
end
gems_n_names = gems.sort.zip names
gems_n_names.each do |gemfile, name|
spec = Gem::Format.from_file_by_path(gemfile).spec
assert_equal name, spec.original_name
end
end
def test_from_file_by_path_nonexistent
assert_raise Gem::Exception do
Gem::Format.from_file_by_path '/nonexistent'

View file

@ -49,16 +49,23 @@ class TestGemIndexer < RubyGemTestCase
assert File.directory?(quickdir)
assert File.directory?(marshal_quickdir)
assert File.exist?(File.join(quickdir, "index"))
assert File.exist?(File.join(quickdir, "index.rz"))
assert File.exist?(File.join(quickdir, "#{@a0_0_1.full_name}.gemspec.rz"))
assert File.exist?(File.join(marshal_quickdir, "#{@a0_0_1.full_name}.gemspec.rz"))
assert File.exist?(File.join(quickdir, "#{@a0_0_2.full_name}.gemspec.rz"))
assert File.exist?(File.join(marshal_quickdir, "#{@a0_0_2.full_name}.gemspec.rz"))
assert File.exist?(File.join(quickdir, "#{@b0_0_2.full_name}.gemspec.rz"))
assert File.exist?(File.join(quickdir, "#{@c1_2.full_name}.gemspec.rz"))
assert !File.exist?(File.join(quickdir, "#{@c1_2.full_name}.gemspec"))
assert !File.exist?(File.join(marshal_quickdir, "#{@c1_2.full_name}.gemspec"))
assert_indexed quickdir, "index"
assert_indexed quickdir, "index.rz"
assert_indexed quickdir, "#{@a0_0_1.full_name}.gemspec.rz"
assert_indexed quickdir, "#{@a0_0_2.full_name}.gemspec.rz"
assert_indexed quickdir, "#{@b0_0_2.full_name}.gemspec.rz"
assert_indexed quickdir, "#{@c1_2.full_name}.gemspec.rz"
assert_indexed quickdir, "#{@pl1.original_name}.gemspec.rz"
deny_indexed quickdir, "#{@pl1.full_name}.gemspec.rz"
assert_indexed marshal_quickdir, "#{@a0_0_1.full_name}.gemspec.rz"
assert_indexed marshal_quickdir, "#{@a0_0_2.full_name}.gemspec.rz"
deny_indexed quickdir, "#{@c1_2.full_name}.gemspec"
deny_indexed marshal_quickdir, "#{@c1_2.full_name}.gemspec"
end
def test_generate_index_ui
@ -67,8 +74,8 @@ class TestGemIndexer < RubyGemTestCase
end
expected = <<-EOF
Generating index for 4 gems in #{@tempdir}
....
Generating index for 5 gems in #{@tempdir}
.....
Loaded all gems
Generating master indexes (this may take a while)
EOF
@ -92,12 +99,21 @@ Generating master indexes (this may take a while)
dump_index.each do |_,gem|
gem.send :remove_instance_variable, :@loaded
gem.send :remove_instance_variable, :@original_platform
end
assert_equal yaml_index, dump_index,
"expected YAML and Marshal to produce identical results"
end
def assert_indexed(dir, name)
file = File.join dir, name
assert File.exist?(file), "#{file} does not exist"
end
def deny_indexed(dir, name)
file = File.join dir, name
assert !File.exist?(file), "#{file} exists"
end
end if ''.respond_to? :to_xs

View file

@ -21,6 +21,7 @@ class TestGemPlatform < RubyGemTestCase
def test_self_new
assert_equal Gem::Platform::RUBY, Gem::Platform.new(Gem::Platform::RUBY)
assert_equal Gem::Platform::RUBY, Gem::Platform.new(nil)
assert_equal Gem::Platform::RUBY, Gem::Platform.new('')
end
def test_initialize

View file

@ -196,6 +196,17 @@ end
assert_equal "1.3.5", spec.version.to_s
end
def test__dump
@a0_0_2.platform = Gem::Platform.local
@a0_0_2.instance_variable_set :@original_platform, 'old_platform'
data = Marshal.dump @a0_0_2
same_spec = Marshal.load data
assert_equal 'old_platform', same_spec.original_platform
end
def test_author
assert_equal 'A User', @a0_0_1.author
end
@ -445,6 +456,14 @@ end
assert_equal 'a', @a0_0_1.name
end
def test_original_name
assert_equal 'a-0.0.1', @a0_0_1.full_name
@a0_0_1.platform = 'i386-linux'
@a0_0_1.instance_variable_set :@original_platform, 'i386-linux'
assert_equal 'a-0.0.1-i386-linux', @a0_0_1.original_name
end
def test_platform
assert_equal Gem::Platform::RUBY, @a0_0_1.platform
end
@ -573,6 +592,7 @@ end
expected = "Gem::Specification.new do |s|
s.name = %q{a}
s.version = \"0.0.1\"
s.platform = Gem::Platform.new([\"ppc\", \"darwin\", nil])
s.specification_version = 2 if s.respond_to? :specification_version=
@ -587,10 +607,9 @@ end
s.files = [\"lib/code.rb\", \"test/suite.rb\", \"bin/exec\", \"ext/a/extconf.rb\"]
s.has_rdoc = %q{true}
s.homepage = %q{http://example.com}
s.platform = Gem::Platform.new([\"ppc\", \"darwin\", nil])
s.require_paths = [\"lib\"]
s.requirements = [\"A working computer\"]
s.rubygems_version = %q{0.9.4.6}
s.rubygems_version = %q{#{Gem::RubyGemsVersion}}
s.summary = %q{this is a summary}
s.test_files = [\"test/suite.rb\"]
@ -615,6 +634,17 @@ end
assert_equal gemspec1, gemspec2
end
def test_to_ruby_platform
@a0_0_2.platform = Gem::Platform.local
@a0_0_2.instance_variable_set :@original_platform, 'old_platform'
ruby_code = @a0_0_2.to_ruby
same_spec = eval ruby_code
assert_equal 'old_platform', same_spec.original_platform
end
def test_to_yaml
yaml_str = @a0_0_1.to_yaml
same_spec = YAML.load(yaml_str)
@ -635,6 +665,7 @@ end
def test_to_yaml_legacy_platform
@a0_0_1.platform = 'powerpc-darwin7.9.0'
@a0_0_1.instance_variable_set :@original_platform, 'powerpc-darwin7.9.0'
yaml_str = @a0_0_1.to_yaml