How does the pessimistic version operator (~>) in

2019-05-28 22:55发布

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条回答
Lonely孤独者°
2楼-- · 2019-05-28 23:40

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".

查看更多
登录 后发表回答