Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the difference between gem and plugin?

I'm new to Rails and I'm confused about concept of gems & plugins. Can anyone explain them for me?

like image 273
mlzboy Avatar asked Nov 23 '10 02:11

mlzboy


People also ask

What is plugin in Ruby?

A Rails plugin is either an extension or a modification of the core framework. Plugins provide: A way for developers to share bleeding-edge ideas without hurting the stable code base. A segmented architecture so that units of code can be fixed or updated on their own release schedule.

What is a gem in software development?

Gems are programs and libraries for the Ruby programming language. They are distributed by Ruby's package manager, which is called RubyGems, which is accessed by the gem command. This page is meant to be Ruby equivalent of Python's pip page.

What is gem and homebrew?

RubyGems and Homebrew are both package managers. RubyGems was created for the express purpose of installing gems whereas Homebrew is a more general tool which can build, install and manage different software packages including gems. Homebrew is tied to Mac OS X, whereas RubyGems works on multiple platforms.

How does gem file work?

A Gemfile describes the gem dependencies required to execute associated Ruby code. Place the Gemfile in the root of the directory containing the associated code. For instance, in a Rails application, place the Gemfile in the same directory as the Rakefile .


1 Answers

Plugins are just libraries loaded from a specific directory, gems are loaded via Bundler or RubyGems directly.

Where this really makes a differences is maintenance and management. What happens when you want the latest and greatest authlogic plugin, well you need to update the files in your directory. That doesn't sound so bad when it's one plugin, but what about something that constantly updates? There was/is an existing system for code packaging and distribution (RubyGems), which lends itself to managing such things.

Consider the authlogic example again, what happens if the new version requires some other dependency now? With RubyGems the gem file explicitly defines that relationship, the plugin system does not and such a definition would've been redundant.

With the advent of Bundler in rails 3.x it's become very easy to manage and distribute the gems that your project uses.

TL;DR: Plugins are basically gems without the packaging information.

like image 105
segy Avatar answered Oct 05 '22 19:10

segy