NAME
Plugin::Loader - finding and loading modules in a given namespace
SYNOPSIS
use Plugin::Loader;
my $loader = Plugin::Loader->new;
my @plugins = $loader->find_modules('MyApp::Plugin');
foreach my $plugin (@plugins) {
$loader->load($plugin);
}
DESCRIPTION
This module provides methods for finding modules in a given namespace, and then loading them. It is intended for use in situations where you're looking for plugins, and then loading one or more of them.
This module was inspired by Mojo::Loader, which I have used in a number of projects. But some people were wary of requiring Mojolicious just to get a module loader, which prompted me to create Plugin::Loader
.
METHODS
find_modules
Takes a namespace, and returns all installed modules in that namespace, that were found in @INC
. For example:
@plugins = $loader->find_modules('Template::Plugin');
This will find all modules in the given namespace, regardless of depth. For example, it will find Template::Plugin::File and Template::Plugin::Filter::Minify::JavaScript.
load_module
Takes a module name and tries to load the module. If loading fails, then we croak
.
SEE ALSO
Mojo::Loader, all, lib::require::all, MAD::Loader, Module::Find, Module::Recursive::Require, Module::Require.
REPOSITORY
https://github.com/neilbowers/Plugin-Loader
AUTHOR
Neil Bowers <neilb@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Neil Bowers <neilb@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.