|
Module::Mapper - Find source for modules and optionally map to another directory |
Module::Mapper - Find source for modules and optionally map to another directory
use Module::Mapper;
#
# explicit mode
#
$options = (
All => 1,
IncludePOD => 1,
Verbose => sub { print STDERR $_[0], "\n"; },
UseINC => 1,
Libs => [ './lib', './otherlib' ],
Scripts => [ './bin/mapmodule' ],
Output => './classdoc',
Modules => [ 'DBD', 'Module::Mapper', 'Some::Other::Module' ]
);
my $modules = find_sources( %options );
#
# project mode
#
$options = (
IncludePOD => 1,
Verbose => sub { print STDERR $_[0], "\n"; },
Output => './classdoc',
Project => './project'
);
my $modules = find_sources( %options );
Searches specified directories and/or @INC (or both) for the specified
module(s) and/or executable(s). Returns a hashref mapping the module to
an arrayref containing the full path where the sources were found
and (optionally) a mapping output path if the Output option was specified.
If neither Scripts or Modules are specified, the search
is performed in ``project'' mode, which assumes that all scripts
and modules within a project directory tree (specified by Project,
or defaults to './') are to be scanned and remapped. Any files within
the ``$options{Project}/bin'' directory are assumed to be scripts; all
files ending in '.pm' and '.pod' in all directories beneath
the ``$options{Project}/lib'' directory are assumed to be modules.
Only a single method is exported:
Uses the options in %options to direct a search for modules and
executable, and optionally generate a remapped paths for them.
If an error occurs during the search (e.g., a nonexistant directory
is specified in Libs), undef is returned with an error message in
$@.
On success, the returned hashref maps the found module names and/or provided executable script paths to an arrayref consisting of
Output option described below.
Output option
described below.
%options may include the following:
=> $boolean=> $boolean=> \&coderef=> $boolean@INC to be included in the search. Default
is to only search directories explicit specified via Libs.
=> \@locallibsUseINC is specified, directories in <@INC> are searched after
@locallibs.
=> \@scripts=> $outpath
Source Type Mapped Location
----------- ---------------
executables <$outpath>/bin
local modules <$outpath>/blib
@INC modules <$outpath>/lib
NOTE that the output maths are not created; rather, a file specification is provided which can be used by the caller to create the path via (e.g.) the File::Path manpage::mkpath().
=> \@modules@localibs and/or @INC. If the
All option is enabled, then elements may be top level
namespaces within which to search for all child modules.
=> $projpath
This module was developed primarily to support the Pod::Classdoc manpage and the PPI::HTML::CodeFolder manpage, but may be generally useful.
Copyright(C) 2007, Dean Arnold, Presicient Corp., USA. All rights reserved.
Permission is granted to use this software under the terms of the Perl Artistic License.
|
Module::Mapper - Find source for modules and optionally map to another directory |