The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Module::Pluggable::Dependency - order plugins based on inter-plugin dependencies

VERSION

This documentation refers to Module::Pluggable::Dependency version 0.0.3

SYNOPSIS

    package MyClass;
    use Module::Pluggable::Dependency;

and then later ...

    use MyClass;
    my $mc = MyClass->new();
    # returns the names of all plugins installed under MyClass::Plugin::*
    # sorted so that plugins are listed after all their dependencies
    my @plugins = $mc->plugins();

DESCRIPTION

Module::Pluggable::Dependency provides a way to run plugins in situations where one plugin depends on running after other plugins run. This module is similar to Module::Pluggable::Ordered but it determines ordering via dependencies instead of precedence levels.

Each plugin may implement an optional depends method which returns a list of the plugins upon which it depends. Module::Pluggable::Dependency makes sure that plugins are returned in an order which meets the dependency hierarchy.

Why would you use this? Let's say you have a series of plugins for caching complex calculations. Some of the plugins base their complex calculations on the calculations of other plugins. You need to be sure that each plugin is only run after it's dependencies have been run. Because the ordering of plugins is specified through dependencies, additional plugins may be added without manually determining the needed precedence levels.

INTERFACE

Module::Pluggable::Dependency should be a drop-in replacement for Module::Pluggable. It accepts all the same options and just modifies the behavior of the plugins sub (or whatever you named it via sub_name).

depends

Any plugin wanting to indicate it's dependence on another plugin should implement a depends method. The method should return a list of class names for the plugins upon which it depends. For example:

    package My::Plugin::Foo;
    sub stuff { ... }
    
    package My::Plugin::Bar;
    sub stuff { ... }
    sub depends { qw( My::Plugin::Foo ) }

Because My::Plugin::Foo doesn't have a depends method, it's assumed that the plugin has no dependencies. My::Plugin::Bar however, must be run after the "Foo" plugin.

DIAGNOSTICS

Exceptions from Algorithm::Dependency::Ordered are propagated.

CONFIGURATION AND ENVIRONMENT

Module::Pluggable::Dependency requires no configuration files or environment variables.

DEPENDENCIES

  • Module::Pluggable 1.9

  • Algorithm::Dependency 1.04

INCOMPATIBILITIES

None known. You should even be able to use Module::Pluggable::Dependency at the same time as Module::Pluggable and other derived classes.

BUGS AND LIMITATIONS

  • Missing plugin dependencies aren't handled

  • Error reporting for circular plugin dependencies should be handled with a module-specific error message.

Please report any bugs or feature requests to bug-module-pluggable-dependency at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Module-Pluggable-Dependency. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Module::Pluggable::Dependency

You can also look for information at:

AUTHOR

Michael Hendricks <michael@ndrix.org>

LICENSE AND COPYRIGHT

The MIT License

Copyright (c) 2006 Michael Hendricks (<michael@ndrix.org>).

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.