插件和 Ruby gem 之间的区别? [英] Difference between plugins and Ruby gems?

查看:20
本文介绍了插件和 Ruby gem 之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

插件和宝石有什么区别?各有什么不同用途?您会在哪里以及为什么要使用其中一个?

What is the difference between plugins and gems? What are the different uses of each? Where and why would you use one over the other?

推荐答案

宝石

  • Gem 是一个打包的 ruby​​ 应用程序,使用 RubyGems 定义的打包系统.
  • Rails 本身就是一颗宝石.

  • Gem is a packaged ruby application using the packaging system defined by RubyGems.
  • Rails itself is a Gem.

Rails gem 安装在 jruby-1.0lib ubygems1.8gems ails-1.2.3 为:

目录 bin
DIR 内置
68,465 更新日志
DIR 配置
DIR 派遣
目录文档
DIR 环境
第307章DIR 助手
目录 html
目录
1,072 MIT 许可证
11,969 个 Rakefile
8,001 自述文件
lib 目录包含所有 gem 源代码.

Rails gem is installed in jruby-1.0lib ubygems1.8gems ails-1.2.3 as:

DIR bin
DIR builtin
68,465 CHANGELOG
DIR configs
DIR dispatches
DIR doc
DIR environments
307 fresh_rakefile
DIR helpers
DIR html
DIR lib
1,072 MIT-LICENSE
11,969 Rakefile
8,001 README
The lib directory contains all the gem source code.

  • 我们可以安装、升级和查询gem版本.如果使用像我的GemInstaller这样的工具,可以轻松实现自动化使用一个简单的配置文件安装和加载 RubyGems.

  • We can install,upgrade and query the gem version.If one uses a tool like my GemInstaller, one can easily automate the installation and loading of RubyGems with a single simple config file.

    插件

    • 插件是 Rails 框架的扩展.
    • 无法使用命令升级.要升级一个必须卸载然后安装升级版本.
    • 必须连接到 rails 应用程序.(必须有 init.rb)
    • 有一个 install.rb 文件.
    • 插件不能作为 Gem 发布.
    • 只能在应用程序范围内使用.

    Goldspike插件安装在应用程序的vendorplugins ails-integration目录下:
    7,089 build.xml
    1,141 许可证.txt
    DIR 插件
    6,675 pom.xml
    1,447 自述文件
    DIR 示例
    plugins/goldspike 目录由
    24 初始化.rb
    25 安装.rb
    目录
    第549话
    第536章DIR 任务
    DIR 测试
    lib目录包含所有插件源代码.

    Goldspike plugin is installed in vendorplugins ails-integration directory of the application as:
    7,089 build.xml
    1,141 LICENSE.txt
    DIR plugins
    6,675 pom.xml
    1,447 README
    DIR samples
    plugins/goldspike directory consists of
    24 init.rb
    25 install.rb
    DIR lib
    549 Rakefile
    536 README
    DIR tasks
    DIR test
    The lib directory contains all the plugin source code.

    Gem 与插件

    • Rails 有一种从 vendor/plugins/目录加载插件的方法.这很可能会被弃用,因为 Rails 添加了对将 gem 与项目捆绑在一起的支持在供应商/宝石/目录中.rspec 的 gem 版本是为日常使用而设计的.除非您支持 1.2.x 系列或更早版本的 Rails 应用程序,否则应该使用这些.
    • 使用 Gems 签入和签出存储库通常会变得更快,因为您没有将库包含在实际应用程序中.使用与分布式团队之间的软件版本不兼容有关的插件问题通常较少.
    • 一般的经验法则是将特定于 Rails 的功能变成插件,同时将更通用的 Ruby 库变成 gem.

    这篇关于插件和 Ruby gem 之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆