summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-04-20 07:31:11 +0900
committerGitHub <[email protected]>2019-04-20 07:31:11 +0900
commit88c3595db3349515634ad21a1595a5ab6b88375c (patch)
tree2a2a08a0c4cf130fe719595b9c3bd5abfb60a8f7
parentff765c814d5f91397c4423079ba626e032222c70 (diff)
parent73bb144ef0dcf1f3dc4e721e0fd2d557f18cfe07 (diff)
downloadmruby-88c3595db3349515634ad21a1595a5ab6b88375c.tar.gz
mruby-88c3595db3349515634ad21a1595a5ab6b88375c.zip
Merge pull request #4393 from robfors/twiddle_wakka
Fixes the twiddle wakka comparison algorithm
-rw-r--r--lib/mruby/gem.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/mruby/gem.rb b/lib/mruby/gem.rb
index ce2e01ab1..95c1d4bc3 100644
--- a/lib/mruby/gem.rb
+++ b/lib/mruby/gem.rb
@@ -267,16 +267,18 @@ module MRuby
# ~> compare algorithm
#
# Example:
+ # ~> 2 means >= 2.0.0 and < 3.0.0
# ~> 2.2 means >= 2.2.0 and < 3.0.0
- # ~> 2.2.0 means >= 2.2.0 and < 2.3.0
+ # ~> 2.2.2 means >= 2.2.2 and < 2.3.0
def twiddle_wakka_ok?(other)
gr_or_eql = (self <=> other) >= 0
- still_minor = (self <=> other.skip_minor) < 0
- gr_or_eql and still_minor
+ still_major_or_minor = (self <=> other.skip_major_or_minor) < 0
+ gr_or_eql and still_major_or_minor
end
- def skip_minor
+ def skip_major_or_minor
a = @ary.dup
+ a << 0 if a.size == 1 # ~> 2 can also be represented as ~> 2.0
a.slice!(-1)
a[-1] = a[-1].succ
a