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   3532 use strict;
  8         17  
  8         239  
3 8     8   35 use warnings;
  8         17  
  8         235  
4 8     8   55 use Moo::Role;
  8         14  
  8         54  
5 8     8   2798 use Carp qw(croak);
  8         18  
  8         2333  
6             with 'Archive::BagIt::Role::Plugin';
7             # ABSTRACT: A role that defines the interface to a hashing algorithm
8             our $VERSION = '0.095'; # VERSION
9              
10             has 'name' => (
11             is => 'ro',
12             );
13              
14              
15             sub get_optimal_bufsize {
16 549     549 1 772 my ($self, $fh) = @_;
17 549         4800 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     3568 if ((defined $blksize ) && ($blksize ne "") && ($blksize >= 512)) {
      33        
22 549         2128 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   59 no Moo;
  8         20  
  8         41  
36             1;
37              
38             __END__