File Coverage

lib/Path/IsDev/NegativeHeuristic/HomeDir.pm
Criterion Covered Total %
statement 28 29 96.5
branch 3 6 50.0
condition n/a
subroutine 8 8 100.0
pod 2 2 100.0
total 41 45 91.1


line stmt bran cond sub pod time code
1 12     12   221707 use 5.008; # utf8
  12         51  
  12         541  
2 12     12   129 use strict;
  12         22  
  12         400  
3 12     12   64 use warnings;
  12         23  
  12         449  
4 12     12   2219 use utf8;
  12         44  
  12         87  
5              
6             package Path::IsDev::NegativeHeuristic::HomeDir;
7              
8             our $VERSION = '1.001002';
9              
10             # ABSTRACT: User home directories are not development roots
11              
12             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
13              
14             ## no critic (RequireArgUnpacking, ProhibitSubroutinePrototypes)
15             sub _uniq (@) {
16 16     16   55 my %seen = ();
17 16         42 return grep { not $seen{$_}++ } @_;
  112         560  
18             }
19              
20              
21              
22              
23              
24              
25              
26              
27              
28              
29              
30              
31              
32              
33              
34              
35 12     12   3144 use Role::Tiny::With qw( with );
  12         8271  
  12         3678  
36             with 'Path::IsDev::Role::NegativeHeuristic', 'Path::IsDev::Role::Matcher::FullPath::Is::Any';
37              
38              
39              
40              
41              
42              
43              
44              
45              
46              
47              
48              
49              
50              
51              
52              
53             sub paths {
54 16     16 1 32 my @sources;
55 16         11382 require File::HomeDir;
56 16         88960 push @sources, File::HomeDir->my_home;
57 16         728 for my $method (qw( my_home my_desktop my_music my_pictures my_videos my_data )) {
58 96 50       3048 if ( $File::HomeDir::IMPLEMENTED_BY->can($method) ) {
59 96         638 push @sources, File::HomeDir->$method();
60             }
61             }
62 16 50       520 return _uniq grep { defined and length } @sources;
  112         526  
63             }
64              
65              
66              
67              
68              
69              
70              
71             sub excludes {
72 16     16 1 46 my ( $self, $result_object ) = @_;
73 16 50       68 return unless $self->fullpath_is_any( $result_object, $self->paths );
74 0           return 1;
75             }
76             1;
77              
78             __END__
79              
80             =pod
81              
82             =encoding UTF-8
83              
84             =head1 NAME
85              
86             Path::IsDev::NegativeHeuristic::HomeDir - User home directories are not development roots
87              
88             =head1 VERSION
89              
90             version 1.001002
91              
92             =head1 METHODS
93              
94             =head2 C<paths>
95              
96             Excludes any values returned by L<< C<File::HomeDir>|File::HomeDir >>
97              
98             uniq grep { defined and length }
99             File::HomeDir->my_home,
100             File::HomeDir->my_desktop,
101             File::HomeDir->my_music,
102             File::HomeDir->my_pictures,
103             File::HomeDir->my_videos,
104             File::HomeDir->my_data;
105              
106             =head2 C<excludes>
107              
108             Excludes any path that matches a C<realpath> of a L<< C<File::HomeDir> path|File::HomeDir >>
109              
110             =begin MetaPOD::JSON v1.1.0
111              
112             {
113             "namespace":"Path::IsDev::NegativeHeuristic::HomeDir",
114             "interface":"single_class",
115             "does": [
116             "Path::IsDev::Role::NegativeHeuristic",
117             "Path::IsDev::Role::Matcher::FullPath::Is::Any"
118             ]
119             }
120              
121              
122             =end MetaPOD::JSON
123              
124             =head1 AUTHOR
125              
126             Kent Fredric <kentfredric@gmail.com>
127              
128             =head1 COPYRIGHT AND LICENSE
129              
130             This software is copyright (c) 2014 by Kent Fredric <kentfredric@gmail.com>.
131              
132             This is free software; you can redistribute it and/or modify it under
133             the same terms as the Perl 5 programming language system itself.
134              
135             =cut