How does the pessimistic version operator (~>) in

2019-05-28 23:35发布

问题:

I understand how the "pessimistic version operator" works with normal, numeric version specifiers (see also this question), but how does it process alpha or beta versions such as '~> 2.0.0.alpha.4'? Will this match future beta and stable versions?

回答1:

I ran a couple of quick tests in irb with the following pattern:

Gem::Requirement.new("~> 2.0.0.alpha.4").satisfied_by?(Gem::Version.new("[version.string.to.test]"))

For instance:

irb(main):001:0> Gem::Requirement.new("~> 2.0.0.alpha.4").satisfied_by?(Gem::Version.new("2.0.1"))
=> true

These tests show that "~> 2.0.0.alpha.4" matches version numbers up to, but not including, "2.1.0".