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   2727 use strict;
  2         4  
  2         48  
3 2     2   8 use warnings;
  2         4  
  2         37  
4 2     2   9 use utf8;
  2         3  
  2         13  
5              
6 2     2   34 use Path::Tiny ();
  2         4  
  2         485  
7              
8             sub new {
9 1     1 0 41 my ($class, %args) = @_;
10 1         3 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         15 my $save_path = $self->{path}->child($save_key);
19 4         160 $save_path->parent->mkpath();
20 4         863 $from_path->copy($save_path);
21             }
22              
23             sub exists :method {
24 3     3 0 6 my ($self, $save_key) = @_;
25 3         9 my $save_path = $self->{path}->child($save_key);
26 3         96 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__