File Coverage

blib/lib/App/FileSummoner/SkeletonDirsFinder.pm
Criterion Covered Total %
statement 17 19 89.4
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 24 26 92.3


line stmt bran cond sub pod time code
1             package App::FileSummoner::SkeletonDirsFinder;
2             BEGIN {
3 1     1   1028 $App::FileSummoner::SkeletonDirsFinder::VERSION = '0.005';
4             }
5              
6 1     1   16 use 5.006;
  1         4  
  1         36  
7 1     1   4 use strict;
  1         2  
  1         31  
8 1     1   4 use warnings;
  1         2  
  1         31  
9              
10 1     1   6 use File::Basename 'dirname';
  1         2  
  1         80  
11 1     1   5 use File::Spec;
  1         2  
  1         37  
12              
13 1     1   440 use Moose;
  0            
  0            
14              
15             has 'skeletonsDir' => ( is => 'rw', default => '.skeletons' );
16              
17             =head1 NAME
18              
19             App::FileSummoner::SkeletonDirsFinder - The great new App::FileSummoner::SkeletonDirsFinder!
20              
21             =head1 METHODS
22              
23             =head2 findForFile
24              
25             Find skeleton directories for a given file.
26              
27             =cut
28              
29             sub findForFile {
30             my ($self, $path) = @_;
31              
32             return map {
33             File::Spec->join($_, $self->skeletonsDir)
34             } $self->skeletonsParentDirs(dirname($path));
35             }
36              
37             =head2 skeletonsParentDirs
38              
39             TODO
40              
41             =cut
42              
43             sub skeletonsParentDirs {
44             my ($self, $path) = @_;
45              
46             return $self->findSkeletonsParentDirs(File::Spec->rel2abs($path));
47             }
48              
49             =head2 findSkeletonsParentDirs
50              
51             TODO
52              
53             =cut
54              
55             sub findSkeletonsParentDirs {
56             my ($self, $path, @paths) = @_;
57              
58             return (@paths, $path) if $path eq '/';
59             return $self->findSkeletonsParentDirs(dirname($path), (@paths, $path));
60             }
61              
62             =head1 AUTHOR
63              
64             Marian Schubert, C<< <marian.schubert at gmail.com> >>
65              
66             =cut
67              
68             1; # End of App::FileSummoner::SkeletonDirsFinder