Gem vs. plugin

Can someone help me understand the difference(s) between a Gem and a plugin?

Thanks,

Bill

Bill Walton wrote:

Can someone help me understand the difference(s) between a Gem and a plugin?

Thanks,
Bill

A gem is a library of ruby code that can add some specific
functionality. You need to 'require' them to use them in your rails
project. They do not depend on Rails for functionality.

A plugin is a bit of code that is loaded by the rails framework when it
starts up that is typically used to add or modify core functionality of
rails. Plugins require Rails to function.

If you have a bit of code that you want to release, it might be better
as a gem if it is generally useful to everyone using Ruby or you might
prefer to package it as a plugin if it really only applies to Rails
applications.

_Kevin

Thanks, Kevin. That helps. Would it be safe (i.e., not 100%, but not too
inaccurate) to say something like "

Gems extend the functionality, in addition to Rails, that's available to all
your Rails apps, while Plugins allow Rails to provide additional
functionality to a specific Rails app."

Best regards,
Bill

Bill Walton wrote:

Thanks, Kevin. That helps. Would it be safe (i.e., not 100%, but not too
inaccurate) to say something like "

Gems extend the functionality, in addition to Rails, that's available to all
your Rails apps, while Plugins allow Rails to provide additional
functionality to a specific Rails app."

Best regards,
Bill

From: "_Kevin" <kevin.olbrich@gmail.com>
To: "Ruby on Rails: Talk" <rubyonrails-talk@googlegroups.com>
Sent: Wednesday, October 25, 2006 6:56 AM
Subject: [Rails] Re: Gem vs. plugin

>
>
> Bill Walton wrote:
>> Can someone help me understand the difference(s) between a Gem and a
>> plugin?
>>
>> Thanks,
>> Bill
>
> A gem is a library of ruby code that can add some specific
> functionality. You need to 'require' them to use them in your rails
> project. They do not depend on Rails for functionality.
>
> A plugin is a bit of code that is loaded by the rails framework when it
> starts up that is typically used to add or modify core functionality of
> rails. Plugins require Rails to function.
>
> If you have a bit of code that you want to release, it might be better
> as a gem if it is generally useful to everyone using Ruby or you might
> prefer to package it as a plugin if it really only applies to Rails
> applications.
>
> _Kevin
>
>
> >
>

No, because you have to load gems manually anyway.

It would be better to say that Gems extend the functionality of Ruby,
while plugins extend the functionality of Rails.

_Kevin

Kevin wrote:

It would be better to say that Gems extend the functionality of Ruby, while plugins extend the functionality of Rails.

I like that. Thanks!

Bill

I'm still not clear. What was the Rails team's rationale for thinking
up and adopting the plugin scheme (a special code packaging technique
just for Rails' apps). What does that buy us over having extension
writers package their code as gems?

Brian

Kevin's association of gems with ruby and plugins with rails is pretty accurate.

Plugins serve a slightly different and more specific purpose than
gems, including a hook (init.rb) which allows a plugin to do any
initialisation at a controlled point while Rails is loaded. Beyond
install.rb, they are really simple, and don't require any packaging to
distribute. It's also trivial to distribute them within a Rails
application.

Gems are typically installed on a system-wide basis, requiring another
control mechanism to determine which gem'd plugins might get loaded
for any particular Rails application. What might using gems gain us?
Well, possibly dependencies, but not much more. The current plugin
implementation is simple, focussed, and most importantly is entirely
under the control of the Rails team, so it can be extended in ways
which suit the future direction of the framework without any issues.