I just recently created Ticket #9793, which includes a simple patch to add plugin lib directories to the load path before plugins are loaded "properly".
In building the patch on #9793, I couldn't help but feel that I was fighting against the existing implementation of Rails::Plugin::Loader and Rails::Plugin::Locator. The load_plugins loop in Rails::Initializer is difficult to refactor, and difficult to test, and the relationship between a "plugin" and a "plugin loader" and a "plugin locator" didn't seem clear to me.
So, while I imagine that the patch on my previous ticket (#9793) will be applied in favour of the patch attached here, I would really like some feedback about this approach (anyone who doesn't care can happily stop reading now :)) as I think there's definite value in it.
In the patch, I've cleared up the responsibilities of the Loader and Locator, and added a new class (Rails::Plugin), so now it's hopefully easier to develop in the future. In particular, I felt it was important that Rails::Plugin::Loader was broken into two classes (most of the functionality in Rails::Plugin comes from Loader), because it didn't feel right that the object which represented a plugin could order itself based on a configuration setting obtained in a convoluted fashion from the Initialiser instance.
With this patch, Plugin instances are returned by the Locator, which are then passed to the Loader. The Loader determines which plugins should be loaded, and takes care of loading them in the right order. The Plugin instance itself contains most the logic for "loading" a plugin (i.e. evaluating init.rb).
The upshot is that I think this implementation is easier to extend, but also much easier to test - much of the bulk of this patch is testing. The rest is just a fairly aggressive refactoring of the classes that were already there, to try and make sense of the way that each type of object interacts.
Again, I'm eager to get some feedback about this, so I'm looking forward to your comments.