整理Ruby相关的各种概念(rvm, gem, bundle, rake, rails等)

1. Ruby

Ruby,一种为简单快捷的面向对象编程(面向对象程序设计)而创的脚本语言,在20世纪90年代由日本人松本行弘(Yukihiro Matsumoto)开发,遵守GPL协议和Ruby License。它的灵感与特性来自于 Perl、Smalltalk、Eiffel、Ada以及 Lisp 语言。由 Ruby 语言本身还发展出了JRuby(Java平台)、IronRuby(.NET平台)等其他平台的 Ruby 语言替代品。Ruby的作者于1993年2月24日开始编写Ruby,直至1995年12月才正式公开发布于fj(新闻组)。因为Perl发音与6月诞生石pearl(珍珠)相同,因此Ruby以7月诞生石ruby(红宝石)命名。

2. RVM

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

参考

3. RubyGems

RubyGems 是一个方便而强大的Ruby程序包管理器(package
manager),类似Redhat的RPM。它讲一个Ruby应用程序打包到一个gem
里,作为一个安装单元。无需安装,最新的Ruby版本已经包含RubyGems了。

4. Gem

Gem是封装起来的Ruby应用程序或代码库。
注:在终端使用的gem命令,是指通过RubyGems管理Gem包。

参考

5. Gemfile

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

6. Rake

Rake是一门构建语言,和make类型。Rake是用Ruby写的,它支持自己的DSL用来处理和维护Ruby
程序。Rails用rake扩展来完成多种不同任务,如数据库初始化、更新等。


  Rake is a Make-like program implemented in Ruby. Tasks and dependencies are specified in standard Ruby syntax.

参考

7. Bundle

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


  Bundler provides a consistent environment for Ruby projects by
  tracking and installing the exact gems and versions that are needed.

  Bundler is an exit from dependency hell, and ensures that the gems
  you needed are present in development, staging, and production.
  Starting work on a project is as simple as `bundle install`

参考

8. Rack

以Ruby为语言编写的轻量级的服务。


  Rack provides a minimal interface between webservers that support Ruby and Ruby frameworks.


  # my_rack_app.rb
  require 'rack'

  app = Proc.new do |env|
      ['200', {'Content-Type' => 'text/html'}, ['A barebones rack app.']]
  end

  Rack::Handler::WEBrick.run app

  > ruby my_rack_app.rb
  [2015-12-14 23:27:19] INFO  WEBrick 1.3.1
  [2015-12-14 23:27:19] INFO  ruby 2.2.2 (2015-04-13) [x86_64-darwin14]
  [2015-12-14 23:27:19] INFO  WEBrick::HTTPServer#start: pid=84264 port=8080
  localhost - - [14/Dec/2015:23:27:43 CST] "GET / HTTP/1.1" 200 21


参考

    原文作者:大浩的投资哲学
    原文地址: https://www.jianshu.com/p/4587f91c7dbe
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞