如何在 gemspec 中指定最低 Ruby 版本? [英] How do you specify a minimum Ruby version in a gemspec?

查看:44
本文介绍了如何在 gemspec 中指定最低 Ruby 版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为现在需要 Ruby 1.9 的新版本 gem 编写 gemspec.以前版本的 gem 可以用于 Ruby 1.8,但现在需要 1.9.有没有办法导致此版本 gem 的 gem 安装失败,并向尝试在 Ruby 1.8 上安装它的用户发出警告?

I'm writing a gemspec for a new version of a gem that will now require Ruby 1.9. Previous versions of the gem were ok with Ruby 1.8, but now 1.9 will be required. Is there a way to cause the gem install for this version of the gem to fail with a warning for users who try to install it on Ruby 1.8?

推荐答案

来自 RubyGems 文档:

# This gem will work with 1.8.6 or greater...
spec.required_ruby_version = '>= 1.8.6'

# Only with ruby 2.0.x
spec.required_ruby_version = '~> 2.0'

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

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