ChangeNotify.pm

filter: Statementstmt 100% 46 / 46 Branchbran 62.5% 5 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 11 / 11 Podpod 100% 2 / 2 totaltotal 90.2% 65 / 72 CC 6 SCAR 7.4
CC
6
Cov
91%
_try_load
4.4
instantiate_watcher
2.0
usable_classes
2.0
CRAP 2.1
« ChangeNotify/Watcher/Default.pm ↑ Summary ChangeNotify/Watcher/Inotify.pm »
1 package File::ChangeNotify;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $VERSION = '0.31';
8  
9 2 ▶use Carp qw( confess );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # We load this up front to make sure that the prereq modules are installed.
12 2 ▶use File::ChangeNotify::Watcher::Default;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Module::Pluggable::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Module::Runtime qw( use_module );
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 # First version to support coerce => 1
17 2 ▶use Moo 1.006 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 3 ▶sub instantiate_watcher {
Subroutine instantiate_watcher: called CC=2 SCAR=7.0
Pod documented
20 3 my $class = shift;
21  
22 3 my @usable = $class->usable_classes;
23 3 ▶ return $usable[0]->new(@_) if @usable;
Branch: 1 branch
BranchTrueFalseTotal
if @usable 0 3 3
24  
25 3 return File::ChangeNotify::Watcher::Default->new(@_);
26 }
27  
28 {
29 2 my $finder = Module::Pluggable::Object->new(
30 search_path => 'File::ChangeNotify::Watcher' );
31 2 my $loaded;
32 2 my @usable_classes;
33  
34 4 ▶ sub usable_classes {
Subroutine usable_classes: called CC=2 SCAR=6.9
Pod documented
35 4 ▶ return @usable_classes if $loaded;
Branch: 1 branch
BranchTrueFalseTotal
if $loaded 2 2 4
36 4 @usable_classes = grep { _try_load($_) }
37 2 sort grep { $_ ne 'File::ChangeNotify::Watcher::Default' }
38 $finder->plugins;
39 2 $loaded = 1;
40  
41 2 return @usable_classes;
42 }
43 }
44  
45 2 ▶sub _try_load {
Subroutine _try_load: called CC=4 SCAR=14.8
46 4 my $module = shift;
47  
48 4 my $ok = eval { use_module($module) };
49 4 my $e = $@;
50 4 ▶ return $module if $ok;
Branch: 1 branch
BranchTrueFalseTotal
if $ok 0 4 4
51  
52 4 ▶ die $e
Branch: 1 branch
BranchTrueFalseTotal
if $e and not $e =~ /Can\'t locate|did not return a true value/ 0 4 4
Condition33%1/3
$e and not $e =~ /Can\'t locate|did not return a true value/
!ll&&!rl&&r
040
MC/DC0%0/2
$e and not $e =~ /Can\'t locate|did not return a true value/
$e not $e =~ /Can\'t locate|did not return a true value/
Truth table33%1/3
A and not(B)
A= $eB= not $e =~ /Can\'t locate|did not return a true value/
ABresult
0X0
100
111
53 if $e
54 && $e !~ /Can\'t locate|did not return a true value/;
55 }
56  
57 2 1;
58  
59 # ABSTRACT: Watch for changes to files, cross-platform style
60  
61 __END__
« ChangeNotify/Watcher/Default.pm ↑ Summary ChangeNotify/Watcher/Inotify.pm »