File Coverage

lib/Path/IsDev/Heuristic/DevDirMarker.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 6     6   245555 use 5.008; # utf8
  6         24  
  6         272  
2 6     6   36 use strict;
  6         13  
  6         221  
3 6     6   32 use warnings;
  6         14  
  6         172  
4 6     6   1485 use utf8;
  6         27  
  6         55  
5              
6             package Path::IsDev::Heuristic::DevDirMarker;
7              
8             our $VERSION = '1.001002';
9              
10             # ABSTRACT: Determine if a path contains a .devdir file
11              
12             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
13              
14              
15              
16              
17              
18              
19              
20              
21              
22              
23              
24              
25              
26              
27              
28              
29 6     6   12465 use Role::Tiny::With qw( with );
  6         9532  
  6         1755  
30             with 'Path::IsDev::Role::Heuristic', 'Path::IsDev::Role::Matcher::Child::Exists::Any::File';
31              
32              
33              
34              
35              
36              
37              
38              
39              
40             sub files {
41 5     5 1 32 return qw( .devdir );
42             }
43              
44              
45              
46              
47              
48              
49              
50             sub matches {
51 5     5 1 14 my ( $self, $result_object ) = @_;
52 5 100       19 if ( $self->child_exists_any_file( $result_object, $self->files ) ) {
53 1         28 $result_object->result(1);
54 1         11 return 1;
55             }
56 4         23 return;
57             }
58              
59             1;
60              
61             __END__
62              
63             =pod
64              
65             =encoding UTF-8
66              
67             =head1 NAME
68              
69             Path::IsDev::Heuristic::DevDirMarker - Determine if a path contains a .devdir file
70              
71             =head1 VERSION
72              
73             version 1.001002
74              
75             =head1 DESCRIPTION
76              
77             This Heuristic is a workaround that is likely viable in the event none of the other Heuristics work.
78              
79             All this heuristic checks for is the presence of a special file called C<.devdir>, which is intended as an explicit notation that
80             "This directory is a project root".
81              
82             An example case where you might need such a Heuristic, is the scenario where you're not working with a Perl C<CPAN> dist, but are
83             instead working on a project in a different language, where Perl is simply there for build/test purposes.
84              
85             =head1 METHODS
86              
87             =head2 C<files>
88              
89             Matches files named:
90              
91             .devdir
92              
93             =head2 C<matches>
94              
95             Matches if any of the files in C<files> exist as children of the C<path>
96              
97             =begin MetaPOD::JSON v1.1.0
98              
99             {
100             "namespace":"Path::IsDev::Heuristic::DevDirMarker",
101             "interface":"single_class",
102             "does":[
103             "Path::IsDev::Role::Heuristic",
104             "Path::IsDev::Role::Matcher::Child::Exists::Any::File"
105             ]
106             }
107              
108              
109             =end MetaPOD::JSON
110              
111             =head1 AUTHOR
112              
113             Kent Fredric <kentfredric@gmail.com>
114              
115             =head1 COPYRIGHT AND LICENSE
116              
117             This software is copyright (c) 2014 by Kent Fredric <kentfredric@gmail.com>.
118              
119             This is free software; you can redistribute it and/or modify it under
120             the same terms as the Perl 5 programming language system itself.
121              
122             =cut