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 7     7   2739 use strict;
  7         13  
  7         183  
3 7     7   36 use warnings;
  7         9  
  7         180  
4 7     7   48 use Moo::Role;
  7         19  
  7         46  
5 7     7   2115 use Carp qw(croak);
  7         23  
  7         1633  
6             with 'Archive::BagIt::Role::Plugin';
7             # ABSTRACT: A role that defines the interface to a hashing algorithm
8             our $VERSION = '0.092'; # VERSION
9              
10             has 'name' => (
11             is => 'ro',
12             );
13              
14              
15             sub get_optimal_bufsize {
16 549     549 1 764 my ($self, $fh) = @_;
17 549         4407 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 549 50 33     2922 if ((defined $blksize ) && ($blksize ne "") && ($blksize >= 512)) {
      33        
22 549         1897 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 7     7   45 no Moo;
  7         11  
  7         32  
36             1;
37              
38             __END__