Ruby中的悲观版本运算符(〜>)如何处理alpha / beta版本? [英] How does the pessimistic version operator (~>) in Ruby handle alpha/beta versions?

查看:99
本文介绍了Ruby中的悲观版本运算符(〜>)如何处理alpha / beta版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解悲观版本运算符如何与普通的数字版本说明符一起工作(另请参阅这个问题),但它如何处理alpha或beta版本,如'〜> 2.0.0.alpha.4'?这将匹配未来的测试版和稳定版吗?

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?

推荐答案

我在irb中运行了几个快速测试, p>

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]"))

例如:

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

这些测试显示〜> 2.0.0.alpha.4与版本号相匹配,但不包括2.1.0。

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

这篇关于Ruby中的悲观版本运算符(〜>)如何处理alpha / beta版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆