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?
Ruby Gems software permits you to download, install, and employ Ruby software packages on your scheme easily. Here, the software package is known as 'gem' which comprises a packaged Ruby application or library. Some of the gems deliver command-line efficacies to aid automate errands and speed-up the work.
Gems in Rails are libraries that allow any Ruby on Rails developer to add functionalities without writing code. You can also call Ruby on Rails gems as plugins for adding features. A Ruby gem enables adding features without creating the code again and again.
Gems can be used to extend or modify functionality in Ruby applications. Commonly they're used to distribute reusable functionality that is shared with other Rubyists for use in their applications and libraries. Some gems provide command line utilities to help automate tasks and speed up your work.
Gem
Rails itself is a Gem.
Rails gem is installed in jruby-1.0\lib\ruby\gems\1.8\gems\rails-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.
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.
Plugin
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
536 README
DIR tasks
DIR test
The lib directory contains all the plugin source code.
Gem vs Plugins
Gems are installed on the system level while plugins are installed on the application level. That means if two or more apps are running on the same server, they can share gems, but each will have its own plugins. For now I'll suggest one to use gems, as they are easier to maintain as applications scale.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With