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   3649 use strict;
  2         5  
  2         63  
3 2     2   11 use warnings;
  2         5  
  2         55  
4 2     2   11 use utf8;
  2         5  
  2         16  
5              
6 2     2   43 use Path::Tiny ();
  2         6  
  2         513  
7              
8             sub new {
9 1     1 0 49 my ($class, %args) = @_;
10 1         4 my $path = delete $args{path};
11 1         7 bless {
12             path => Path::Tiny->new($path),
13             } => $class;
14             }
15              
16             sub copy {
17 4     4 0 11 my ($self, $from_path, $save_key) = @_;
18 4         16 my $save_path = $self->{path}->child($save_key);
19 4         177 $save_path->parent->mkpath();
20 4         978 $from_path->copy($save_path);
21             }
22              
23             sub exists :method {
24 3     3 0 7 my ($self, $save_key) = @_;
25 3         14 my $save_path = $self->{path}->child($save_key);
26 3         120 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__