NAME

File::Collector::Processor - Base class for custom File::Collector::Processor classes for processing files classified by a File::Collector class.

VERSION

version 0.031

OVERVIEW

This is the base class for custom File::Collector::Processor classes and is intended to package methods used to manipulate and inspect files and data contained in a File::Collector object. To keep this class small and manageable, it's recommended any heavy file processing be done inside the objects associated with the files.

File::Collector::Processor objects are not intended to be constructed directly. Instead, they are created by their respective File::Collector classes for you automatically.

SYNOPSIS

package File::Collector::CustomClassifier::Processor

use parent 'File::Collector::Processor';

sub a_useful_method {
  my $s = shift;

  # do useful stuff
  ...
}

sub another_useful_method {
  my $s = shift;

  # do more useful stuff
  ...
}

sub get_data {
  my $s = shift;
  return $s->get_obj_prop ( 'obj_name', 'some_values' );
}

DESCRIPTION

Methods in the Processor classes are typically called from a custom File::Collector class which should use your custom Processor class. All methods described will be available to your Collector class as well as the Processor class.

Collector Methods

The methods can be run on Collector objects after they've been constructed.

do()

$collector->some_files->do->run_method;

The do method iterates over all the files classified under the name of the method call preceding it. In the example above, it will iterate over all the files classified under "some" by the custom Collector classes using the _classify_file method. For each file found in the specified category, it will call run_method of the Processor class returned by the do call.

So for example, if you wanted to delete all the files classified as "bad" files, that might look something like this:

$collector->bad_files->do->delete;

The example delete method will takes care of deleting the file for you and might look somethink like this:

sub delete {
  my $s = shift;
  unlink $s->selected
}

Note that we use $s->selected to refer to the file currently selected by the Processor's iterator. See File::Collector::Base for more details.

next()

Initiates a Processor class' iterator on the first call. Iterates over the files in the Processor on subsequent calls. Returns a boolean false when the iterator is exhausted/empty. Otherwise, it returns the full path the current file in the iterator.

REQUIRES

BUGS AND LIMITATIONS

You can make new bug reports, and view existing ones, through the web interface at https://github.com/sdondley/File-Collector/issues.

INSTALLATION

See perlmodinstall for information and options on installing Perl modules.

SEE ALSO

File::Collector

AUTHOR

Steve Dondley <s@dondley.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2019 by Steve Dondley.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.