Archives for Oct 2006

Plugin Dependencies

Aaron (obrie to most of the Rails community) has launched the PluginAWeek project, to open source 25,000 lines of code in over 70 plugins. In his various posts, Aaron goes into his “Theory of Plugins” to explain why he needs them, and why his plugin_dependencies plugin matters.

For me though, the current state of Rails plugins works just fine. I haven’t written any plugins that really depend on any others. I try to write small plugins without much coupling if I can. Occasionally I will need plugins to be loaded first, such as my gems. Mephisto needs any liquid plugins to be loaded after Liquid has been loaded. Since M comes after L, this hasn’t been an issue. Had I named the project Aardvark or something, then I’d rename the plugin aaa_liquid. A little crufty perhaps, but then I don’t have to add require_plugin 'liquid' to all of those plugins. Course, they do depend on the plugin technically, so that’s not a big deal. But, should I add require_plugin 'gems' to all of my plugins because I happen to use that gem a lot?

Those are really basic examples, and definitely not on the scale of the project Aaron is working on. So, let’s imagine a plugin that implemented versioned pages with attached images. (Note: this is a contrived example to prove a single point. I’m not claiming to have a plugin like this, or that one of Aaron’s plugins is like this) Some might make a plugin that adds models like this:

1
2
3
4
5
6
7
8
9
class Photo < ActiveRecord::Base
  acts_as_attachment ...
end

class Content < ActiveRecord::Base
  acts_as_versioned
  acts_as_paranoid
  has_many :photos
end

That’s a horrible plugin. It really ties you into those models, and causes more work than it would be to actually write from scratch. So, how about a simple macro like acts_as_content (yes, I realize this is a lame and contrived example, but stay with me).

1
2
3
4
5
6
7
8
9

module ActsAsContentPlugin
  def acts_as_content
    acts_as_versioned
    acts_as_paranoid
  end
end

ActiveRecord::Base.extend ActsAsContentPlugin

The actual method isn’t actually executed until the Content model has been loaded. So yes, my example plugin depends on two of my plugins, but it doesn’t matter what order they’re loaded in. Of course, this is an example of how acts_as_* plugins can be used to delegate, and cut down on coupling. I can definitely see other situations where this wouldn’t be possible. However, I’m not sure this is common practice for most plugin developers, so I wouldn’t like having this new plugin dependency behavior being default.

At any rate, I’m anxious to see what treats Aaron has in store for us. I’m sure these 70 plugins will be a very useful addition to the Rails community. It’s great to see folks taking the time to properly contribute some open source code back to the community, rather than acting as a black hole.

0 comments | posted 31 Oct 11:36

java applets have officially been deprecated

see fireworks.js

0 comments | posted 29 Oct 22:58

simply_bdd update

I’ve made a nice little update to my simply_bdd plugin:

You can specify a superclass for context so the class inherits from it instead:

1
2
3
context "Post Controller Creation", PostControllerTest do
  ...
end

You can also nest context calls to get automatic inheritance:

1
2
3
4
5
context "Post Controller" do
  context "Post Controller Creation" do
    ...
  end
end

0 comments | posted 14 Oct 16:36

Mephisto Asset Management is "like a video game"

> Have you guys checked out Mephisto ?
> They have a very compelling way of adding files to articles.
Yes, it’s an interesting take! Kind of a like a video game.

Improving TXP Image Management in the textpattern forums

What video game is Mephisto like? Beast has already been compared to Altered Beast.

0 comments | posted 10 Oct 10:46

test caching in your app

Tom Ward wrote a nifty plugin for properly testing page and fragment caching in your rails applications.

0 comments | posted 08 Oct 09:33

Google Code Search

0 comments | posted 05 Oct 00:48