在Ruby on Rails中,将某些东西安装为宝石或作为插件有什么区别? [英] In Ruby on Rails, what's the difference between installing something as a gem or as a plugin?

查看:112
本文介绍了在Ruby on Rails中,将某些东西安装为宝石或作为插件有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://github.com/collectiveidea/delayed_job



它表示:


要作为gem安装,请将以下内容添加到config / environment.rb:< br>
config.gem'delayed_job'

运行 rake gems:install




安装为插件:

script / plugin install git://github.com/collectiveidea/delayed_job.git




将它安装为宝石或作为插件的区别是什么?

另外,第一种方法只是安装宝石2.0.3这可能是tobi的版本? ( rake gems:install 安装版本由 gem list -r delayed_job >) http://github.com/tobi/delayed_job
插件方法明确表示它是collectiveidea版本?

解决方案

Gem和买卖的插件都是指collectiveidea的分支。实际上,collectiveidea是RubyGems上 delayed_job Gem的当前维护者。

这就是说,一般来说,安装一个插件作为一个Gem有很多优势。



  • 您可以安装一次并将其用于许多不同的项目中

  • 您可以利用依赖解决方案

  • 您可以升级只更改版本号

  • 您不需要存储整个插件代码在您的SCM中



那么,为什么您可以将插件安装为插件?
有很多不同的答案。


最初,Rails插件是简单的库。时间过去了,开发人员开始注意到将封装插件作为Gem的优势。

另外,在Rails 3之前,一些插件功能仅用于插件,而不适用于Gems。例如,在Rails 3之前,插件可以绑定rake任务,而没有办法将新的rake任务或新路由注入主应用程序。



在最后两年来,Rails插件的大部分功能都可以作为插件或Gem来安装。随着Rails 3和Bundler的到来,我相信插件将会被弃用,以支持Gems。


On http://github.com/collectiveidea/delayed_job

it says:

To install as a gem, add the following to config/environment.rb:
config.gem 'delayed_job'
Run rake gems:install

versus

To install as a plugin:
script/plugin install git://github.com/collectiveidea/delayed_job.git

What is the difference between installing it as a gem or as a plugin?

Also, the first method just install gem 2.0.3 which might be the tobi's version? (rake gems:install installs the version by gem list -r delayed_job) Is it http://github.com/tobi/delayed_job ? The "plugin" method specifically says it is the collectiveidea version? Doesn't it matter which one you install?

解决方案

Both the Gem and the vendored plugin refers to the collectiveidea's fork. In fact, collectiveidea is the current maintainer for the delayed_job Gem on RubyGems.

That said, generally speaking installing a plugins as a Gem has many advantages.

  • You can install it once and use it in many different projects
  • You can take advantage of dependency resolution
  • You can upgrade just changing version number
  • You don't need to store the entire plugin code in your SCM

So, why you can install a plugin "as a plugin"? There are many different answers.

At the very beginning, Rails plugins came as simple libraries. Time passes and developers started to notice the advantage of packaging plugins as Gem.

Also, before Rails 3, some plugin features were only reserved to plugins and not to Gems. For instance, before Rails 3, plugins could bundle rake tasks while there wasn't a way to inject new rake tasks or new routes into the main application.

In the last two years, the most part of Rails plugins offers the ability to be installed as a plugin or as a Gem. With Rails 3 and the arrival of Bundler, I'm sure plugins are going to be deprecated in favor of Gems.

这篇关于在Ruby on Rails中,将某些东西安装为宝石或作为插件有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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