summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-20 05:56:43 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-20 05:56:43 +0000
commitdb74541efec489c62310ab85091b28bb360e79c8 (patch)
tree168c17fc9415c483722c7eb31ecdd63eac8771be /lib
parentcae4fb76dcc6810a38ad67301fb764b8b7e5c5ca (diff)
Update to RubyGems 0.9.5
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems.rb20
-rw-r--r--lib/rubygems/dependency_installer.rb21
-rw-r--r--lib/rubygems/indexer.rb14
-rw-r--r--lib/rubygems/indexer/marshal_index_builder.rb11
-rw-r--r--lib/rubygems/indexer/master_index_builder.rb11
-rw-r--r--lib/rubygems/indexer/quick_index_builder.rb6
-rw-r--r--lib/rubygems/platform.rb2
-rw-r--r--lib/rubygems/rubygems_version.rb2
-rw-r--r--lib/rubygems/specification.rb64
9 files changed, 109 insertions, 42 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 3ee9593ce3..184461b4d0 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -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
diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb
index 49afc76c79..e189e800a0 100644
--- a/lib/rubygems/dependency_installer.rb
+++ b/lib/rubygems/dependency_installer.rb
@@ -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}"
+
+ gem = Gem::RemoteFetcher.fetcher.fetch_path remote_gem_path
+ rescue Gem::RemoteFetcher::FetchError
+ raise if spec.original_platform == spec.platform
- remote_gem_path = source_uri + "gems/#{gem_file_name}"
+ alternate_name = "#{spec.name}-#{spec.version}-#{spec.original_platform}.gem"
- gem = Gem::RemoteFetcher.fetcher.fetch_path remote_gem_path
+ 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
diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb
index 8cb7735c29..dc94f51b1a 100644
--- a/lib/rubygems/indexer.rb
+++ b/lib/rubygems/indexer.rb
@@ -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"
diff --git a/lib/rubygems/indexer/marshal_index_builder.rb b/lib/rubygems/indexer/marshal_index_builder.rb
index 5e3ba7f5b9..e1a4d9f9b8 100644
--- a/lib/rubygems/indexer/marshal_index_builder.rb
+++ b/lib/rubygems/indexer/marshal_index_builder.rb
@@ -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
diff --git a/lib/rubygems/indexer/master_index_builder.rb b/lib/rubygems/indexer/master_index_builder.rb
index f435c44e41..dbe02370a9 100644
--- a/lib/rubygems/indexer/master_index_builder.rb
+++ b/lib/rubygems/indexer/master_index_builder.rb
@@ -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
diff --git a/lib/rubygems/indexer/quick_index_builder.rb b/lib/rubygems/indexer/quick_index_builder.rb
index 8805f3fe38..23c7ca696b 100644
--- a/lib/rubygems/indexer/quick_index_builder.rb
+++ b/lib/rubygems/indexer/quick_index_builder.rb
@@ -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
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
index f72f3a7684..24081d4fec 100644
--- a/lib/rubygems/platform.rb
+++ b/lib/rubygems/platform.rb
@@ -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
diff --git a/lib/rubygems/rubygems_version.rb b/lib/rubygems/rubygems_version.rb
index e01588ef2d..d08789baf6 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 = '0.9.4.6'
+ RubyGemsVersion = '0.9.5'
end
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 308ed717a4..4a785fa600 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -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,