可以用gem help commands看所有支持的参数,这个比gem -h显示的全:

wisy@wisy-ThinkPad-X61:~/src/ruby_src$ gem help commands
GEM commands are:

    build             Build a gem from a gemspec
    cert              Manage RubyGems certificates and signing settings
    check             Check a gem repository for added or missing files
    cleanup           Clean up old versions of installed gems
    contents          Display the contents of the installed gems
    dependency        Show the dependencies of an installed gem
    environment       Display information about the RubyGems environment
    fetch             Download a gem and place it in the current directory
    generate_index    Generates the index files for a gem server directory
    help              Provide help on the 'gem' command
    install           Install a gem into the local repository
    list              Display local gems whose name starts with STRING
    lock              Generate a lockdown list of gems
    mirror            Mirror all gem files (requires rubygems-mirror)
    outdated          Display all gems that need updates
    owner             Manage gem owners of a gem on the push server
    pristine          Restores installed gems to pristine condition from files
                      located in the gem cache
    push              Push a gem up to the gem server
    query             Query gem information in local or remote repositories
    rdoc              Generates RDoc for pre-installed gems
    search            Display remote gems whose name contains STRING
    server            Documentation and gem repository HTTP server
    sources           Manage the sources and cache file RubyGems uses to search
                      for gems
    specification     Display gem specification (in yaml)
    stale             List gems along with access times
    uninstall         Uninstall gems from the local repository
    unpack            Unpack an installed gem to the current directory
    update            Update installed gems to the latest version
    which             Find the location of a library file you can require
    yank              Remove a pushed gem from the index

For help on a particular command, use 'gem help COMMAND'.

Commands may be abbreviated, so long as they are unambiguous.
e.g. 'gem i rake' is short for 'gem install rake'.

windows下gem search默认是查找本地的gem,需要加-R以便查找远程的gem;linux like系统正好相反,默认是查找远程gem,如果要查找本地gem要加--local(或者-l).查询还可以用query选项,和search差不多.

gem list列出本地安装的第三方gem,可以用gem which查看某一个gem的路径:

wisy@wisy-ThinkPad-X61:~/src/ruby_src$ gem list

*** LOCAL GEMS ***

activemodel (4.1.8)
activerecord (4.1.8)
activesupport (4.1.8)
arel (6.0.0, 5.0.1.20140414130214)
bigdecimal (1.2.5, 1.2.4)
builder (3.2.2)
i18n (0.7.0.beta1)
io-console (0.4.2)
json (1.8.1)
md5sum (1.0.2)
minitest (5.4.3, 4.7.5)
net-ntp (2.1.2)
power_assert (0.2.2)
psych (2.0.8, 2.0.5)
rake (10.4.2, 10.1.0)
rdoc (4.2.0, 4.1.0)
RubyInline (3.12.3)
test-unit (3.0.8, 2.1.3.0)
thread_safe (0.3.4)
tzinfo (1.2.2)
webrick (1.3.1)
ZenTest (4.11.0)
zip (2.0.2)
wisy@wisy-ThinkPad-X61:~/src/ruby_src$ gem which zip
/var/lib/gems/2.1.0/gems/zip-2.0.2/lib/zip.rb

如果要看一个gem的详细信息,可以用gem specification,不过返回的是yaml格式,不过ruby中可以轻松将yaml转换为obj,从而用pp显示其"人类可读"内容:

wisy@wisy-ThinkPad-X61:~/src/ruby_src/drb$ gem specification zip>zip.doc
ruby -e"require 'yaml';require 'pp';pp YAML::load(File.read('zip.doc'))"
Gem::Specification.new do |s|
  s.name = "zip"
  s.version = Gem::Version.new("2.0.2")
  s.installed_by_version = Gem::Version.new("0")
  s.authors = ["Postmodern", "Thomas Sondergaard", "Sam Lown"]
  s.date = Time.utc(2010, 5, 26)
  s.description = "zip is a Ruby library for reading and writing Zip files. Unlike the official rubyzip, zip is compatible with Ruby 1.9.1."
  s.email = ["me@samlown.com", "postmodern.mod3@gmail.com"]
  s.extra_rdoc_files = ["ChangeLog.txt", "README"]
  s.files = ["ChangeLog.txt", "README"]
  s.homepage = "http://github.com/postmodern/rubyzip2"
  s.rdoc_options = ["--charset=UTF-8"]
  s.require_paths = ["lib"]
  s.rubygems_version = "2.2.2"
  s.specification_version = 4
  s.summary = "zip is a Ruby library for reading and writing Zip files"
  end

其实specification本身带有一个--ruby输出选项,输出和上面类似:gem specification zip --ruby,如果想查询远程gem的信息可以在后面加-r选项:gem specification xxx_gem --ruby -r

使用install可以从远程安装gem,不过有时候rubygems.org卡的和屎一样,这时要不你用代理,要不你从其他地方下载下来从本地安装:gem install --local xxx_gem.gem

可以用gem 查看某个gem的所有相关文件:

wisy@wisy-ThinkPad-X61:~/src/ruby_src/drb$ gem contents zip
/var/lib/gems/2.1.0/gems/zip-2.0.2/ChangeLog.txt
/var/lib/gems/2.1.0/gems/zip-2.0.2/NEWS.txt
/var/lib/gems/2.1.0/gems/zip-2.0.2/README
/var/lib/gems/2.1.0/gems/zip-2.0.2/Rakefile
/var/lib/gems/2.1.0/gems/zip-2.0.2/TODO.txt
/var/lib/gems/2.1.0/gems/zip-2.0.2/lib/zip.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/lib/zip/ioextras.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/lib/zip/stdrubyext.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/lib/zip/tempfile_bugfixed.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/lib/zip/version.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/lib/zip/zip.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/lib/zip/zipfilesystem.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/lib/zip/ziprequire.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/samples/example.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/samples/example_filesystem.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/samples/gtk_zip.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/samples/write_simple.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/samples/zipfind.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/test/alltests.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/test/data/file1.txt
/var/lib/gems/2.1.0/gems/zip-2.0.2/test/data/file1.txt.deflatedData
/var/lib/gems/2.1.0/gems/zip-2.0.2/test/data/file2.txt
/var/lib/gems/2.1.0/gems/zip-2.0.2/test/data/notzippedruby.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/test/data/rubycode.zip
/var/lib/gems/2.1.0/gems/zip-2.0.2/test/data/rubycode2.zip
/var/lib/gems/2.1.0/gems/zip-2.0.2/test/data/testDirectory.bin
/var/lib/gems/2.1.0/gems/zip-2.0.2/test/data/zipWithDirs.zip
/var/lib/gems/2.1.0/gems/zip-2.0.2/test/gentestfiles.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/test/ioextrastest.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/test/stdrubyexttest.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/test/zipfilesystemtest.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/test/ziprequiretest.rb
/var/lib/gems/2.1.0/gems/zip-2.0.2/test/ziptest.rb

最后可以用gem update升级所有本地gem,也可以用gem outdated查看本地需要升级的gem.

rubygem若干常用选项参数的更多相关文章

  1. zip命令的常用选项

    zip命令的常用选项 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 大家都知道,在linux上一切皆文件,在实际生产环境中,如果我们需要部署一些系统的服务,我们会将一些软件包提前下 ...

  2. curl常用选项详解

    curl常用选项详解 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 又是下班的时间了,让我们一起来学习一下今天的Linux命令吧~我一半只把自己常用的参数列出来,其他的有但是我们几 ...

  3. MySQL Backup mysqldump 常用选项与主要用法

    The mysqldump client utility performs logical backups, producing a set of SQL statements that can be ...

  4. mysqldump命令之常用选项

    ===============================================mysqldump常用选项-h, --host=name:服务器IP-u, --user=name:登录名 ...

  5. JVM调优系列:(五)JVM常用调试参数和工具

    转自:http://blog.csdn.net/opensure/article/details/46715769 JVM常用调试参数: –verbose:gc在虚拟机发生内存回收时在输出设备显示信息 ...

  6. Hotspot JVM的常用选项

    Hotspot JVM的常用选项 选项的分类 Hotspot JVM提供以下三大类选项: 1. 标准选项:这类选项的功能是很稳定的,在后续版本中也不太会发生变化.运行java或者java -help可 ...

  7. 附1 consul常用命令+常用选项

    之后每用到一个command或options,都会记录在这里. 常用命令command: agent 作用:运行一个consul agent join 作用:将agent加入到consul clust ...

  8. maven常用命令参数

    整理了一些maven常用命令参数,以便参考:参考了maven官网和网上其他一些maven追随者的文件,不在此一一列举,但表示感谢! mvn命令参数 mvn -v, --version 显示版本信息; ...

  9. FPGA综合工具--Synplify Pro的常用选项及命令

    最近要用到Synplify,但以前没使用过,无基础,找到一篇帖子,隧保存下来. 本文转自:http://blog.sina.com.cn/s/blog_65fe490d0100v8ax.html Sy ...

随机推荐

  1. TraceView性能分析工具介绍

    一.TraceView简介 TraceView是AndroidSDK里面自带的工具,用于对Android的应用程序以及Framework层的代码进行性能分析. TraceView是图形化的工具,最终它 ...

  2. Django使用forms来实现评论功能

    貌似Django从版本1.6开始就放弃了对自带的comments的使用,具体原因未查,但是现在使用Django的内部的模块也可以实现评论功能,那就是借助于forms模块,下面是我的一个小例子. 环境准 ...

  3. Python与JavaWeb的第一次碰撞

    在Python中向服务器提交一个表单数据看起来是很容易的,但是这次经历着实让我记忆深刻,借此也为了警醒同样遇到了这样问题的你们. 要做什么? 使用Python的urllib2模块提交表单数据,并在服务 ...

  4. BFS与DFS总结

    最近一直在看DFS和BFS,感觉要晕的GJ. DFS思想: 一直往深处走,直到找到解或者走不下去为止 DFS框架: DFS(dep,-)  //dep代表目前DFS的深度 {       if (找到 ...

  5. (六十八)使用XMPPFramework登录

    按照XMPPFramework的官方样例,应该把登录代码放置在AppDelegate中,并且让注销成为私有方法. XMPPFramework进行登录的步骤如下: ①连接主机,并且发送JID ②如果连接 ...

  6. EBS DBA指南笔记(三)

    第五章 patching   patch的作用:解决应用代码的问题:安装新的特征:更新technology stack组件.打patch不是一个简单的过程,但我们也没必要深究里面每个细节. EBS的p ...

  7. Java图片加文字水印

    Java图片加文字水印 import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.I ...

  8. java Domj4读取xml文件加强训练案例

    需求:给出一段xml文件.要求按照鸳鸯输出. xml文件代码如下: <?xml version="1.0" encoding="utf-8"?> & ...

  9. 海量数据挖掘MMDS week2: LSH的距离度量方法

    http://blog.csdn.net/pipisorry/article/details/48882167 海量数据挖掘Mining Massive Datasets(MMDs) -Jure Le ...

  10. leetcode 104 Maximum Depth of Binary Tree二叉树求深度

    Maximum Depth of Binary Tree Total Accepted: 63668 Total Submissions: 141121 My Submissions Question ...