December 12, 2006

Managing Rails Plugins with Piston
Post by Chris Wanstrath of ErrTheBlog

This entry was written by Chris Wanstrath of ErrTheBlog. Ruby Inside thinks ErrTheBlog is one of the best Ruby / Rails blogs out there right now, so definitely check it out.

Piston is a tool for keeping bits and pieces of your Subversion repository in sync with a remote repository. Like svn:externals, but better. How?

With Piston, you import a remote repository and check it into your local repository. You can then go nuts modifying it or periodically sync it up with its remote origin using piston update.

There's an advent calendar full of reasons why you'd want to manage Rails plugins with Piston rather than using svn:externals. For one thing, it makes checkouts and updates faster -- code is all kept in the same repository so you don't need to query foreign repositories on every svn up. It also gives you simple control over which reversion of a plugin you keep around -- it's really not ideal to have your plugins updating to the bleeding edge all the time. You could set your external to a tag, but what plugin author uses tags? Seriously. Piston makes life easier.

Install it:

$ gem install piston -y
Successfully installed piston-1.2.1

Import a plugin (from your Rails app's root directory):

$ piston import vendor/plugins/simply_helpful
Exported r5630 from '' to 'vendor/plugins/simply_helpful'

Convert an existing svn:externals directory into Piston-style:

$ piston convert
Importing '' to vendor/rails (-r 4720)
Exported r4720 from '' to 'vendor/rails'

Done converting existing svn:externals to Piston  

Grab remote updates (plugin was updated, you want the updates):

$ piston update vendor/plugins/simply_helpful/
Updated to r5710 (4 changes)

See directories under Piston's watch in your project:

$ piston status
     vendor/plugins/simply_helpful (
     vendor/plugins/annotate_models (
M    vendor/plugins/acts_as_attachment (
     vendor/plugins/acts_as_textiled (svn://
     vendor/plugins/mocha (svn://
     vendor/plugins/has_many_polymorphs (svn://   

Make sure a directory can't be updated:

$ piston lock vendor/plugins/simply_helpful/
'vendor/plugins/simply_helpful/' locked at revision 5710

Predictably, unlock:

$ piston unlock vendor/plugins/simply_helpful/
'vendor/plugins/simply_helpful/' unlocked.

Check out Piston's daily usage page or developer François Beausoleil's blog for more slickness.