免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3564 | 回复: 0
打印 上一主题 下一主题

rails3中23个gem包都是做什么用的? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-12-21 12:27 |只看该作者 |倒序浏览
本帖最后由 中关村村草 于 2010-12-21 12:29 编辑

转:inosin


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中是不提供抽象方法的,引入这个库之后,可以简单的创建抽象方法,有两种使用方式:
Ruby代码
  1. require 'abstract'
  2. # 简写方式
  3. class Foo
  4.   abstract_method 'arg1, arg2=""', :method1, :method2, :method3
  5. end
  6. # 标准方式
  7. class Bar
  8.   def method1(arg1, arg2="")
  9.     not_implemented
  10.   end

  11.   def method2(arg1, arg2="")
  12.     not_implemented
  13.   end
  14. 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%的数据库操作。下面举几个例子:
Ruby代码
  1. posts = Arel::Table.new(:posts)
  2. posts.project(Arel.sql('*')).to_sql
  3. # => SELECT * FROM `posts`
  4. posts.project(posts[:title]).to_sql
  5. # => SELECT `posts`.`title` FROM `posts`
  6. posts.where(posts[:title].eq('test')).to_sql
  7. # => SELECT  FROM `posts` WHERE `posts`.`title` = 'test'
  8. posts.take(5).skip(4).to_sql
  9. # => 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组件需要用到。
Ruby代码
  1. #== EXAMPLE:   
  2.   
  3. #In file rubyglot.rb, define and register a file type handler:   
  4.   
  5. require 'polyglot'  
  6.   
  7. class RubyglotLoader   
  8.   def self.load(filename, options = nil, &block)   
  9.       File.open(filename) {|file|   
  10.         # Load the contents of file as Ruby code:   
  11.         # Implement your parser here instead!   
  12.         Kernel.eval(file.read)   
  13.     }   
  14.   end  
  15. end  
  16. Polyglot.register("rgl", RubyglotLoader)   
  17.   
  18. # In file test.rb:   
  19. require 'rubyglot'  # Create my file type handler   
  20. require 'hello' # Can add extra options or even a block here   
  21. puts "Ready to go"  
  22. Hello.new  
  23.   
  24. # In file hello.rgl (this simple example uses Ruby code):   
  25. puts "Initializing"  
  26. class Hello   
  27.   def initialize()   
  28.       puts "Hello, world\n"  
  29.   end  
  30. end  
  31.   
  32. # Run:   
  33.   $ ruby test.rb   
  34.   Initializing   
  35.   Ready to go   
  36.   Hello, world   
  37.   $  
复制代码
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)
  用于不同时区的时间转换
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP