1use 5.008;    # utf8
2use strict;
3use warnings;
4use utf8;
5
6package Path::IsDev::Role::Heuristic;
7
8our $VERSION = '1.001002';
9
10# ABSTRACT: Base role for Heuristic things.
11
12our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
13
14sub _blessed { require Scalar::Util; goto &Scalar::Util::blessed }
15
16use Role::Tiny qw( requires );
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41sub name {
42  my $name = shift;
43  $name = _blessed($name) if _blessed($name);
44  $name =~ s/\APath::IsDev::Heuristic:/+ :/msx;
45  return $name;
46}
47
48
49
50
51
52
53
54
55
56sub heuristic_type {
57  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
81requires 'matches';
82
831;
84
85__END__
86
87=pod
88
89=encoding UTF-8
90
91=head1 NAME
92
93Path::IsDev::Role::Heuristic - Base role for Heuristic things.
94
95=head1 VERSION
96
97version 1.001002
98
99=head1 ROLE REQUIRES
100
101=head2 C<matches>
102
103Implementing 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
113Additionally, consuming classes B<should> set C<< $result_object->result( 1 ) >> prior to returning true.
114
115Composing roles B<should> also invoke C<< $result_object->add_reason( $self, $result_value, $descriptive_reason_for_result, \%contextinfo ) >>.
116
117See L<< C<Path::IsDev::Result> for details|Path::IsDev::Result >>
118
119=head1 METHODS
120
121=head2 C<name>
122
123Returns the name to use in debugging.
124
125By default, this is derived from the classes name
126with the C<PIDH> prefix removed:
127
128    Path::IsDev::Heuristic::Tool::Dzil->name()
129    → "+ ::Tool::Dzil"
130
131=head2 C<heuristic_type>
132
133Returns 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
149Kent Fredric <kentfredric@gmail.com>
150
151=head1 COPYRIGHT AND LICENSE
152
153This software is copyright (c) 2014 by Kent Fredric <kentfredric@gmail.com>.
154
155This is free software; you can redistribute it and/or modify it under
156the same terms as the Perl 5 programming language system itself.
157
158=cut
159