Dependencies::Searcher - Search recursively dependencies used in a module's directory and build a report that can be used as a Carton cpanfile.
Maybe you don't want to have to list all the dependencies of your application by hand, or maybe you forgot to do it for a long time ago. During this time, you've add lots of CPAN modules. Carton is here to help you manage dependencies between your development environment and production, but how to keep track of the list of modules you will give to Carton?
You will need a tool that will check for any 'requires' or 'use' in your module package, and report it into a file that could be used as a Carton cpanfile. Any duplicated entry will be removed and versions are available.
This project has begun because it happens to me, and I don't want to search for modules to install, I just want to run a simple script that update the list in a simple way.
use Dependencies::Searcher; my $searcher = Dependencies::Searcher->new(); my @elements = $searcher->get_files(); my $path = $searcher->build_full_path(@elements); my @uses = $searcher->get_modules($path, "use"); my @uniq_modules = $searcher->uniq(@uses); $searcher->dissociate(@uniq_modules); $searcher->generate_report($searcher->non_core_modules);
This is work in progress...
Us-e Ack to get modules and store lines into arrays
Retrieve names of : * lib/ directory, if it don't exist, we don't care and die * Makefile.PL * script/ directory, if we use a Catalyst application * ... only if they exists !
Merge use and requires
Remove special cases that can't be interesting.
Remove everything but the module name. Remove dirt, clean stuffs...
Make each array element uniq
Dissociate core / non-core modules
Generate the cpanfile for Carton, with optionnal version number
smonff, <smonff at gmail.com>
<smonff at gmail.com>
Please report any bugs or feature requests to bug-dependencies-searcher at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dependencies-Searcher. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-dependencies-searcher at rt.cpan.org
https://github.com/smonff/dependencies-searcher/issues
You can find documentation for this module with the perldoc command.
perldoc Dependencies::Searcher
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dependencies-Searcher
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Dependencies-Searcher
CPAN Ratings
http://cpanratings.perl.org/d/Dependencies-Searcher
Search CPAN
http://search.cpan.org/dist/Dependencies-Searcher/
Brian D. Foy's Module::Extract::Use
Was the main inspiration for this one. First, I want to use it for my needs but is was not recursive...
See https://metacpan.org/module/Module::Extract::Use
Module::CoreList
What modules shipped with versions of perl. I use it extensively to detect if the module is from Perl Core or not.
See http://perldoc.perl.org/Module/CoreList.html
Andy Lester's Ack
I've use it as the main source for the module. It was pure Perl so I've choose it, even if Ack is not meant for being used programatically, this use do the job.
See http://beyondgrep.com/
See also https://metacpan.org/module/Perl::PrereqScanner http://stackoverflow.com/questions/17771725/
Copyright 2013 smonff.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Dependencies::Searcher, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dependencies::Searcher
CPAN shell
perl -MCPAN -e shell install Dependencies::Searcher
For more information on module installation, please visit the detailed CPAN module installation guide.