POE::Component::DirWatch::Role::Signatures - POE::Component::DirWatch::Role::Signatures documentation


POE-Component-DirWatch documentation Contained in the POE-Component-DirWatch distribution.

Index


Code Index:

NAME

Top

POE::Component::DirWatch::Role::Signatures

DESCRIPTION

Top

POE::Component::DirWatch::Role::Signatures is a role which provides File::Signature functionality to DirWatch-based classes. It will keep a hashref of signatures of the files processing to allow you to determine if a file has changed.

ATTRIBUTES

Top

signatures

Read-write. Will return a hashref in which keys will be the full path of the files seen and the value will be a stringified File::Signature object.

METHODS

Top

file_callback

after '_file_callback' Add the file's signature to signatures if it doesnt yet exist.

_poll

before '_poll' the list of known files is checked and if any of the files no longer exist they are removed from the list of known files.

SEE ALSO

Top

File::Signature, POE::Component::DirWatch, Moose

COPYRIGHT

Top


POE-Component-DirWatch documentation Contained in the POE-Component-DirWatch distribution.

package POE::Component::DirWatch::Role::Signatures;

use POE;
use Moose::Role;
use File::Signature;

our $VERSION = "0.300000";

has signatures => (
  is => 'ro',
  isa => 'HashRef',
  required => 1,
  default => sub { {} }
);

after _file_callback => sub {
  my ($self, $file) = @_[OBJECT, ARG0];
  $self->signatures->{ "$file" } ||= $self->_generate_signature($file);
};

before _poll => sub {
  my $sigs = shift->signatures;
  delete($sigs->{$_}) for grep {! -e $_ } keys %$sigs;
};

sub _generate_signature{
  my ($self, $file) = @_;
  return "" . File::Signature->new( "$file" ) . "";
}

1;

__END__;

#--------#---------#---------#---------#---------#---------#---------#---------