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

@ -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,