lib/Archive/BagIt/Role/Algorithm.pm

filter: Statementstmt 79.4% 27 / 34 Branchbran 75.0% 3 / 4 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 85.7% 6 / 7 Podpod 50.0% 1 / 2 totaltotal 69.6% 39 / 56 CC 5 SCAR 12.0
CC
5
Cov
73%
get_optimal_bufsize
5.9
register_plugin
2.0
BEGIN
1.0
CRAP 3.3
« lib/Archive/BagIt.pm ↑ Summary blib/lib/Archive/BagIt/Role/OpenSSL/Async.pm »
1 package Archive::BagIt::Role::Algorithm;
2 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 12 with 'Archive::BagIt::Role::Plugin';
7 # ABSTRACT: A role that defines the interface to a hashing algorithm
8 12 our $VERSION = '0.103'; # VERSION
9  
10 12 has 'name' => (
11 is => 'ro',
12 );
13  
14 12 has '_optimal_bufsize' => (
15 is => 'ro',
16 default => undef
17 );
18  
19  
20 546 ▶sub get_optimal_bufsize {
Subroutine get_optimal_bufsize: called CC=5 SCAR=17.8
Pod documented
21 546 my ($self, $fh) = @_;
22 546 ▶ return $self->{_optimal_bufsize} if defined $self->{_optimal_bufsize};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_optimal_bufsize"} 467 79 546
23 79 my $minsize = 8192;
24 79 my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
25 $atime, $mtime, $ctime, $blksize, $blocks)
26 = stat $fh;
27 # Windows systems return "" for $blksize
28 79 ▶ if ((defined $blksize) && ($blksize ne "") && ($blksize >= $minsize)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $blksize and $blksize ne '' and $blksize >= $minsize) { } 0 79 79
Condition33%2/6
defined $blksize and $blksize ne "" and $blksize >= $minsize
!ll&&!rl&&r
0790
defined $blksize and $blksize ne ""
!ll&&!rl&&r
0079
MC/DC0%0/3
defined $blksize and $blksize ne "" and $blksize >= $minsize
defined $blksize $blksize ne "" $blksize >= $minsize
Truth table25%1/4
A and B and C
A= defined $blksizeB= $blksize ne ""C= $blksize >= $minsize
ABCresult
0XX0
10X0
1100
1111
29 0 $self->{_optimal_bufsize} = $blksize;
30  
31 } else {
32 79 $self->{_optimal_bufsize} = $minsize;
33 }
34 #print "set optimal bufsize to $self->{_optimal_bufsize}\n";
35 79 return $self->{_optimal_bufsize};
36 }
37  
38 0 ▶sub register_plugin {
Subroutine register_plugin: not called CC=1 SCAR=6.9
Pod undocumented
39 0 my ($class, $bagit) =@_;
40 0 my $self = $class->new({bagit=>$bagit});
41 0 my $plugin_name = $self->plugin_name;
42 0 $self->bagit->plugins( { $plugin_name => $self });
43 0 $self->bagit->algos( {$self->name => $self });
44 0 return 1;
45 }
46 12 ▶no Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 12 1;
48  
49 __END__
« lib/Archive/BagIt.pm ↑ Summary blib/lib/Archive/BagIt/Role/OpenSSL/Async.pm »