Currently plugins load as follows (psuedocode):
for each plugin directory:
add plugin directory/lib to $LOAD_PATH (if it exists)
execute plugin directory/init.rb
I think it would be better to change this to:
for each plugin directory:
add plugin directory/lib to $:
for each plugin directory:
execute plugin directory/init.rb
The reason for this is that I have a general plugin that does a lot of
stuff, and a specific one that extends part of it for a specific site
(so the specific plugin depends on the general one). I’d like to be
able to do:
in specific_plugin/init.rb
require ‘general_plugin’
require ‘specific_plugin’
However, this fails if specific plugin is loaded before general plugin
(and you can’t choose the order). You can fix it by doing:
in specific_plugin/init.rb
$:.push(File.join(RAILS_ROOT, ‘vendor’, ‘plugins’, ‘general_plugin’,
‘lib’))
require ‘general_plugin’
require ‘specific_plugin’
Obviously, I’d just like to eliminate that additional line. After
poking around in the source, I tried this:
in specific_plugin/init.rb
load_plugin ‘general_plugin’
require ‘specific_plugin’
But that doesn’t work, probably because it doesn’t have the full path.
This is probably the best I can do at this point:
in specific_plugin/init.rb
load_plugin File.join(RAILS_ROOT, ‘vendor’, ‘plugins’, ‘general_plugin’)
require ‘specific_plugin’
Any thoughts on changing plugin loading? If other people think this
is a good idea (and the powers that be approve), it should be fairly
simple to come up with a patch.