在 ruby​​ .gemspec 文件中,如何指定依赖项的多个版本? [英] In a ruby .gemspec file, how do I specify multiple versions of a dependency?

查看:42
本文介绍了在 ruby​​ .gemspec 文件中,如何指定依赖项的多个版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试修改当前依赖于活动资源的 gem,定义为:

I'm trying to modify a gem which currently has a dependency on activeresource defined as:

s.add_dependency              "activeresource", "~> 3.0"

为了让 gem 与 Rails 4 一起工作,我需要扩展依赖项以与版本 3 或 4 的 activeresource 一起使用.我不想简单地添加以下内容,因为它可能会导致以后出现问题:

In order to get the gem working with Rails 4, I need to extend the dependency to work with either version 3 or 4 of activeresource. I don't want to simply add the following as it could cause problems later:

s.add_dependency              "activeresource", ">= 3.0"

有没有办法指定可接受版本的列表?~> 3.0 还是 ~> 4.0?

Is there a way to specify a list of acceptable versions? ~> 3.0 or ~> 4.0?

推荐答案

根据文档,如果需要要拥有 3 到 4 之间的所有版本,您可以这样做:

Accordly to the documentation, if you want to have all version between 3 and 4, you can do this :

s.add_dependency "activeresource", ">= 3.0", "< 5.0"

接受的说明符是:>=, ~>, <=, >, <.

这篇关于在 ruby​​ .gemspec 文件中,如何指定依赖项的多个版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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