RubyGems简称gems,它允许您轻松下载,安装和使用系统上的ruby软件包。该软件包称为“gem”,其中包含打包的Ruby应用程序或库。
每个软件包gem都有一个名称,版本和平台。例如, Rake gem有一个0.8.7版本(从2009年5月起)。Rake的平台是ruby,这意味着它适用于ruby运行的任何平台。
每个gem都遵循相同的代码组织标准结构:
% tree freewill freewill/ ├── bin/ │ └── freewill ├── lib/ │ └── freewill.rb ├── test/ │ └── test_freewill.rb ├── README ├── Rakefile └── freewill.gemspec
% cat freewill.gemspec Gem::Specification.new do |s| s.name = 'freewill' s.version = '1.0.0' s.summary = "Freewill!" s.description = "I will choose Freewill!" s.authors = ["Nick Quaranto"] s.email = 'nick@quaran.to' s.homepage = 'http://example.com/freewill' s.files = ["lib/freewill.rb", ...] end
ruby项目依赖于一系列的ruby gems,而bundler是一个很好的管理ruby项目gems的工具。使用bundler可以为你的ruby project提供统一的构建环境。
gemfile是描述gem之间依赖的文件,这个文件定义了从哪个源找到这些gem,使用该gem的什么版本等。
source "https://rubygems.org" gem "my_gem", ">= 0.0"
Rake是全部须要安装的Gem中最重要的一个,而且它应该始终是你在系统上第一个安装的Gem。Rake是一个构建工具,和Make很类似,但它容许用Ruby来写Rakefile(如何进行构建的定义文件),其中使用了一种特定的DSL(domain-specific language,领域专用语言),在保持Ruby强大功能的同时提供很高的可读性。 Rails用rake扩展来完成多种不容任务,如数据库初始化、更新等。ui
Rake is a build language, similar in purpose to make and ant. Like make and ant it's a Domain Specific Language, unlike those two it's an internal DSL programmed in the Ruby language.插件
PS:我的感受有点相似Symfony2中的app/consoledebug
详细 http://rake.rubyforge.org/
Rakefile是由Ruby编写,Rake的命令执行就是由Rakefile文件定义。
In a gem’s context, the Rakefile is extremely useful. It can hold various tasks to help building, testing and debugging your gem, among all other things that you might find useful.
详细:http://rake.rubyforge.org/files/doc/rakefile_rdoc.
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!