ruby gems tips(转)_Ruby_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > Ruby > ruby gems tips(转)

ruby gems tips(转)

 2010/12/5 13:14:33  zfj.rails  http://zfj-rails.javaeye.com  我要评论(0)
  • 摘要:升级rubygemgemupdate--system查看gem版本gem-v查看gem版本,gems安装目录,remotesources等gemenv查看已经添加的remotesourcesgemsources添加一个sourcegemsources-a'htt://rubygems.org'安装一个gem包geminstallwill_paginate指定源位置geminstallwill_paginate--source'http://rubygems
  • 标签:Ruby Gem
升级ruby gem
gem update --system

查看gem版本
gem -v

查看gem版本,gems安装目录,remote sources等
gem env

查看已经添加的remote sources
gem sources

添加一个source
gem sources -a 'htt://rubygems.org'

安装一个gem包
gem install will_paginate

指定源位置
gem install will_paginate --source 'http://rubygems.org'
gem install will_paginate -s 'http://rubygems.org'

指定版本
gem install rails -v=2.3.5

查看已经安装的全部gem包
gem list

或者 gem list -d 查看具体的信息,例如project的author,homepage,安装在系统中的路径 等信息,建议加上该参数…
查看d开头的gem包
gem list d

更详细的查看
gem list will_paginate -d

卸载gem包
gem uninstall rails

卸载指定版本
gem uninstall rails -v=2.1.0

查找gem包
gem search will_paginate --both (在local和remote源中search含有will_paginate关键字的)
gem list -r will_paginate
gem list -dr will_paginate (我常用这个)

查看gem包依赖其他的gem:
gem dependency rails -v 2.3.5
Gem rails-2.3.5
  actionmailer (= 2.3.5, runtime)
  actionpack (= 2.3.5, runtime)
  activerecord (= 2.3.5, runtime)
  activeresource (= 2.3.5, runtime)
  activesupport (= 2.3.5, runtime)
  rake (>= 0.8.3, runtime)

查看gem包的rdoc帮助
gem server (然后http://localhost:8808查看)

windows 平台上安装
gem install hpricot --platform=mswin32 # 不指定在windows安装会报错

不安装ri 和 rdoc
gem install hpricot --no-ri --no-rdoc

查看更多的gem帮助,可以
gem -h


项目里常用gem命令
rake -T gems:
(in /usr/local/system/entos/netposa_redmine)
rake gems:build                # Build any native extensions for unpacked gems
rake gems:build:force          # Force the build of all gems
rake gems:install              # Installs all required gems.
rake gems:refresh_specs        # Regenerate gem specifications in correct format.
rake gems:unpack               # Unpacks all required gems into vendor/gems.
rake gems:unpack:dependencies  # Unpacks all required gems and their dependencies into vendor/gems.

例如你enviroment.rb 中配置了paperclip gem
config.gem 'paperclip', '2.3.5'

那么
rake gems:install 

将会安装paperclip 2.3.5 到你的ruby目录里,
rake gems:unpack:dependencies 

将会把依赖的gem包unpack 到vendor/gems 目录下,
如果你是直接从gem包copy 到vendor/gems 目录下的话,需要执行
rake gems:refresh_specs 

来生成 .specifications 文件
发表评论
用户名: 匿名