Rvm,gems,rubygems,bundle,gemfile,git,rake,

hbzhouyj 2012-11-29

rvm,gems,rubygems,bundle,gemfile,git,rake,怎么这么多概念,都是干什么用的?

RVM(Ruby Version Manager): is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems.

用于帮你安装Ruby环境,帮你管理多个Ruby环境,帮你管理你开发的每个Ruby应用使用机器上哪个Ruby环境。Ruby环境不仅仅是Ruby本身,还包括依赖的第三方Ruby插件。都由RVM管理。

保证了两个一致性:1.开发、测试、生产环境的基础Ruby环境一致。2.各个版本的Ruby都有与其完全匹配的第三方插件。

gems:At its most basic form, a Ruby gem is a package. It contains the necessary files and information for being installed on the system. Quoting RubyGems, ?a gem is a packaged Ruby application or library. It has a name (e.g. rake) and a version (e.g. 0.4.16)?.

可以叫做组件、库或包,里面包含了该组件运行所必需的各种文件和信息。当你用该第三方组件,你知道它是可靠的,因为它用清晰的结构自我描述,。

RubyGems: It is a package manager which became part of the standard library in Ruby 1.9. It allows developers to search, install and build gems, among other features. All of this is done by using the gemcommand-line utility. You can find its website at rubygems.org.

gems定义了包的结构,RubyGems是个工具,帮你管理单个包,包括搜索、安装、创建一个gems。他和RVM的区别在于:RVM维护一组gems,仿佛是一个基线,让这一组gems是彼此匹配的,而RubyGems帮你维护一个gmes。

bundle:We designed bundler to make it easy to share your code across a number of development, staging and production machines. Of course, you know how to share your own application or gem: stick it on GitHub and clone it where you need it. Bundler makes it easy to make sure that your application has the dependencies it needs to start up and run without errors.

bundle 相当于多个RubyGems批处理运行。在配置文件gemfilel里说明你的应用依赖哪些第三方包,他自动帮你下载安装多个包,并且会下载这些包依赖的包。

gemfile:定义你的应用依赖哪些第三方包,bundle根据该配置去寻找这些包。

git:Git is an extremely fast, efficient, distributed version control system ideal for the collaborative development of software.分布式版本控制软件配置管理软件。

github:GitHub is the best way to collaborate with others. Fork, send pull requests and manage all your public and private git repositories.

是git的一个在线的代码仓库,网址github.com。

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.

Rake:Rake包括了Rakefile,用于创建和执行某些任务。比如执行测试,比如创建 一个修改数据库的批处理任务。

将以上概念连接起来:

1.安装RVM :bash < <(curl -s )

2.用RVM安装出一个或多个Ruby环境:$ rvm install 1.9.2

3.用RVM指出现在使用哪个版本的Ruby环境:$ rvm use 1.9.2
4.用gem安装rails $ gem install rails (gem是ruby的内置的)
5.安装后的rails,以一组gems的形式,存储在RVM1.9.2的环境仓库里。
6.用安装的rails,生成你自己的应用。 work> rails new demo
7.用rake,生成rails的API文档,> rake doc:rails
8.在rails生成的应用目录下,写自己的代码,用git进行版本控制。
9.需要新功能,安装新组件,在gemfile文件中添加需要的组件,并用bundle下载安装多个组件及其依赖的其他组件,这些组件仍然存储到RVM的gems库里。
10.用rake执行 生成、修改数据库,执行测试等要多次执行的任务。

相关推荐