Storage/S3.pm

filter: Statementstmt 81.8% 9 / 11 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 86.6% 13 / 15 CC 1 SCAR 0.7
CC
1
Cov
82%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Storage/S3/Adapter/NetAmazonS3.pm ↑ Summary
1 package CPAN::MirrorMerger::Storage::S3;
2 1 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 our $VERSION = "0.04";
7  
8 0 ▶use Class::Accessor::Lite ro => [qw/retry_policy adapter/];
Subroutine BEGIN: called CC=1 SCAR=2.6
9  
10 use Carp qw/croak/;
11 use Path::Tiny ();
12  
13 use CPAN::MirrorMerger ();
14  
15 sub new {
16 my ($class, %args) = @_;
17 croak 'adapter required' unless defined $args{adapter};
18 $args{retry_policy} ||= $CPAN::MirrorMerger::DEFAULT_RETRY_POLICY;
19 bless \%args, $class;
20 }
21  
22 sub copy {
23 my ($self, $from_path, $save_key) = @_;
24 $self->retry_policy->apply_and_doit(sub {
25 $self->adapter->upload($from_path, $save_key);
26 });
27 }
28  
29 sub exists :method {
30 my ($self, $save_key) = @_;
31 return $self->retry_policy->apply_and_doit(sub {
32 return $self->adapter->exists($save_key);
33 });
34 }
35  
36 sub fetch {
37 my ($self, $save_key) = @_;
38 return $self->retry_policy->apply_and_doit(sub {
39 my $tempfile = Path::Tiny->tempfile(UNLINK => 1);
40  
41 my $downloaded = $self->adapter->download($save_key, $tempfile->cached_temp);
42 return unless $downloaded;
43  
44 return $tempfile;
45 });
46 }
47  
48 1;
49 __END__
« Storage/S3/Adapter/NetAmazonS3.pm ↑ Summary