`
inosin
  • 浏览: 89922 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

rails3中23个gem包都是做什么用的?

阅读更多
安装了rails3后,系统会自动安装23个gem包,比rails2时代的7个gem包大大有所增加,到底这些包都是做什么用的呢?下面让我们来看看:

rails2所包含的gem包:

  • activesupport
  • activerecord
  • rack
  • actionpack
  • actionmailer
  • activeresource
  • rails


rails3所包含的gem包:

abstract (1.0.0)
  提供一个库可以在ruby中定义抽象方法。我们知道,ruby中是不提供抽象方法的,引入这个库之后,可以简单的创建抽象方法,有两种使用方式:
require 'abstract'
# 简写方式
class Foo
  abstract_method 'arg1, arg2=""', :method1, :method2, :method3
end
# 标准方式
class Bar
  def method1(arg1, arg2="")
    not_implemented
  end

  def method2(arg1, arg2="")
    not_implemented
  end
end


actionmailer (3.0.3)
  Rails的email组件,可以以控制器/视图的方式来撰写、发送、接收和测试电子邮件,支持群发和附件

actionpack (3.0.3)
  Rails的Web应用组件,包含三部分:Action Controller, Action View 和 Action Dispatch。是整个MVC的VC部分,可以使用在Rack兼容的服务器上。

activemodel (3.0.3)
  这个组件用于提供一个定义好的接口,用于建立ORM(activerecord)与actionpack之间的关系映射,也就是MVC的M部分,它支持:attributes, callbacks, validations, observers, serialization, internationalization, and testing等。也就是说它把Rails2中的activerecord各项功能抽象出来做成了接口,如果有需要,你只要实现这些接口就可以建立自己的ORM来取代activerecord。

activerecord (3.0.3)
  Rails的数据库操作组件,建立一个持久的领域模型用于数据库表和ruby类之间的映射。它用于提供基本的CRUD功能,强大的查找功能,和模型之间的关联,数据校验、迁移和测试等。

activeresource (3.0.3)
  Rails的REST实现。包装你的RESTful风格的web应用,用于实现基于web的资源和本地CURD对象之间的映射

activesupport (3.0.3)
  是从rails提取出来的一个支持工具包库和Ruby的核心扩展。支持多字节字串,国际化,时区和测试。

arel (2.0.4)
  1)简单的生成复杂的SQL查询;2)适用于各种RDBMS系统。可以把它当成是框架中的框架,就是说可以用它创建自己的ORM系统,只需要把注意力集中在创新和建模,而不是数据库兼容性和查询的生成。通过大量通俗易懂的关系操作符,几乎可以覆盖80%的数据库操作。下面举几个例子:
posts = Arel::Table.new(:posts)
posts.project(Arel.sql('*')).to_sql
# => SELECT * FROM `posts`
posts.project(posts[:title]).to_sql
# => SELECT `posts`.`title` FROM `posts`
posts.where(posts[:title].eq('test')).to_sql
# => SELECT  FROM `posts` WHERE `posts`.`title` = 'test'
posts.take(5).skip(4).to_sql
# => SELECT  FROM `posts` LIMIT 5 OFFSET 4


builder (2.1.2)
  提供了一些builder对象,用于简单的创建结构化数据。现在支持XML标记和XML事件

bundler (1.0.7)
  在一个应用程序的整个生命周期中都可以用它来管理包依赖问题,可以跨多台机器,系统性重复性管理。 

erubis (2.6.6)
  Erubis 是一个快速、安全和具备高可扩展性的eRuby 的实现,主要特征如下:
* Very fast, almost three times faster than ERB and even 10% faster than eruby
* Multi-language support (Ruby/PHP/C/Java/Scheme/Perl/Javascript)
* Auto escaping support
* Auto trimming spaces around '<% %>'
* Embedded pattern changeable (default '<% %>')
* Enable to handle Processing Instructions (PI) as embedded pattern (ex. '<?rb ... ?>')
* Context object available and easy to combine eRuby template with YAML datafile
* Print statement available
* Easy to extend and customize in subclass
* Ruby on Rails support


i18n (0.4.2)
  Ruby的国际化支持

mail (2.2.10)
  Ruby的mail工具,mail的实现都在这里。

mime-types (1.16)
  这个在Rails2中也有,Rails3中把它独立出来单独成包了。它用于以MIME内容类型的方式来识别文件类型,是基于文件扩展名的。

polyglot (0.3.1)
  通过它可以注册任意文件扩展名,并在ruby文件中require引入。treetop组件需要用到。
#== EXAMPLE:

#In file rubyglot.rb, define and register a file type handler:

require 'polyglot'

class RubyglotLoader
  def self.load(filename, options = nil, &block)
	  File.open(filename) {|file|
	    # Load the contents of file as Ruby code:
	    # Implement your parser here instead!
	    Kernel.eval(file.read)
    }
  end
end
Polyglot.register("rgl", RubyglotLoader)

# In file test.rb:
require 'rubyglot'	# Create my file type handler
require 'hello'	# Can add extra options or even a block here
puts "Ready to go"
Hello.new

# In file hello.rgl (this simple example uses Ruby code):
puts "Initializing"
class Hello
  def initialize()
	  puts "Hello, world\n"
  end
end

# Run:
  $ ruby test.rb
  Initializing
  Ready to go
  Hello, world
  $


rack-mount (0.6.13)
  Stackable dynamic tree based Rack router

rack-test (0.5.6)
  Rack::Test是用于测试Rack应用的一个简单的小API。

rails (3.0.3)
  我不说了,你知道的!

railties (3.0.3)
  Rails的核心中的核心:应用程序引导、插件、生成器和计划任务

rake (0.8.7)
  类似于Make,Ruby里的程序执行器,用标准的Ruby语法来指定计划任务和依赖包

thor (0.14.6)
  一个简单高效的工具,用于创建自文档化的命令行,类似于rake,语法也于rake很像

treetop (1.4.9)
  一个Ruby写的解析器,用于解析领域特定语言(Domain Specific Language,DSL),mail组件需要用到

tzinfo (0.3.23)
  用于不同时区的时间转换
6
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics