File Coverage

blib/lib/CPAN/MirrorMerger/Storage/Directory.pm
Criterion Covered Total %
statement 22 26 84.6
branch 0 2 0.0
condition n/a
subroutine 7 8 87.5
pod 0 4 0.0
total 29 40 72.5


line stmt bran cond sub pod time code
1             package CPAN::MirrorMerger::Storage::Directory;
2 2     2   2704 use strict;
  2         4  
  2         49  
3 2     2   8 use warnings;
  2         3  
  2         39  
4 2     2   8 use utf8;
  2         3  
  2         11  
5              
6 2     2   34 use Path::Tiny ();
  2         3  
  2         418  
7              
8             sub new {
9 1     1 0 45 my ($class, %args) = @_;
10 1         4 my $path = delete $args{path};
11 1         5 bless {
12             path => Path::Tiny->new($path),
13             } => $class;
14             }
15              
16             sub copy {
17 4     4 0 10 my ($self, $from_path, $save_key) = @_;
18 4         13 my $save_path = $self->{path}->child($save_key);
19 4         143 $save_path->parent->mkpath();
20 4         773 $from_path->copy($save_path);
21             }
22              
23             sub exists :method {
24 3     3 0 7 my ($self, $save_key) = @_;
25 3         9 my $save_path = $self->{path}->child($save_key);
26 3         98 return $save_path->exists;
27             }
28              
29             sub fetch {
30 0     0 0   my ($self, $save_key) = @_;
31 0           my $save_path = $self->{path}->child($save_key);
32 0 0         return unless $save_path->exists;
33 0           return $save_path;
34             }
35              
36             1;
37             __END__