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 8     8   3376 use strict;
  8         15  
  8         261  
3 8     8   37 use warnings;
  8         18  
  8         217  
4 8     8   37 use Moo::Role;
  8         13  
  8         46  
5 8     8   2553 use Carp qw(croak);
  8         18  
  8         1922  
6             with 'Archive::BagIt::Role::Plugin';
7             # ABSTRACT: A role that defines the interface to a hashing algorithm
8             our $VERSION = '0.094'; # VERSION
9              
10             has 'name' => (
11             is => 'ro',
12             );
13              
14              
15             sub get_optimal_bufsize {
16 550     550 1 790 my ($self, $fh) = @_;
17 550         4510 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 550 50 33     3403 if ((defined $blksize ) && ($blksize ne "") && ($blksize >= 512)) {
      33        
22 550         1938 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 8     8   52 no Moo;
  8         16  
  8         48  
36             1;
37              
38             __END__