如何将条件rubygem需求添加到gem规范? [英] How do I add conditional rubygem requirements to a gem specification?

查看:90
本文介绍了如何将条件rubygem需求添加到gem规范?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只有当用户使用特定版本的ruby时,才有可能添加gem依赖关系吗?

背景:在使用Test :: Unit :: Autorunner等的项目分支上工作。它们是Ruby 1.8标准库的一部分,但不是1.9.1中标准库的一部分,而是在测试单元gem中。我想添加一个依赖关系,如果有人使用ruby 1.9.1或更高版本,请安装test-unitgem,但如果他们使用1.8或更低版本,则不需要安装任何东西。

解决方案

如果您查看 gemspec关于add_dependency的文档,没有Ruby版本的选项。也许你可以使用post_install_message属性告诉用户如果他们使用Ruby 1.9来安装gem。


Is it possible to add a gem dependency only if the person is using a certain version of ruby?

Background: I'm working on a fork of a project that uses Test::Unit::Autorunner and the like. They are part of the standard library in ruby 1.8, but aren't part of the standard library in 1.9.1, and is instead in the "test-unit" gem. I want to add a dependency that says that if someone's using ruby 1.9.1 or later, install the "test-unit" gem, but if they're using 1.8 or earlier, they don't need to install anything.

解决方案

If you look at the gemspec documentation for add_dependency, there isn't an option for a ruby version. Perhaps you could use the post_install_message attribute to tell the user to install the gem if they're using ruby 1.9.

这篇关于如何将条件rubygem需求添加到gem规范?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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