Re: plugin dependencies

Aaron Pfeifer
Wed, 19 Sep 2007 15:42:07 -0000

Indeed, I actually had proposed this way back when:
http://dev.rubyonrails.org/ticket/6418#comment:17.  I''m not sure why I
came to the conclusion that this was already being done on edge.  I
think this did result in some other issues that needed to be
considered, such as:
1. When a plugin is loaded, it''s lib path always comes before other
plugins, therefore if I trying to require a file called "node",
it''ll
look in my plugin''s lib path before looking elsewhere.  This would not
be the case with the paths added before initialization.
2. Similarly, the order of the paths would not reflect the order in
which the plugins were loaded, resulting in potential issues with the
priority in which files are loaded
3. You would still need support for loading gems as plugins because
otherwise they would not go through the same motions as normal plugins
(such as evaluating the init.rb).
4. You''d need support for loading tasks from gems.
5. If you call require ''encrypted_strings'', and
encrypted_strings/lib/
encrypted_strings.rb gets loaded, then the plugin is still going to
get loaded again later on if it''s in vendor/plugins.  This again means
that the list of plugins loaded is out of order and would break
engines/plugins+.

That''s all I can think of right now.  I certainly agree that this
would be simpler, although I''m not sure if it brings up additional
issues that need to be addressed.  Any technique that allows us to
describe dependencies in the plugins and not in the application''s
configuration I support.

On Sep 19, 11:19 am, "James Adam" <james.a...@gmail.com>
wrote:
> On 9/19/07, Aaron Pfeifer <aaron.pfei...@gmail.com> wrote:
>
> > Say we have 2 plugins, encrypted_strings and encrypted_attributes
> > (which depends on encrypted_strings).  In this case, we do the
> > following:
>
> > encrypted_attributes/init.rb:
> > require ''encrypted_attributes''
>
> > encrypted_attributes/lib/encrypted_attributes.rb:
> > require ''encrypted_strings''
> > ...do stuff...
>
> > With plugin_dependencies loaded, this will look for encrypted_strings
> > as either a vendor/plugin within the application or as a gem.  This
> > lets me be flexible in case I want the same plugin/gem/whatever used
> > across multiple applications in a single environment.
>
> Ignoring anything about requiring specific versions, couldn''t this
be
> achieved by having all of the plugins added to the load path before
> any init.rb files are evaluated (my suggestion above)? That way the
> normal Ruby "require" would seem to provide everything that you
> describe here.
>
> --
> * J *
>   ~