| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%2/6
defined $blksize and $blksize ne "" and $blksize >= $minsize
defined $blksize and $blksize ne ""
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||