了解RubyGems

1, 什么是Gem?
gem是Ruby程序或库的打包方式,比如 gem install rails就是安装rails程序的gem
我们可以拿gem和war、jar类比
但是gem还担当了Java里maven的角色,就是一个库管理工具,可以远程下载和安装Ruby库

2, 常用gem命令
gem build -- Build a gem file from a specification
gem cert -- Support signing and managing signed gems
gem check -- Check installed gems for problems
gem cleanup -- Cleanup old versions in the repository
gem contents -- Display the files contained in an installed gem
gem dependency -- List the dependencies of a gem
gem environment -- Display information about the gem environment
gem help -- Provide help about gem commands
gem install -- Installing a gem
gem list -- List gems starting with a string
gem query -- Query for a list of gems
gem rdoc -- Generate the RDoc files for an installed gem
gem search -- List gems containing a string
gem specification -- Extract the Gem::Specification from a gem file
gem uninstall -- Uninstalling a gem
gem unpack -- Unpack an installed gem to the current directory
gem update -- Update your installed gems

3, 写自己的gem
看看rails-1.2.3.gemspec
Gem::Specification.new do |s|
  s.name = %q{rails}
  s.version = "1.2.3"
  s.date = %q{2007-03-13}
  s.summary = %q{Web-application framework with template engine, control-flow layer, and ORM.}
  s.email = %q{[email protected]}
  s.homepage = %q{http://www.rubyonrails.org}
  s.rubyforge_project = %q{rails}
  s.description = %q{Rails is a ...}
  s.default_executable = %q{rails}
  s.authors = ["David Heinemeier Hansson"]
  s.files = ["bin", "builtin", ... ]
  s.rdoc_options = ["--exclude", "."]
  s.executables = ["rails"]
  s.add_dependency(%q<rake>, [">= 0.7.2"])
  s.add_dependency(%q<activesupport>, ["= 1.4.2"])
  s.add_dependency(%q<activerecord>, ["= 1.15.3"])
  s.add_dependency(%q<actionpack>, ["= 1.13.3"])
  s.add_dependency(%q<actionmailer>, ["= 1.3.3"])
  s.add_dependency(%q<actionwebservice>, ["= 1.2.3"])
end

gem build mygem.gemspec


4, 发布Gems
a, 提供xx.gem下载
b, gem_server
c, 上传到 RubyForge
因为我们使用 gem install xx命令安装gem时首先查找本地gems
如果本地gems没有,则从 RubyForge寻找gems

你可能感兴趣的:(maven,orm,Ruby,rubygems,Rails)