diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-08 01:32:18 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-08 01:32:18 +0000 |
commit | c00e84327f14845bd484e76b5ee5dfeb1fa9ce3d (patch) | |
tree | 9f558dafa363f4f0118d504a50cd4461e2821cd1 /lib/rubygems/resolver.rb | |
parent | 6b05153a3a75b74b64553d6a46f501d9ee0f0376 (diff) | |
download | ruby-c00e84327f14845bd484e76b5ee5dfeb1fa9ce3d.tar.gz |
Merge rubygems master.
This is RC version of Rubygems 2.7.0.
https://github.com/rubygems/rubygems/commit/688fb7e83c13c3fe7c2bb03c49a2db4c82852aee
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/resolver.rb')
-rw-r--r-- | lib/rubygems/resolver.rb | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb index 8f0db512a2..13ee035e4c 100644 --- a/lib/rubygems/resolver.rb +++ b/lib/rubygems/resolver.rb @@ -230,8 +230,28 @@ class Gem::Resolver exc.errors = @set.errors raise exc end - possibles.sort_by { |s| [s.source, s.version, Gem::Platform.local =~ s.platform ? 1 : 0] }. - map { |s| ActivationRequest.new s, dependency, [] } + + sources = [] + + groups = Hash.new { |hash, key| hash[key] = [] } + + # create groups & sources in the same loop + sources = possibles.map { |spec| + source = spec.source + groups[source] << spec + source + }.uniq.reverse + + activation_requests = [] + + sources.each do |source| + groups[source]. + sort_by { |spec| [spec.version, Gem::Platform.local =~ spec.platform ? 1 : 0] }. + map { |spec| ActivationRequest.new spec, dependency, [] }. + each { |activation_request| activation_requests << activation_request } + end + + activation_requests end def dependencies_for(specification) |