File Coverage

lib/Path/IsDev/Heuristic/Changelog.pm
Criterion Covered Total %
statement 21 21 100.0
branch 2 2 100.0
condition n/a
subroutine 7 7 100.0
pod 2 2 100.0
total 32 32 100.0


line stmt bran cond sub pod time code
1 8     8   6940 use 5.008; # utf8
  8         31  
  8         436  
2 8     8   45 use strict;
  8         16  
  8         258  
3 8     8   41 use warnings;
  8         29  
  8         210  
4 8     8   1178 use utf8;
  8         24  
  8         43  
5              
6             package Path::IsDev::Heuristic::Changelog;
7              
8             our $VERSION = '1.001002';
9              
10             # ABSTRACT: Determine if a path contains a Changelog (or similar)
11              
12             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
13              
14              
15              
16              
17              
18              
19              
20              
21              
22              
23              
24              
25              
26 8     8   1612 use Role::Tiny::With qw( with );
  8         7451  
  8         2196  
27             with 'Path::IsDev::Role::Heuristic', 'Path::IsDev::Role::Matcher::Child::BaseName::MatchRegexp::File';
28              
29              
30              
31              
32              
33              
34              
35              
36              
37              
38              
39              
40             sub basename_regexp {
41             ## no critic (RegularExpressions::RequireLineBoundaryMatching)
42 9     9 1 87 return qr/\AChange(s|log)(|[.][^.\s]+)\z/isx;
43             }
44              
45              
46              
47              
48              
49              
50              
51             sub matches {
52 9     9 1 25 my ( $self, $result_object ) = @_;
53 9 100       40 if ( $self->child_basename_matchregexp_file( $result_object, $self->basename_regexp ) ) {
54 3         69 $result_object->result(1);
55 3         26 return 1;
56             }
57 6         40 return;
58             }
59              
60             1;
61              
62             __END__
63              
64             =pod
65              
66             =encoding UTF-8
67              
68             =head1 NAME
69              
70             Path::IsDev::Heuristic::Changelog - Determine if a path contains a Changelog (or similar)
71              
72             =head1 VERSION
73              
74             version 1.001002
75              
76             =head1 DESCRIPTION
77              
78             This heuristic matches any case variation of C<Changes> or C<Changelog>,
79             including any files of that name with a suffix.
80              
81             e.g.:
82              
83             Changes
84             CHANGES
85             Changes.mkdn
86              
87             etc.
88              
89             =head1 METHODS
90              
91             =head2 C<basename_regexp>
92              
93             Indicators for this heuristic is the existence of a file such as:
94              
95             Changes (i)
96             Changes.anyext (i)
97             Changelog (i)
98             Changelog.anyext (i)
99              
100             =head2 C<matches>
101              
102             Returns a match if any child of C<path> exists matching the regexp C<basename_regexp>
103              
104             =begin MetaPOD::JSON v1.1.0
105              
106             {
107             "namespace":"Path::IsDev::Heuristic::Changelog",
108             "interface":"single_class",
109             "does":[ "Path::IsDev::Role::Heuristic", "Path::IsDev::Role::Matcher::Child::BaseName::MatchRegexp::File" ]
110             }
111              
112              
113             =end MetaPOD::JSON
114              
115             =head1 AUTHOR
116              
117             Kent Fredric <kentfredric@gmail.com>
118              
119             =head1 COPYRIGHT AND LICENSE
120              
121             This software is copyright (c) 2014 by Kent Fredric <kentfredric@gmail.com>.
122              
123             This is free software; you can redistribute it and/or modify it under
124             the same terms as the Perl 5 programming language system itself.
125              
126             =cut