Dependencies::Searcher::AckRequester - Helps Dependencies::Searcher to use Ack
my $requester = Dependencies::Searcher::AckRequester->new(); # Places to search... my @path = ("./lib", "./Makefile.PL", "./script"); # Params for Ack my @params = ('--perl', '-hi', $pattern, @path); # Absolute path to the Ack binary my $ack_path = $requester->get_path(); # Build the command for IPC::Cmd my $cmd_use = $requester->build_cmd(@params); # Execute the command and retrieve the output my @moduls = $requester->ack($cmd_use);
This module use ack through a system command to search recursively for patterns. It use IPC::Cmd as a layer between the module and ack, that execute and retrieve the command output.
It also builds the command itself (path and arguments). Arguments are stored into an array, because it is too much dangerous to build a command with strings (space problems are one reason among others).
It's not made to be used independantly from Dependencies::Searcher (mean it's not supposed to be used directly into your programs, but you can try if you want...)
Returns the ack full path if installed. Set the full_path Moose attribute that will be used by ICP::Cmd. It verify also that Ack is reachable or warns about it.
full_path
build_cmd() takes as parameter all the arguments Ack will need. Dependencies::Searcher defines it like this :
build_cmd()
--perl : tells to search in Perl like files (*.pm, *.pl, etc.)
--perl
*.pm
*.pl
-hi : suppress the prefixing filename on output + ignore case
-hi
$pattern : must be passed from your implementation
$pattern
@path : files and directories where ack will go
@path
All these params are merged in an only array reference that is returned for later use with IPC::Cmd.
Execute the IPC::Cmd command that calls ack and returns an array of potentially interesting lines, containing dependencies names but some crap inside too.
ack
Win32 and Cygwin platforms aren't well supported but last tests have not been that bad.
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
smonff, <smonff at gmail.com>
<smonff at gmail.com>
Ack gives me the wish to try to write this module. It was pure Perl so I've choose it because it was possible to install it through CPAN during the distribution installation process. Even if Ack was not meant for being used programatically, this hacked use of Ack do the job.
See http://beyondgrep.com/
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.