0

如果我要求安装给定的 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)

类似这样的 CLI 是否存在gem

顺便说一句,如果没有-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
4

1 回答 1

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

它将显示主页、当前版本、作者、日期和依赖项信息。(默认为本地安装的 gem)。

于 2013-10-18T20:27:22.350 回答