Diffrence between ruby Gem V Plugins

Topic Ruby Gem Rails Plugin
Definition A Gem is a packaged Ruby application using the packaging system defined by RubyGems. A Rails plugin is a packaged Ruby application that extends the core Rails framework.
Example Has a name (e.g. rake) and a version (e.g. 0.4.16). Rails is also installed as a Gem. Has a name (e.g. Goldspike) and a version (e.g. 1.1.1).
Scope Installed in the Ruby or JRuby installation and is available to all applications run using that interpreter. Installed in a specific Rails app only.
Packaging System Rails gem is installed in jruby-1.0\lib\ruby\gems\1.8\gems\rails-1.2.3 as:<DIR>        bin
<DIR>        builtin
<DIR>        configs
<DIR>        dispatches
<DIR>        doc
<DIR>        environments
307          fresh_rakefile
<DIR>        helpers
<DIR>        html
<DIR>        lib
11,969 Rakefile
8,001 README

The lib directory contains all the gem source code.

Goldspike plugin is installed in vendor\plugins\rails-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
<DIR>       tasks
<DIR>       test

The lib directory contains all the plugin source code.

Management Gems are managed on your computer using the gem command. You can install, remove and query gem packages using the gem command. Plugins can be installed using after creating a Rails application and then invoking the command

ruby script\plugin install [url or name of plugin]

Load Path gem command adds the lib directory of your gem to the load path of Ruby. Rails adds the lib directory of plugin in your application’s load path.
Specific Features
  • Bundled Rake tasks that get automatically loaded into your Rakefile
  • An installation hook (install.rb)
  • An application initialization hook for the plugin to inject itself (init.rb)
  • ability to bundle additional generators (for the script/generate script)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s