有没有办法让RubyGems的'gem`命令可以安装什么版本的gem?

时间:2013-10-18 19:11:21

标签: rubygems

如果我要求安装它,我想知道给定gem的哪个版本 。例如,(在撰写本文时)如果我执行gem install rails,它将安装4.0.0。但我更愿意问gem而不是去https://rubygems.org/gems/rails

示例:

-bash> gem info rails -v
4.0.0

另外,我想知道可以安装哪些版本。同样,我不想去RubyGems - https://rubygems.org/gems/rails/versions - 我只想问gem最后10个版本:

-bash> gem info rails -v 10
4.0.1.rc1 October 17, 2013 (1.48 MB)
4.0.0 June 25, 2013 (1.47 MB)
4.0.0.rc2 June 11, 2013 (1.47 MB)
4.0.0.rc1 April 29, 2013 (1.49 MB)
4.0.0.beta1 February 26, 2013 (1.49 MB)
3.2.15 October 16, 2013 (4.5 KB)
3.2.15.rc3 October 11, 2013 (4.5 KB)
3.2.15.rc2 October 4, 2013 (4.5 KB)
3.2.15.rc1 October 3, 2013 (4.5 KB)
3.2.14 July 22, 2013 (3.5 KB)

gem中是否存在类似这样的CLI?

顺便说一下,如果没有-v它会告诉我RubyGems网页告诉我的相应内容会很酷:

-bash> gem info rails
About: Ruby on Rails is a full-stack web framework optimized for programmer 
       happiness and sustainable productivity. It encourages beautiful code
       by favoring convention over configuration.

Author: David Heinemeier Hansson

Version: 4.0.0
Total downloads: 28,483,741
For this version: 801,825

License: MIT

RubyGems:      https://rubygems.org/gems/rails
Homepage:      http://www.rubyonrails.org/
Source Code:   http://github.com/rails/rails
Documentation: http://api.rubyonrails.org/
Wiki:          http://wiki.rubyonrails.org/
Mailing List:  http://groups.google.com/group/rubyonrails-talk
Bug Tracker:   http://github.com/rails/rails/issues

Gemfile:
    gem "rails", "~> 4.0.0"

Versions:
    4.0.1.rc1 October 17, 2013 (1.48 MB)
    3.2.15 October 16, 2013 (4.5 KB)
    3.2.15.rc3 October 11, 2013 (4.5 KB)
    3.2.15.rc2 October 4, 2013 (4.5 KB)
    3.2.15.rc1 October 3, 2013 (4.5 KB)
    https://rubygems.org/gems/rails/versions

Runtime Dependencies:
    actionmailer = 4.0.0
    actionpack = 4.0.0
    activerecord = 4.0.0
    activesupport = 4.0.0
    bundler < 2.0, >= 1.3.0
    railties = 4.0.0
    sprockets-rails ~> 2.0.0

1 个答案:

答案 0 :(得分:1)

要查找“将”安装哪个版本的遥控器:

gem query --remote -n^rails$ #the -n parameter takes a regex

可替换地,

gem search ^rails$

(我不认为除了参数样式之外这两个命令之间有很大的区别,但查询默认为本地,搜索默认为远程)

如果您想知道哪些版本可用,您可以这样做:

gem search --all ^rails$ #defaults to remote
gem query -n^rails$ #defaults to local

如果您需要作者/主页/许可证信息,可以添加--details标志。除非您在本地获得所有信息,否则似乎并非所有信息都可用。

如果您不介意有关在Yaml的许可,主页等信息,您可以使用:

gem specification --remote rails

它将显示主页,当前版本,作者,日期和依赖关系信息。 (默认为本地安装的宝石)。