| 1 | package POE::Component::DirWatch::WithCaller; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | our $VERSION = "1.00"; | |||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use POE; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | extends 'POE::Component::DirWatch'; | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | has ignore_seen => ( | |||||||||||||||||||||||||||||||||||||||||
| 14 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 15 | isa => 'Int', | ||||||||||||||||||||||||||||||||||||||||||
| 16 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 17 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | has ensure_seen => ( | |||||||||||||||||||||||||||||||||||||||||
| 20 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 21 | isa => 'Int', | ||||||||||||||||||||||||||||||||||||||||||
| 22 | required => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 23 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 25 | has seen_files => ( | ||||||||||||||||||||||||||||||||||||||||||
| 26 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 27 | isa => 'HashRef', | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | default => sub{{}}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | override '_poll' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=19 SCAR=59.4
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | # the vast majority of this is copied from POE::Component::DirWatch's _poll subroutine by virtue of not being able to call super | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my ($self, $kernel) = @_[OBJECT, KERNEL]; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | $self->clear_next_poll; | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | # seen_files portions borrowed from POE::Component::DirWatch::Object::NewFile | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | %{ $self->seen_files } = map {$_ => $self->seen_files->{$_} } grep {-e $_ } keys %{ $self->seen_files }; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | my $filter = $self->has_filter ? $self->filter : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my $has_dir_cb = $self->has_dir_callback; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $has_file_cb = $self->has_file_callback; | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | while (my $child = $self->directory->next) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if($child->is_dir) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | next unless $has_dir_cb; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | next if ref $filter && !$filter->($self->alias, $child); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $filter and not &$filter($self->alias, $child)
MC/DC0%0/2
ref $filter and not &$filter($self->alias, $child)
ref $filter
not &$filter($self->alias, $child)
Truth table0%0/3
A and not(B)
A= ref $filterB= not &$filter($self->alias, $child)
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $kernel->yield(dir_callback => $child); | |||||||||||||||||||||||||||||||||||||||||
| 47 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | next unless $has_file_cb; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | next if $child->basename =~ /^\.+$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | $self->seen_files->{"$child"} = 0 if not defined $self->seen_files->{"$child"}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | next unless $self->seen_files->{"$child"} == 0 or $self->seen_files->{"$child"} > 120 or not $self->ignore_seen; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->seen_files->{"$child"} == 0 or $self->seen_files->{"$child"} > 120 or not $self->ignore_seen
$self->seen_files->{"$child"} == 0 or $self->seen_files->{"$child"} > 120
MC/DC0%0/3
$self->seen_files->{"$child"} == 0 or $self->seen_files->{"$child"} > 120 or not $self->ignore_seen
$self->seen_files->{"$child"} == 0
$self->seen_files->{"$child"} > 120
not $self->ignore_seen
Truth table0%0/4
A or B or not(C)
A= $self->seen_files->{"$child"} == 0B= $self->seen_files->{"$child"} > 120C= not $self->ignore_seen
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | $self->seen_files->{"$child"}++ unless ($self->seen_files->{"$child"}*$self->interval) > 120 and $self->seen_files->{"$child"} = -1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->seen_files->{"$child"} * $self->interval > 120 and $self->seen_files->{"$child"} = -1
MC/DC0%0/1
$self->seen_files->{"$child"} * $self->interval > 120 and $self->seen_files->{"$child"} = -1
$self->seen_files->{"$child"} * $self->interval > 120
Truth table0%0/2
A
A= $self->seen_files->{"$child"} * $self->interval > 120
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | $self->seen_files->{"$child"} = 1 if $self->ignore_seen and not $self->ensure_seen; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->ignore_seen and not $self->ensure_seen
MC/DC0%0/2
$self->ignore_seen and not $self->ensure_seen
$self->ignore_seen
not $self->ensure_seen
Truth table0%0/3
A and not(B)
A= $self->ignore_seenB= not $self->ensure_seen
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | next if ref $filter && !$filter->($self->alias, $child); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $filter and not &$filter($self->alias, $child)
MC/DC0%0/2
ref $filter and not &$filter($self->alias, $child)
ref $filter
not &$filter($self->alias, $child)
Truth table0%0/3
A and not(B)
A= ref $filterB= not &$filter($self->alias, $child)
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | $kernel->yield(file_callback => $child); | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $self->next_poll( $kernel->delay_set(poll => $self->interval) ); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | override '_file_callback' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my ($self, $kernel, $file) = @_[OBJECT, KERNEL, ARG0]; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $self->file_callback->($self->alias, $file); | |||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | override '_dir_callback' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my ($self, $kernel, $dir) = @_[OBJECT, KERNEL, ARG0]; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $self->dir_callback->($self->alias, $dir); | |||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 72 | __END__ | ||||||||||||||||||||||||||||||||||||||||||