File Coverage

blib/lib/Path/IsDev/Role/HeuristicSet.pm
Criterion Covered Total %
statement 37 39 94.8
branch 5 6 83.3
condition n/a
subroutine 12 12 100.0
pod 1 1 100.0
total 55 58 94.8


line stmt bran cond sub pod time code
1 14     14   5142 use 5.008; # utf8;
  14         33  
2 14     14   62 use strict;
  14         30  
  14         245  
3 14     14   43 use warnings;
  14         38  
  14         297  
4 14     14   481 use utf8;
  14         24  
  14         51  
5              
6             package Path::IsDev::Role::HeuristicSet;
7              
8             our $VERSION = '1.001003';
9              
10             # ABSTRACT: Role for sets of Heuristics.
11              
12             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
13              
14              
15              
16              
17              
18              
19              
20              
21              
22              
23              
24              
25 127     127   365 sub _use_module { require Module::Runtime; goto &Module::Runtime::use_module }
  127         308  
26 208     208   460 sub _com_mn { require Module::Runtime; goto &Module::Runtime::compose_module_name; }
  208         348  
27             ## no critic (Subroutines::ProhibitCallsToUnexportedSubs)
28 13     13   116 sub _debug { require Path::IsDev; goto &Path::IsDev::debug }
  13         37  
29              
30 14     14   2098 use Role::Tiny qw( requires );
  14         3061  
  14         65  
31              
32              
33              
34              
35              
36              
37              
38             requires 'modules';
39              
40             sub _expand_heuristic {
41 160     160   157 my ( undef, $hn ) = @_;
42 160         157 return _com_mn( 'Path::IsDev::Heuristic', $hn );
43             }
44              
45             sub _expand_negative_heuristic {
46 48     48   57 my ( undef, $hn ) = @_;
47 48         102 return _com_mn( 'Path::IsDev::NegativeHeuristic', $hn );
48             }
49              
50             sub _load_module {
51 127     127   182 my ( undef, $module ) = @_;
52 127         185 return _use_module($module);
53             }
54              
55              
56              
57              
58              
59              
60              
61              
62              
63              
64              
65             sub matches {
66 16     16 1 151 my ( $self, $result_object ) = @_;
67 16         51 TESTS: for my $module ( $self->modules ) {
68 127         458 $self->_load_module($module);
69 127 100       1620 if ( $module->can('excludes') ) {
70 48 50       133 if ( $module->excludes($result_object) ) {
71 0         0 _debug( $module->name . q[ excludes path ] . $result_object->path );
72 0         0 return;
73             }
74 48         101 next TESTS;
75             }
76 79 100       194 next unless $module->matches($result_object);
77 13         40 my $name = $module->name;
78 13         200 _debug( $name . q[ matched path ] . $result_object->path );
79 13         106 return 1;
80             }
81 3         23 return;
82             }
83              
84             1;
85              
86             __END__