CPAN-Visitor
view release on metacpan or search on metacpan
The "select" method returns a count of files selected.
iterate
$visitor->iterate( @args );
Valid arguments include:
* "jobs" â non-negative integer specifying the maximum number of
forked processes. Defaults to none.
* "check" â code reference callback
* "start" â code reference callback
* "extract" â code reference callback
* "enter" â code reference callback
* "visit" â code reference callback
* "leave" â code reference callback
* "finish" â code reference callback
See "ACTION CALLBACKS" for more. Generally, you only need to provide the
"visit" callback, which is called from inside the unpacked distribution
directory.
The "iterate" method always returns true.
ACTION CALLBACKS
Each selected distribution is processed with a series of callback
functions. These are each passed a hash-ref with information about the
particular distribution being processed.
sub _my_visit {
my $job = shift;
# do stuff
}
The job hash-ref is initialized with the following fields:
* "distfile" â the unique, short CPAN distfile name, e.g.
DAGOLDEN/CPAN-Visitor-0.001.tar.gz
* "distpath" â the absolute path the distribution archive, e.g.
/my/cpan/authors/id/D/DA/DAGOLDEN/CPAN-Visitor-0.001.tar.gz
* "tempdir" â a File::Temp directory object for extraction or other
things
* "stash" â the 'stash' hashref from the Visitor object
* "quiet" â the 'quiet' flag from the Visitor object
* "result" â an empty hashref to start; the return values from each
action are added and may be referenced by subsequent actions
The "result" field is used to accumulate the return values from action
callbacks. For example, the return value from the default 'extract'
action is the unpacked distribution directory:
$job->{result}{extract} # distribution directory path
You do not need to store the results yourself â the "iterate" method
takes care of it for you.
Callbacks occur in the following order. Some callbacks skip further
processing if the return value is false.
* "check" â determines whether the distribution should be processed;
goes to next file if false; default is always true
* "start" â used for any setup, logging, etc; default does nothing
* "extract" â operate on the tarball to prepare for visiting; skips to
finish action if it returns a false value; the default extracts a
distribution into a temp directory and returns the path to the
extracted directory; if the "stash" has a true value for
"prefer_bin", binary tar, etc. will be preferred. This is faster,
but less portable.
* "enter" â skips to the finish action if it returns false; default
takes the result of extract, chdir's into it, and returns the
original directory; if the extract result is missing the +x
permissions, this will attempt to add it before calling chdir.
* "visit" â examine the distribution or otherwise do stuff; the
default does nothing;
* "leave" â default returns to the original directory (the result of
enter)
* "finish" â any teardown processing, logging, etc.
These allow complete customization of the iteration process. For
example, one could do something like this:
* replace the default "extract" callback with one that returns an
arrayref of distribution files without actually unpacking it into a
physical directory
* replace the default "enter" callback with one that does nothing but
return a true value; replace the default "leave" callback likewise
* have the "visit" callback get the "$job->{result}{extract}" listing
and examine it for the presence of certain files
This could potentially speed up iteration if only the file names within
the distribution are of interest and not the contents of the actual
files.
SEE ALSO
* App::CPAN::Mini::Visit
* CPAN::Mini::Visit
SUPPORT
Bugs / Feature Requests
Please report any bugs or feature requests through the issue tracker at
<https://github.com/dagolden/CPAN-Visitor/issues>. You will be notified
automatically of any progress on your issue.
Source Code
This is open source software. The code repository is available for
public review and contribution under the terms of the license.
<https://github.com/dagolden/CPAN-Visitor>
( run in 0.485 second using v1.01-cache-2.11-cpan-0d23b851a93 )