| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 4 | ▶ | die $e | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$e and not $e =~ /Can\'t locate|did not return a true value/
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/
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||