Recipe 14.1. Finding Third-Party Plug-ins


Problem

You need some feature that isn't supported in the latest version of Rails. You want to see whether there's a third-party plug-in you can use to extend your application.

Solution

Use the built-in plugin script to query a list of publicly accessible Subversion repositories for available plug-ins.

First, use the discover command to make sure your list of plug-in repositories contains all those listed on the Rails wiki plug-ins page. If new repositories are discovered, you'll be asked whether or not to add these repositories to your local list:

rob@mac:~/fooApp$ ruby script/plugin discover Add http://svn.techno-weenie.net/projects/plugins/? [Y/n] y Add http://www.delynnberry.com/svn/code/rails/plugins/? [Y/n] y ...

To return a complete list of available plug-ins from the plug-in sources you have configured, use the list command of the plugin script:

rob@mac:~/fooApp$ ruby script/plugin list --remote account_location   http://dev.ruby ... plugins/account_location/ acts_as_taggable   http://dev.ruby ... plugins/acts_as_taggable/ browser_filters    http://dev.ruby ... plugins/browser_filters/ ...

Discussion

The current system for distributing plug-ins is for authors to post links to their plug-in's Subversion repository on the Rails wiki (http://wiki.rubyonrails.org/rails/pages/Plugins). The discover command uses Ruby's open-uri.rb library to retrieve and parse that page for URLs that look like subversion repositories (beginning with svn://, http://, or https://, and containing the string /plugins/). If there are any repository sources that don't exist in ~/.rails-plugin-sources in your home directory, you have the option of adding them when prompted by the script.

Once you have at least one plug-in repository configured, you may query it for available plug-ins with the list command. The list command defaults to searching remote repositories but to be explicit, pass it the remote option. To return a list of currently installed plug-ins locally, pass the local option to the list command:

rob@mac:~/fooApp$ ruby script/plugin list --local             

Here's a summary of the commands that you can use with the plug-in script to manage your plug-in repository list and query local and remotely available plug-ins:


discover

Discovers plug-in repositories listed on the Rails wiki plug-in page


list

Lists available plug-ins based in your configured sources


source

Adds a plug-in source repository manually


unsource

Removes a plug-in repository from ~/.rails-plugin-sources


sources

Lists all currently configured plug-in repositories

Currently, running ruby script/plugin list --remote finds a little more than 100 plug-ins after scraping the plug-ins wiki page. There are a number of plug-ins on the page that are missed by the script because of the lack of /plugins/ in their Subversion URL. The plug-ins page is also supposed to have a short description for every plug-in that should give you a good idea of the problem that each is trying to solve, but many of the posted plug-ins require a bit of creative Internet research to find out exactly what they do and how they work. Look for a more refined plug-in distribution system in the future. Ultimately, it's best to examine the code of plug-ins you're investigating before including them in your project or running generators they may provide.

See Also

  • Agile Web Development plug-in list, http://www.agilewebdevelopment.com/plugins

  • Section 14.2"




Rails Cookbook
Rails Cookbook (Cookbooks (OReilly))
ISBN: 0596527314
EAN: 2147483647
Year: 2007
Pages: 250
Authors: Rob Orsini

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net