分享

RubyGems简介

 xos 2007-01-22
RubyGems是一个方便而强大的Ruby程序包管理器( package manager),类似RedHat的RPM.它将一个Ruby应用程序打包到一个gem里,作为一个安装单元。
当前最新版本为0.8.3
下载地址:http:///frs/?group_id=126
主页:http://rubygems./wiki/wiki.pl
最新的Ruby版本已经包含RubyGems了。


特点:
能远程安装包
包之间依赖关系的管理
简单可靠的卸载(uninstallation)
查询机制,能查询本地和远程服务器的包信息
能保持一个包的不同版本
基于Web的查看接口,能查看你安装的gem的信息。


安装RubyGems
首先从rubyforge下载它的源文件 ,然后解压缩到一个地方,比如C:rubygems-0.8.3

C:rubygems-0.8.3>ruby setup.rb
---> bin
<--- bin
---> lib
---> lib/rubygems
<--- lib/rubygems
<--- lib
---> bin
<--- bin
---> lib
---> lib/rubygems
<--- lib/rubygems
<--- lib
rm -f InstalledFiles
---> bin
mkdir -p c:/ruby/bin/
install gem c:/ruby/bin/
install gem_server c:/ruby/bin/
install generate_yaml_index.rb c:/ruby/bin/
install update_rubygems c:/ruby/bin/
<--- bin
---> lib
mkdir -p c:/ruby/lib/ruby/site_ruby/1.8/
install rubygems.rb c:/ruby/lib/ruby/site_ruby/1.8/
install ubygems.rb c:/ruby/lib/ruby/site_ruby/1.8/
---> lib/rubygems
mkdir -p c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install builder.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install cmd_manager.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install command.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install config_file.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install doc_manager.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install format.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install gem_commands.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install gem_runner.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install installer.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install loadpath_manager.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install old_format.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install open-uri.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install package.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install remote_installer.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install rubygems_version.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install source_index.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install specification.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install user_interaction.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install validator.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
install version.rb c:/ruby/lib/ruby/site_ruby/1.8/rubygems
<--- lib/rubygems
<--- lib

As of RubyGems 0.8.0, library stubs are no longer needed.
Searching $LOAD_PATH for stubs to optionally delete (may take a while)...
...done.
No library stubs found.

Successfully built RubyGem
Name: sources
Version: 0.0.1
File: sources-0.0.1.gem

C:rubygems-0.8.3>gem -v
0.8.3

安装其实很简单。使用也简单,不带参数运行gem则显示使用方法:

C:rubygems-0.8.3>gem

RubyGems is a sophisticated package manager for Ruby. This is a
basic help message containing pointers to more information.

Usage:
gem -h/--help
gem -v/--version
gem command [arguments...] [options...]

Examples:
gem install rake
gem list --local
gem build package.gemspec
gem help install

Further help:
gem help commands list all ‘gem‘ commands
gem help examples show some examples of usage
gem help show help on COMMAND
(e.g. ‘gem help install‘)
Further information:
http://rubygems.

安装Rails

C:rubygems-0.8.3>gem install rails
Attempting local installation of ‘rails‘
Local gem file not found: rails*.gem
Attempting remote installation of ‘rails‘
Install required dependency rake? [Yn] y
Install required dependency activerecord? [Yn] y
Install required dependency actionpack? [Yn] y
Install required dependency actionmailer? [Yn] y
Successfully installed rails, version 0.9.1
Installing RDoc documentation for rails-0.9.1...
WARNING: Generating RDoc on .gem that may not have RDoc.

lib/binding_of_caller.rb:4:25: Couldn‘t find Continuation. Assuming it‘s a mod
e

lib/binding_of_caller.rb:36:21: Couldn‘t find Binding. Assuming it‘s a module

lib/rails_generator.rb:34:46: Skipping require of dynamic string: "#{path}/#{n
e}_generator.rb"
Installing RDoc documentation for rake-0.4.12...
Installing RDoc documentation for activerecord-1.2.0...
Installing RDoc documentation for actionpack-1.0.1...

lib/action_controller/scaffolding.rb:87:37: Skipping require of dynamic string
"#{model_id.id2name}"
Installing RDoc documentation for actionmailer-0.5.0...

C:rubygems-0.8.3>gem query --local

*** LOCAL GEMS ***

actionmailer (0.5.0)
Service layer for easy email delivery and testing.

actionpack (1.0.1)
Web-flow and rendering framework putting the VC in MVC.

activerecord (1.2.0)
Implements the ActiveRecord pattern for ORM.

rails (0.9.1)
Web-application framework with template engine, control-flow layer,
and ORM.

rake (0.4.12)
Ruby based make-like utility.

sources (0.0.1)
This package provides download sources for remote gem installation


如果命令没有指明是从本地还是远程安装,则默认先从本地安装,因为找不到rails*.gem文件,所以,所以再从远程安装。
遇到Rails依赖的包,我们也需要安装。
默认得,这些gems都被安装到了RUBY_HOMElibrubygems1.8gems下了(各个平台,版本都可能不同)
你可以用--dir选项覆盖这个默认值。


RubyGems还自带了一个基于
WEBrick的web服务器程序gem_server,使得你可以通过web来查看生成的RDoc文档。
C:rubygems-0.8.3>gem_server
[2004-12-19 13:06:12] INFO WEBrick 1.3.1
[2004-12-19 13:06:12] INFO ruby 1.8.2 (2004-11-06) [i386-mswin32]
[2004-12-19 13:06:12] INFO WEBrick::HTTPServer#start: pid=624 port=8808
127.0.0.1 - - [19/Dec/2004:13:06:26 中国标准时间] "GET / HTTP/1.1" 200 2248

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多