File Coverage

blib/lib/Alien/Base/ModuleBuild/Repository/Local.pm
Criterion Covered Total %
statement 40 40 100.0
branch 1 2 50.0
condition 1 3 33.3
subroutine 10 10 100.0
pod 0 3 0.0
total 52 58 89.6


line stmt bran cond sub pod time code
1             package Alien::Base::ModuleBuild::Repository::Local;
2              
3 2     2   232080 use strict;
  2         10  
  2         65  
4 2     2   10 use warnings;
  2         6  
  2         48  
5 2     2   10 use Carp;
  2         5  
  2         107  
6 2     2   517 use File::chdir;
  2         3221  
  2         262  
7 2     2   523 use File::Copy qw/copy/;
  2         2376  
  2         111  
8 2     2   858 use Path::Tiny qw( path );
  2         11319  
  2         116  
9 2     2   591 use parent 'Alien::Base::ModuleBuild::Repository';
  2         307  
  2         25  
10              
11             # ABSTRACT: Local file repository handler
12             our $VERSION = '1.15'; # VERSION
13              
14             sub new {
15 4     4 0 355 my $class = shift;
16              
17 4         106 my $self = $class->SUPER::new(@_);
18              
19             # make location absolute
20 4         62 local $CWD = $self->location;
21 4         340 $self->location("$CWD");
22              
23 4         18 return $self;
24             }
25              
26             sub list_files {
27 4     4 0 41 my $self = shift;
28              
29 4         29 local $CWD = $self->location;
30              
31 4         227 opendir( my $dh, $CWD);
32             my @files =
33 4         421 grep { ! /^\./ }
  21         158  
34             readdir $dh;
35              
36 4         94 return @files;
37             }
38              
39             sub get_file {
40 4     4 0 7439 my $self = shift;
41 4   33     42 my $file = shift || croak "Must specify file to copy";
42              
43 4         10 my $full_file = do {
44 4         22 local $CWD = $self->location;
45 4 50       279 croak "Cannot find file: $file" unless -e $file;
46 4         70 path($file)->absolute->stringify;
47             };
48              
49 4         1261 copy $full_file, $CWD;
50              
51 4         2594 return $file;
52             }
53              
54             1;
55              
56             __END__