File Coverage

lib/Path/IsDev/NegativeHeuristic/PerlINC.pm
Criterion Covered Total %
statement 27 28 96.4
branch 2 4 50.0
condition n/a
subroutine 9 9 100.0
pod 2 2 100.0
total 40 43 93.0


line stmt bran cond sub pod time code
1 12     12   11106 use 5.008; # utf8
  12         46  
  12         613  
2 12     12   71 use strict;
  12         22  
  12         393  
3 12     12   72 use warnings;
  12         20  
  12         388  
4 12     12   1190 use utf8;
  12         152  
  12         97  
5              
6             package Path::IsDev::NegativeHeuristic::PerlINC;
7              
8             our $VERSION = '1.001002';
9              
10             # ABSTRACT: White-list paths in Config.pm as being non-development roots.
11              
12             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
13              
14             ## no critic (RequireArgUnpacking, ProhibitSubroutinePrototypes)
15             sub _uniq (@) {
16 16     16   39 my %seen = ();
17 16         36 return grep { not $seen{$_}++ } @_;
  48         254  
18             }
19              
20              
21              
22              
23              
24              
25              
26              
27              
28              
29              
30              
31              
32              
33              
34              
35 12     12   3045 use Role::Tiny::With qw( with );
  12         5659  
  12         747  
36 12     12   112 use Config;
  12         22  
  12         2534  
37              
38             with 'Path::IsDev::Role::NegativeHeuristic', 'Path::IsDev::Role::Matcher::FullPath::Is::Any';
39              
40              
41              
42              
43              
44              
45              
46              
47              
48             sub paths {
49 16     16 1 29 my @sources;
50 16         471 push @sources, $Config{archlibexp}, $Config{privlibexp}, $Config{sitelibexp}, $Config{vendorlibexp};
51 16 50       819 return _uniq grep { defined and length } @sources;
  64         319  
52             }
53              
54              
55              
56              
57              
58              
59              
60             sub excludes {
61 16     16 1 49 my ( $self, $result_object ) = @_;
62              
63 16 50       65 return unless $self->fullpath_is_any( $result_object, $self->paths );
64 0           return 1;
65             }
66              
67             1;
68              
69             __END__
70              
71             =pod
72              
73             =encoding UTF-8
74              
75             =head1 NAME
76              
77             Path::IsDev::NegativeHeuristic::PerlINC - White-list paths in Config.pm as being non-development roots.
78              
79             =head1 VERSION
80              
81             version 1.001002
82              
83             =head1 METHODS
84              
85             =head2 C<paths>
86              
87             Returns a unique list comprised of all the C<*exp> library paths from L<< C<Config.pm>|Config >>
88              
89             uniq grep { defined and length } $Config{archlibexp}, $Config{privlibexp}, $Config{sitelibexp}, $Config{vendorlibexp};
90              
91             =head2 C<excludes>
92              
93             Excludes a path if its full path is any of C<paths>
94              
95             =begin MetaPOD::JSON v1.1.0
96              
97             {
98             "namespace":"Path::IsDev::NegativeHeuristic::PerlINC",
99             "interface":"single_class",
100             "does": [
101             "Path::IsDev::Role::NegativeHeuristic",
102             "Path::IsDev::Role::Matcher::FullPath::Is::Any"
103             ]
104             }
105              
106              
107             =end MetaPOD::JSON
108              
109             =head1 AUTHOR
110              
111             Kent Fredric <kentfredric@gmail.com>
112              
113             =head1 COPYRIGHT AND LICENSE
114              
115             This software is copyright (c) 2014 by Kent Fredric <kentfredric@gmail.com>.
116              
117             This is free software; you can redistribute it and/or modify it under
118             the same terms as the Perl 5 programming language system itself.
119              
120             =cut