SimpleBackuper/StorageLocal.pm

filter: Statementstmt 21.8% 7 / 32 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 28.5% 2 / 7 Podpod 0.0% 0 / 5 totaltotal 13.8% 9 / 65 CC 10 SCAR 26.4
CC
10
Cov
14%
listing
30.0
new
12.0
put
6.0
CRAP 14.0
« SimpleBackuper/_print_table.pm ↑ Summary SimpleBackuper/_format.pm »
1 package App::SimpleBackuper::StorageLocal;
2  
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 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
7 0 my($class, $path) = @_;
8
9 0 ▶ die "Storage path '$path' doesn't exists" if ! -e $path;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $path 0 0 0
10 0 ▶ die "Storage path '$path' is not a directory" if ! -d $path;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $path 0 0 0
11
12 0 return bless { path => $path } => $class;
13 }
14  
15 0 ▶sub put {
Subroutine put: not called CC=2 SCAR=17.9
Pod undocumented
16 0 my($self, $name, $content_ref) = @_;
17
18 0 ▶ open(my $fh, ">", "$self->{path}/$name") or die "Can't write to $self->{path}/$name: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", qq[$self->{"path"}/$name] or die qq[Can't write to $self->{"path"}/${name}: $!] 0 0 0
19 0 print $fh $$content_ref;
20 0 close($fh);
21
22 0 return $self;
23 }
24  
25 0 ▶sub get {
Subroutine get: not called CC=2 SCAR=17.9
Pod undocumented
26 0 my($self, $name) = @_;
27
28 0 ▶ open(my $fh, "<", "$self->{path}/$name") or die "Can't read from $self->{path}/$name: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", qq[$self->{"path"}/$name] or die qq[Can't read from $self->{"path"}/${name}: $!] 0 0 0
29 0 my $content = join('', <$fh>);
30 0 close $fh;
31
32 0 return [$content];
33 }
34  
35 0 ▶sub remove {
Subroutine remove: not called CC=2 SCAR=17.9
Pod undocumented
36 0 my($self, $name) = @_;
37
38 0 ▶ unlink("$self->{path}/$name") or die "Can't remove $self->{path}/$name: $!";
Branch: 1 branch
BranchTrueFalseTotal
unlink qq[$self->{"path"}/$name] or die qq[Can't remove $self->{"path"}/${name}: $!] 0 0 0
39
40 0 return $self;
41 }
42  
43 0 ▶sub listing {
Subroutine listing: not called CC=5 SCAR=34.0
Pod undocumented
44 0 my($self) = @_;
45 0 my %listing;
46 0 ▶ opendir(my $dh, $self->{path}) or die "Can't open directory '$self->{path}': $!";
Branch: 1 branch
BranchTrueFalseTotal
opendir my $dh, $self->{"path"} or die qq[Can't open directory '$self->{"path"}': $!] 0 0 0
47 0 ▶ while(my $file = readdir($dh)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $file = readdir $dh)) 0 0 0
48 0 ▶ next if $file eq '..' or $file eq '.';
Branch: 1 branch
BranchTrueFalseTotal
if $file eq ".." or $file eq "." 0 0 0
Condition0%0/3
$file eq ".." or $file eq "."
l!l&&r!l&&!r
000
MC/DC0%0/2
$file eq ".." or $file eq "."
$file eq ".." $file eq "."
Truth table0%0/3
A or B
A= $file eq ".."B= $file eq "."
ABresult
1X1
011
000
49 0 $listing{ $file } = -s "$self->{path}/$file";
50 }
51 0 closedir($dh);
52
53 0 return \%listing;
54 }
55  
56 1 1;
« SimpleBackuper/_print_table.pm ↑ Summary SimpleBackuper/_format.pm »