aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/spec_fetcher.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-22 08:24:42 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-22 08:24:42 +0000
commit372dcece3f69989d133f720468f1e24aa1133cda (patch)
treec173ca48a23ce18afa44feb15bf68d2dd14ac619 /lib/rubygems/spec_fetcher.rb
parentd0e5a34ac7c34e70c145024a0fed8f6042814f29 (diff)
downloadruby-372dcece3f69989d133f720468f1e24aa1133cda.tar.gz
Update to RubyGems 1.3.7.pre.1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/spec_fetcher.rb')
-rw-r--r--lib/rubygems/spec_fetcher.rb40
1 files changed, 31 insertions, 9 deletions
diff --git a/lib/rubygems/spec_fetcher.rb b/lib/rubygems/spec_fetcher.rb
index 027970c342..dac35d85d0 100644
--- a/lib/rubygems/spec_fetcher.rb
+++ b/lib/rubygems/spec_fetcher.rb
@@ -3,6 +3,7 @@ require 'fileutils'
require 'rubygems/remote_fetcher'
require 'rubygems/user_interaction'
+require 'rubygems/errors'
##
# SpecFetcher handles metadata updates from remote gem repositories.
@@ -65,22 +66,28 @@ class Gem::SpecFetcher
# false, all platforms are returned. If +prerelease+ is true,
# prerelease versions are included.
- def fetch(dependency, all = false, matching_platform = true, prerelease = false)
- specs_and_sources = find_matching dependency, all, matching_platform, prerelease
+ def fetch_with_errors(dependency, all = false, matching_platform = true, prerelease = false)
+ specs_and_sources, errors = find_matching_with_errors dependency, all, matching_platform, prerelease
- specs_and_sources.map do |spec_tuple, source_uri|
+ ss = specs_and_sources.map do |spec_tuple, source_uri|
[fetch_spec(spec_tuple, URI.parse(source_uri)), source_uri]
end
+ return [ss, errors]
+
rescue Gem::RemoteFetcher::FetchError => e
raise unless warn_legacy e do
require 'rubygems/source_info_cache'
- return Gem::SourceInfoCache.search_with_source(dependency,
- matching_platform, all)
+ return [Gem::SourceInfoCache.search_with_source(dependency,
+ matching_platform, all), nil]
end
end
+ def fetch(*args)
+ fetch_with_errors(*args).first
+ end
+
def fetch_spec(spec, source_uri)
spec = spec - [nil, 'ruby', '']
spec_file_name = "#{spec.join '-'}.gemspec"
@@ -117,16 +124,27 @@ class Gem::SpecFetcher
# matching released versions are returned. If +matching_platform+
# is false, gems for all platforms are returned.
- def find_matching(dependency, all = false, matching_platform = true, prerelease = false)
+ def find_matching_with_errors(dependency, all = false, matching_platform = true, prerelease = false)
found = {}
+ rejected_specs = {}
+
list(all, prerelease).each do |source_uri, specs|
found[source_uri] = specs.select do |spec_name, version, spec_platform|
- dependency =~ Gem::Dependency.new(spec_name, version) and
- (not matching_platform or Gem::Platform.match(spec_platform))
+ if dependency.match?(spec_name, version)
+ if matching_platform and !Gem::Platform.match(spec_platform)
+ pm = (rejected_specs[dependency] ||= Gem::PlatformMismatch.new(spec_name, version))
+ pm.add_platform spec_platform
+ false
+ else
+ true
+ end
+ end
end
end
+ errors = rejected_specs.values
+
specs_and_sources = []
found.each do |source_uri, specs|
@@ -134,7 +152,11 @@ class Gem::SpecFetcher
specs_and_sources.push(*specs.map { |spec| [spec, uri_str] })
end
- specs_and_sources
+ [specs_and_sources, errors]
+ end
+
+ def find_matching(*args)
+ find_matching_with_errors(*args).first
end
##