Plugins++ (engines lite)

12 Jun 2006, 03:24 »

Ezra Zygmuntowicz has spilled forth and excellent bit of Plugin-fu over at caboo.se earlier in the day.

Essentially, with a few lines in init.rb, you can store controllers, models, and helpers in an app-like structure within your plugin. An extra addition to each controller can hook up views within your plugins.

The improvements in Rails 1.1 have made creating powerful plugins like this really easy - it's come a long way since I had to delve deep into the core frameworks to create the first versions of the engines plugin.

While Ezra's technique doesn't have all the bells and whistles that the engines plugin might endow, it's a significant part of the core functionality. I wait unti I have time to refactor the rest of the additions that engine developers might need into something similarly bite-sized and easy to digest :)

something from which I have spared you all

(recently removed from a work in progress)

To illustrate, lets consider the story of Harry Coder, who has been working the next great web application – Incantr Beta, a social tagging folksonomic Web 3.0 mash-up targeted at young magicians (naturally).

Harry Coder and the Order of the Commits

Harry decides to bring his good friend Hermione on board as a developer, since he tends to spend most of his time running around getting into trouble rather than doing any work. Since Hermione likes to work in the library, whereas Harry prefers to develop in a shed on the edge of a forest, they agree to work on the code on their laptops, and then save it back to a central shared directory on Ron's fileserver every night, so they can each see any changes the other might have made.

As term progresses Harry's dedication to the project wanes, as is so typical for him, replaced by some self-important notion that the world not only revolves around him, but is also conspiring to plot his ultimate demise. In fact, the last time he touched the code was in September. Hermione does her best to entertain these ideas, but continues working steadily on Incantr all the way through to spring, undeterred.

Then, one sunny day after examinations, Harry decides to finally save those changes he made last year back to the shared folder on Ron's server. Without a care in the world, Harry drops his old, out of date version of Incantr into the folder, completely wiping out all of the work that Hermione had done for the entire year! What's more, there's no way to get it back, short of a Time Turner!

Oh dear, Harry. Thought you had problems before?

Harry Coder and the Half-baked Product

Let us imagine that our protagonists start again the next year, with the explicit understanding that Harry is going to be a bit more careful about overwriting newer files. With the announced public release only a few days away, Harry realizes (in an uncharacteristic moment of hard-working clarity) that a change to the code made last month has broken one of the key features!

Can he recall the exact set of changes made on that fateful afternoon? Even if he's reasonably sure he can remember what changed, will he be able to undo that change without wreaking more havoc with the code base? Does he even have a copy of the code as it was back then?

It is a truly chilling tale. Will Harry and his friends have to use the Dark Arts to solve their integration issues?

OK. Harry Potter. We get it. Stop now please.

Really?

Yes.

Oh... OK. Where was I? Ah yes. Version control.

© All content is available under the creative commons, except where I didn't write the stuff, in which case you'll need to track down the original author. I'm notoriously bad at citing references. Needless to say the text here is not guaranteed to reflect my opinions, or indeed the opinions of any sane person. Developed on a Mac.. Powered by PURE EVIL.