File Coverage

blib/lib/Alien/Base/ModuleBuild/Repository/Local.pm
Criterion Covered Total %
statement 42 42 100.0
branch 1 2 50.0
condition 1 3 33.3
subroutine 12 12 100.0
pod 0 5 0.0
total 56 64 87.5


line stmt bran cond sub pod time code
1             package Alien::Base::ModuleBuild::Repository::Local;
2              
3 4     4   197801 use strict;
  4         13  
  4         174  
4 4     4   22 use warnings;
  4         8  
  4         95  
5 4     4   18 use Carp;
  4         8  
  4         182  
6 4     4   433 use File::chdir;
  4         2877  
  4         410  
7 4     4   448 use File::Copy qw/copy/;
  4         2129  
  4         173  
8 4     4   752 use Path::Tiny qw( path );
  4         10679  
  4         188  
9 4     4   452 use parent 'Alien::Base::ModuleBuild::Repository';
  4         248  
  4         27  
10              
11             # ABSTRACT: Local file repository handler
12             our $VERSION = '1.16_01'; # TRIAL VERSION
13             $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
14              
15 1     1 0 82 sub is_network_fetch { 0 }
16 4     4 0 16 sub is_secure_fetch { 1 }
17              
18             sub new {
19 4     4 0 161 my $class = shift;
20              
21 4         87 my $self = $class->SUPER::new(@_);
22              
23             # make location absolute
24 4         80 local $CWD = $self->location;
25 4         263 $self->location("$CWD");
26              
27 4         14 return $self;
28             }
29              
30             sub list_files {
31 4     4 0 33 my $self = shift;
32              
33 4         12 local $CWD = $self->location;
34              
35 4         195 opendir( my $dh, $CWD);
36             my @files =
37 4         370 grep { ! /^\./ }
  21         100  
38             readdir $dh;
39              
40 4         69 return @files;
41             }
42              
43             sub get_file {
44 4     4 0 1134 my $self = shift;
45 4   33     18 my $file = shift || croak "Must specify file to copy";
46              
47 4         9 my $full_file = do {
48 4         16 local $CWD = $self->location;
49 4 50       221 croak "Cannot find file: $file" unless -e $file;
50 4         60 path($file)->absolute->stringify;
51             };
52              
53 4         982 copy $full_file, $CWD;
54              
55 4         2291 return $file;
56             }
57              
58             1;
59              
60             __END__