File Coverage

blib/lib/POE/Component/DirWatch/Unmodified.pm
Criterion Covered Total %
statement 4 6 66.6
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 6 8 75.0


line stmt bran cond sub pod time code
1             package POE::Component::DirWatch::Unmodified;
2              
3 1     1   920 use POE;
  1         2  
  1         5  
4 1     1   448 use Moose;
  0            
  0            
5              
6             our $VERSION = "0.300002";
7              
8             extends 'POE::Component::DirWatch';
9             with 'POE::Component::DirWatch::Role::Signatures';
10              
11             #--------#---------#---------#---------#---------#---------#---------#---------
12              
13             around _file_callback => sub {
14             my $orig = shift;
15             my ($self, $kernel, $file) = @_[OBJECT, KERNEL, ARG0];
16             my $sig = delete $self->signatures->{"$file"};
17             return unless defined $sig && $sig->is_same;
18             $orig->(@_);
19             };
20              
21             __PACKAGE__->meta->make_immutable;
22              
23             1;
24              
25             __END__;
26              
27             #--------#---------#---------#---------#---------#---------#---------#---------
28              
29              
30             =head1 NAME
31              
32             POE::Component::DirWatch::Unmodified
33              
34             =head1 DESCRIPTION
35              
36             POE::Component::DirWatch::Unmodified extends DirWatch::New to
37             exclude files that appear to be in use or are actively being changed. To
38             prevent files from being processed multiple times it is adviced that files
39             are moved after successful processing.
40              
41             This module consumes the L<POE::Component::DirWatch::Role::Signatures> role,
42             please see its documentation for information about methods or attributes
43             it provides or extends.
44              
45             =head1 METHODS
46              
47             =head2 _file_callback
48              
49             C<around '_file_callback'> is modified to only execute the callback if the file
50             has been seen previously and its signature has not changed since the last
51             poll. This behavior means that callbacks will not be called until the second
52             time they are seen.
53              
54             =head2 meta
55              
56             Keeping tests happy.
57              
58             =head1 SEE ALSO
59              
60             L<POE::Component::DirWatch>, L<Moose>
61              
62             =head1 COPYRIGHT
63              
64             Copyright 2006-2008 Guillermo Roditi. This is free software; you may
65             redistribute it and/or modify it under the same terms as Perl itself.
66              
67             =cut
68