line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::ChangeNotify::Watcher; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
28189
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
97
|
|
4
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
77
|
|
5
|
3
|
|
|
3
|
|
18
|
use namespace::autoclean; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
23
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.29'; |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
1104
|
use File::ChangeNotify::Event; |
|
3
|
|
|
|
|
34
|
|
|
3
|
|
|
|
|
116
|
|
10
|
3
|
|
|
3
|
|
31
|
use Module::Runtime qw( use_module ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
23
|
|
11
|
3
|
|
|
3
|
|
155
|
use Types::Standard qw( ArrayRef Bool ClassName CodeRef Num RegexpRef Str ); |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
21
|
|
12
|
3
|
|
|
3
|
|
4524
|
use Type::Utils -all; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
17
|
|
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
3
|
|
9889
|
use Moo::Role; |
|
3
|
|
|
|
|
30
|
|
|
3
|
|
|
|
|
22
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has filter => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
isa => RegexpRef, |
19
|
|
|
|
|
|
|
default => sub {qr/.*/}, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#<<< |
23
|
|
|
|
|
|
|
my $dir_t = subtype as Str, |
24
|
|
|
|
|
|
|
where { -d $_ }, |
25
|
|
|
|
|
|
|
message { "$_ is not a valid directory" }; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $array_of_dirs_t = subtype as ArrayRef[Str], |
28
|
|
|
|
|
|
|
where { |
29
|
|
|
|
|
|
|
map {-d} @{$_}; |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
message {"@{$_} is not a list of valid directories"}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
coerce $array_of_dirs_t, |
34
|
|
|
|
|
|
|
from $dir_t, |
35
|
|
|
|
|
|
|
via { [$_] }; |
36
|
|
|
|
|
|
|
#>>> |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has directories => ( |
39
|
|
|
|
|
|
|
is => 'ro', |
40
|
|
|
|
|
|
|
writer => '_set_directories', |
41
|
|
|
|
|
|
|
isa => $array_of_dirs_t, |
42
|
|
|
|
|
|
|
required => 1, |
43
|
|
|
|
|
|
|
coerce => 1, |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
has follow_symlinks => ( |
47
|
|
|
|
|
|
|
is => 'ro', |
48
|
|
|
|
|
|
|
isa => Bool, |
49
|
|
|
|
|
|
|
default => 0, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
has event_class => ( |
53
|
|
|
|
|
|
|
is => 'ro', |
54
|
|
|
|
|
|
|
isa => ClassName, |
55
|
|
|
|
|
|
|
default => 'File::ChangeNotify::Event', |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
has sleep_interval => ( |
59
|
|
|
|
|
|
|
is => 'ro', |
60
|
|
|
|
|
|
|
isa => Num, |
61
|
|
|
|
|
|
|
default => 2, |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $files_or_regexps_or_code_t |
65
|
|
|
|
|
|
|
= subtype as ArrayRef [ Str | RegexpRef | CodeRef ]; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
has exclude => ( |
68
|
|
|
|
|
|
|
is => 'ro', |
69
|
|
|
|
|
|
|
isa => $files_or_regexps_or_code_t, |
70
|
|
|
|
|
|
|
default => sub { [] }, |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub BUILD { |
74
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
0
|
use_module( $self->event_class() ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub new_events { |
80
|
13
|
|
|
13
|
1
|
1839
|
my $self = shift; |
81
|
|
|
|
|
|
|
|
82
|
13
|
|
|
|
|
71
|
return $self->_interesting_events(); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
86
|
|
|
|
|
|
|
sub _path_is_excluded { |
87
|
93
|
|
|
93
|
|
209
|
my $self = shift; |
88
|
93
|
|
|
|
|
146
|
my $path = shift; |
89
|
|
|
|
|
|
|
|
90
|
93
|
|
|
|
|
131
|
foreach my $excluded ( @{ $self->exclude } ) { |
|
93
|
|
|
|
|
282
|
|
91
|
51
|
100
|
|
|
|
118
|
if ( my $ref = ref $excluded ) { |
92
|
32
|
100
|
|
|
|
63
|
if ( $ref eq 'Regexp' ) { |
|
|
50
|
|
|
|
|
|
93
|
29
|
100
|
|
|
|
173
|
return 1 if $path =~ /$excluded/; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
elsif ( $ref eq 'CODE' ) { |
96
|
3
|
|
|
|
|
7
|
local $_ = $path; |
97
|
3
|
50
|
|
|
|
8
|
return 1 if $excluded->($path); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
else { |
101
|
19
|
100
|
|
|
|
45
|
return 1 if $path eq $excluded; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
86
|
|
|
|
|
333
|
return; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _remove_directory { |
109
|
2
|
|
|
2
|
|
5
|
my $self = shift; |
110
|
2
|
|
|
|
|
4
|
my $dir = shift; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
$self->_set_directories( |
113
|
2
|
|
|
|
|
4
|
[ grep { $_ ne $dir } @{ $self->directories() } ] ); |
|
2
|
|
|
|
|
57
|
|
|
2
|
|
|
|
|
8
|
|
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
## use critic |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# ABSTRACT: Role consumed by all watchers |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
__END__ |