File Coverage

lib/Archive/BagIt/Role/Algorithm.pm
Criterion Covered Total %
statement 19 26 73.0
branch 1 2 50.0
condition 2 6 33.3
subroutine 6 7 85.7
pod 1 2 50.0
total 29 43 67.4


line stmt bran cond sub pod time code
1             package Archive::BagIt::Role::Algorithm;
2 12     12   225651 use strict;
  12         27  
  12         605  
3 12     12   68 use warnings;
  12         21  
  12         696  
4 12     12   669 use Moo::Role;
  12         20716  
  12         86  
5 12     12   7225 use Carp qw(croak);
  12         26  
  12         4005  
6             with 'Archive::BagIt::Role::Plugin';
7             # ABSTRACT: A role that defines the interface to a hashing algorithm
8             our $VERSION = '0.101'; # VERSION
9              
10             has 'name' => (
11             is => 'ro',
12             );
13              
14              
15             sub get_optimal_bufsize {
16 540     540 1 997 my ($self, $fh) = @_;
17 540         4474 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
18             $atime,$mtime,$ctime,$blksize,$blocks)
19             = stat $fh;
20             # Windows systems return "" for $blksize
21 540 50 33     3890 if ((defined $blksize ) && ($blksize ne "") && ($blksize >= 512)) {
      33        
22 540         3678 return $blksize;
23             }
24 0           return 8192;
25             }
26              
27             sub register_plugin {
28 0     0 0   my ($class, $bagit) =@_;
29 0           my $self = $class->new({bagit=>$bagit});
30 0           my $plugin_name = $self->plugin_name;
31 0           $self->bagit->plugins( { $plugin_name => $self });
32 0           $self->bagit->algos( {$self->name => $self });
33 0           return 1;
34             }
35 12     12   785 no Moo;
  12         3729  
  12         107  
36             1;
37              
38             __END__