The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Dependencies::Searcher - Manage your dependencies list in a convenient way

SYNOPSIS

Search recursively dependencies used in a module's directory and build a report that can be used as a Carton cpanfile.

    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);

    # Prints
    # requires Data::Printer, 0.35
    # requires Moose, 2.0602
    # requires IPC::Cmd
    # requires Module::Version

DESCRIPTION

Maybe you don't want to have to list all the dependencies of your Perl application by hand and want an automated way to build it. 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 pass to to Carton?

Event if it is a no brainer to keep track of this list, it can be much better not to have to do it.

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 modules versions will be checked and made available. Core modules will be ommited because you don't need to install them.

This project has begun because it happens to me, and I don't want to search for modules to install by hand, I just want to run a simple script that update the list in a simple way. It was much more longer to write the module than to search by hand but I wish it will be usefull for others.

SUBROUTINES/METHODS

This is work in progress...

Dependencies::Searcher->get_modules()

Us-e Ack to get modules and store lines into arrays

Dependencies::Searcher->get_files()

TODO

Dependencies::Searcher->build_full_path()

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 !

Dependencies::Searcher->merge_dependencies()

Merge use and requires

Dependencies::Searcher->make_it_real()

Remove special cases that can't be interesting.

Dependencies::Searcher->clean_everything()

Remove everything but the module name. Remove dirt, clean stuffs...

Dependencies::Searcher->uniq()

Make each array element uniq

Dependencies::Searcher->dissociate()

Dissociate core / non-core modules

Dependencies::Searcher->generate_report()

Generate the cpanfile for Carton, with optionnal version number

Log::Minimal::PRINT override

Just override the way Log::Minimal is used. We create a .out file in ./t directory. To see log, use tail -v /path/to/the/module/t/dependencies-searcher.[y-M-d].out

AUTHOR

smonff, <smonff at gmail.com>

BUGS

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.

TODOs

https://github.com/smonff/dependencies-searcher/issues

SUPPORT

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

    perldoc Dependencies::Searcher

You can also look for information at:

ACKNOWLEDGEMENTS

  • 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/

LICENSE AND COPYRIGHT

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.