DirWatch/Role/AIO.pm

filter: Statementstmt 91.4% 43 / 47 Branchbran 40.0% 4 / 10 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 10 / 10 Podpod n/a totaltotal 75.3% 58 / 77 CC 10 SCAR 25.7
CC
10
Cov
76%
__ANON__
23.8
__ANON__
1.1
BEGIN
1.0
CRAP 13.0
↑ Summary DirWatch/Unmodified.pm »
1 package POE::Component::DirWatch::Role::AIO;
2  
3 4 our $VERSION = "0.300004";
4  
5 4 ▶use POE;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use IO::AIO qw/2/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use POE::Component::AIO { no_auto_export => 1, no_auto_bootstrap => 1 };
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Path::Class qw(file dir);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 has aio => (
12 is => 'ro',
13 isa => 'POE::Component::AIO',
14 required => 1,
15 clearer => 'clear_aio',
16 3 ▶ default => sub { POE::Component::AIO->new }
Subroutine __ANON__: called CC=1 SCAR=0.0
17 4 );
18  
19 3 ▶after _start => sub {
Subroutine __ANON__: called CC=1 SCAR=1.0
20 3 my $self = $_[OBJECT];
21 9 ▶ my $aio_cb = sub {
Subroutine __ANON__: called CC=10 SCAR=31.7
22 9 my ($kernel, $dirs, $nondirs) = @_[KERNEL, ARG0, ARG1];
23 9 ▶ my $filter = $self->has_filter ? $self->filter : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->has_filter ? : 0 9 9
24 9 ▶ if( $self->has_dir_callback ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_dir_callback) 0 9 9
25 0 foreach my $child (@$dirs){
26 0 $child = dir($self->directory, $child);
27 0 ▶ next if ref $filter && !$filter->($child);
Branch: 1 branch
BranchTrueFalseTotal
if ref $filter and not &$filter($child) 0 0 0
Condition0%0/3
ref $filter and not &$filter($child)
!ll&&!rl&&r
000
MC/DC0%0/2
ref $filter and not &$filter($child)
ref $filter not &$filter($child)
Truth table0%0/3
A and not(B)
A= ref $filterB= not &$filter($child)
ABresult
0X0
100
111
28 0 $kernel->yield(dir_callback => $child);
29 }
30 }
31 9 ▶ if( $self->has_file_callback ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_file_callback) 9 0 9
32 9 foreach my $child (@$nondirs){
33 14 $child = file($self->directory, $child);
34 14 ▶ next if ref $filter && !$filter->($child);
Branch: 1 branch
BranchTrueFalseTotal
if ref $filter and not &$filter($child) 0 14 14
Condition33%1/3
ref $filter and not &$filter($child)
!ll&&!rl&&r
1400
MC/DC0%0/2
ref $filter and not &$filter($child)
ref $filter not &$filter($child)
Truth table33%1/3
A and not(B)
A= ref $filterB= not &$filter($child)
ABresult
0X0
100
111
35 14 $poe_kernel->yield(file_callback => $child);
36 }
37 }
38 9 $self->next_poll( $kernel->delay_set(poll => $self->interval) );
39 3 };
40  
41 3 $_[KERNEL]->state(aio_callback => $aio_cb);
42 4 };
43  
44 9 ▶around _poll => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
45 9 my $super = shift;
46 9 my ($self, $kernel) = @_[OBJECT, KERNEL];
47 9 $self->clear_next_poll;
48 9 my $dir = $self->directory->stringify;
49 9 aio_scandir $dir, 0, $self->aio->postback('aio_callback');
50 4 };
51  
52 3 ▶before _shutdown => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
53 3 my ($self, $kernel) = @_[OBJECT, KERNEL];
54 3 $kernel->state('aio_callback');
55 3 $self->aio->shutdown;
56 3 $self->clear_aio;
57 4 };
58  
59 4 1;
60  
61 __END__;
↑ Summary DirWatch/Unmodified.pm »