File Coverage

blib/lib/Path/IsDev/Role/Heuristic.pm
Criterion Covered Total %
statement 22 22 100.0
branch 1 2 50.0
condition n/a
subroutine 8 8 100.0
pod 2 2 100.0
total 33 34 97.0


line stmt bran cond sub pod time code
1 22     22   23850 use 5.008; # utf8
  22         155  
  22         1082  
2 22     22   134 use strict;
  22         48  
  22         811  
3 22     22   174 use warnings;
  22         40  
  22         879  
4 22     22   15572 use utf8;
  22         58  
  22         149  
5              
6             package Path::IsDev::Role::Heuristic;
7              
8             our $VERSION = '1.001002';
9              
10             # ABSTRACT: Base role for Heuristic things.
11              
12             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
13              
14 149     149   778 sub _blessed { require Scalar::Util; goto &Scalar::Util::blessed }
  149         757  
15              
16 22     22   4000 use Role::Tiny qw( requires );
  22         9454  
  22         284  
17              
18              
19              
20              
21              
22              
23              
24              
25              
26              
27              
28              
29              
30              
31              
32              
33              
34              
35              
36              
37              
38              
39              
40              
41             sub name {
42 149     149 1 245 my $name = shift;
43 149 50       660 $name = _blessed($name) if _blessed($name);
44 149         592 $name =~ s/\APath::IsDev::Heuristic:/+ :/msx;
45 149         453 return $name;
46             }
47              
48              
49              
50              
51              
52              
53              
54              
55              
56             sub heuristic_type {
57 136     136 1 350 return 'positive heuristic';
58             }
59              
60              
61              
62              
63              
64              
65              
66              
67              
68              
69              
70              
71              
72              
73              
74              
75              
76              
77              
78              
79              
80              
81             requires 'matches';
82              
83             1;
84              
85             __END__
86              
87             =pod
88              
89             =encoding UTF-8
90              
91             =head1 NAME
92              
93             Path::IsDev::Role::Heuristic - Base role for Heuristic things.
94              
95             =head1 VERSION
96              
97             version 1.001002
98              
99             =head1 ROLE REQUIRES
100              
101             =head2 C<matches>
102              
103             Implementing classes must provide this method.
104              
105             return : 1 / undef
106             1 -> this path is a development directory as far as this heuristic is concerned
107             undef -> this path is not a development directory as far as this heuristic is concerned
108              
109             args : ( $class , $result_object )
110             $class -> method will be invoked on packages, not objects
111             $result_object -> will be a Path::IsDev::Result
112              
113             Additionally, consuming classes B<should> set C<< $result_object->result( 1 ) >> prior to returning true.
114              
115             Composing roles B<should> also invoke C<< $result_object->add_reason( $self, $result_value, $descriptive_reason_for_result, \%contextinfo ) >>.
116              
117             See L<< C<Path::IsDev::Result> for details|Path::IsDev::Result >>
118              
119             =head1 METHODS
120              
121             =head2 C<name>
122              
123             Returns the name to use in debugging.
124              
125             By default, this is derived from the classes name
126             with the C<PIDH> prefix removed:
127              
128             Path::IsDev::Heuristic::Tool::Dzil->name()
129             → "+ ::Tool::Dzil"
130              
131             =head2 C<heuristic_type>
132              
133             Returns a description of the general heuristic type
134              
135             positive heuristic
136              
137             =begin MetaPOD::JSON v1.1.0
138              
139             {
140             "namespace":"Path::IsDev::Role::Heuristic",
141             "interface":"role"
142             }
143              
144              
145             =end MetaPOD::JSON
146              
147             =head1 AUTHOR
148              
149             Kent Fredric <kentfredric@gmail.com>
150              
151             =head1 COPYRIGHT AND LICENSE
152              
153             This software is copyright (c) 2014 by Kent Fredric <kentfredric@gmail.com>.
154              
155             This is free software; you can redistribute it and/or modify it under
156             the same terms as the Perl 5 programming language system itself.
157              
158             =cut