aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/requirement.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-01 04:53:52 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-01 04:53:52 +0000
commit6e7213f427c8030396c2de6cc488cae5d8dd5ff9 (patch)
tree690a8520ec62d18b56e433e7a35f1c49603c1ea5 /lib/rubygems/requirement.rb
parentf77d381159419434b3c1f1a63839706967f348f9 (diff)
downloadruby-6e7213f427c8030396c2de6cc488cae5d8dd5ff9.tar.gz
Merge rubygems-3.0.2.
https://blog.rubygems.org/2019/01/01/3.0.2-released.html git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/requirement.rb')
-rw-r--r--lib/rubygems/requirement.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/rubygems/requirement.rb b/lib/rubygems/requirement.rb
index 1a73274c01..48f4b00d63 100644
--- a/lib/rubygems/requirement.rb
+++ b/lib/rubygems/requirement.rb
@@ -267,7 +267,22 @@ class Gem::Requirement
def ==(other) # :nodoc:
return unless Gem::Requirement === other
- requirements == other.requirements
+
+ # An == check is always necessary
+ return false unless requirements == other.requirements
+
+ # An == check is sufficient unless any requirements use ~>
+ return true unless _tilde_requirements.any?
+
+ # If any requirements use ~> we use the stricter `#eql?` that also checks
+ # that version precision is the same
+ _tilde_requirements.eql?(other._tilde_requirements)
+ end
+
+ protected
+
+ def _tilde_requirements
+ requirements.select { |r| r.first == "~>" }
end
private