Branch Coverage

blib/lib/Catmandu/BagIt.pm
Criterion Covered Total %
branch 173 234 73.9


line true false branch
185 1 22 unless $filename
188 21 11 if $_->filename eq $filename
196 1 2 unless $filename
199 1 1 if $_->filename eq $filename
233 1 118 unless $file
248 1 194 unless $file
257 1 10 unless $path
261 1 9 unless (-d $path)
283 0 9 if (wantarray) { }
284 0 0 $ok == 7 ? :
287 8 1 $ok == 7 ? :
297 1 24 unless $path
300 0 24 if ($self->locked($path))
306 1 23 if (defined $self->path and $path ne $self->path) { }
13 10 elsif (defined $self->path and $path eq $self->path) { }
4 11 elsif ($opts{'overwrite'} and -d $path) { }
326 14 10 if (-f $self->_bagit_file($path)) { }
327 13 1 if ($opts{'overwrite'}) { }
342 0 23 unless ($self->touch($self->_lock_file($path)))
358 0 23 unless $ok == 6
401 31 22 if -f $p
412 31 22 if -f $p
446 0 26 unless defined $path
454 0 24 unless defined $path
465 0 21 unless defined $filename and defined $data
470 1 20 unless ($self->_is_legal_file_name($filename))
478 7 13 if ($opts{'overwrite'})
482 1 19 if ($self->get_checksum("$filename"))
493 2 17 if (is_string($opts{'md5'})) { }
0 17 elsif (is_string($opts{'sha1'})) { }
0 17 elsif (is_string($opts{'sha256'})) { }
0 17 elsif (is_string($opts{'sha512'})) { }
494 0 2 if ($self->algorithm ne 'md5') { }
1 1 elsif ($opts{'md5'} =~ /^[0-9a-f]{32}$/) { }
509 0 0 if ($self->algorithm ne 'sha1') { }
0 0 elsif ($opts{'sha1'} =~ /^[0-9a-f]{5,40}$/) { }
524 0 0 if ($self->algorithm ne 'sha256') { }
0 0 elsif ($opts{'sha256'} =~ /^[A-Fa-f0-9]{64}$/) { }
539 0 0 if ($self->algorithm ne 'sha512') { }
0 0 elsif ($opts{'sha512'} =~ /^[A-Fa-f0-9]{128}$/) { }
582 0 14 unless defined $filename
586 5 9 unless ($self->get_checksum($filename))
596 0 9 unless ($idx != -1)
618 0 4 unless defined $url and $size =~ /^[0-9]+$/ and defined $filename
621 0 4 unless $self->_is_legal_file_name($filename)
643 0 2 unless defined $filename
660 0 1 unless defined $fetch and ref $fetch and ref($fetch) =~ /^Catmandu::BagIt::Fetch/
673 1 0 if ($response->is_success) { }
689 0 188 unless defined $name and defined $values
692 178 10 if ($name =~ /^(Bag-Size|Bagging-Date|Payload-Oxum)$/)
694 100 177 if ($part->[0] eq $name)
705 0 10 if (ref $values eq 'ARRAY') { }
724 0 5 unless defined $name
727 1 4 if ($name =~ /^(Bag-Size|Bagging-Date|Payload-Oxum)$/)
754 0 447 unless $field
758 438 9 wantarray ? :
766 0 62 if ($total > 100000000000) { }
0 62 elsif ($total > 104857600) { }
2 60 elsif ($total > 102400) { }
804 0 10 unless ($self->version and $self->version =~ /^[0-9]+\.[0-9]+$/)
809 0 10 unless ($self->encoding and $self->encoding eq 'UTF-8')
817 19 4 unless (grep {(my $filename = $_->{'filename'} || '') =~ /^$file$/;} $self->list_files)
823 0 31 unless (grep {/^$file$/;} $self->list_tags)
829 19 0 unless (grep {$_->filename =~ /^$file$/;} $self->list_fetch)
835 2 8 $self->list_fetch > 0 ? :
837 9 1 if $self->errors == 0 and @missing == 0
851 0 74 unless (defined $path and -d $path)
856 43 31 $tag == 0 ? :
857 43 31 $tag == 0 ? :
861 38 36 unless ($fh)
872 2 34 unless (lc $sum eq lc $sum_check)
882 1 10 if ($self->dirty)
891 38 5 if ($code == 0)
899 2 29 if ($code == 0)
969 8 88 if ($self->list_fetch) { }
973 4 4 unless (grep {/fetch.txt/;} $self->list_tags)
989 27 5 unless -f $self->_fetch_file($path)
1014 1 31 unless ($manifest)
1027 0 31 if ($self->algorithm and $self->algorithm ne $algorithm) { }
1045 1 31 unless ($manifest)
1058 66 0 if ($self->escape)
1087 31 98 if $file =~ /^tagmanifest-\w+.txt$/
1102 3 29 unless (-d "$path/data")
1129 31 1 -f $self->_bag_info_file($path) ? :
1133 1 31 unless (-f $info_file)
1143 12 115 if ($line =~ /^\s+/)
1162 1 31 unless (-f $self->_bagit_file($path))
1173 31 31 if ($n eq 'BagIt-Version') { }
31 0 elsif ($n eq 'Tag-File-Character-Encoding') { }
1187 13 10 unless $self->dirty & 1
1213 0 23 unless $self->dirty & 2
1235 427 427 $cnt == 0 ? :
1236 427 0 $cnt == 0 ? :
1250 1 22 unless $self->dirty & 8
1255 10 12 unless (-d "$path/data")
1256 0 10 unless (mkdir "$path/data")
1273 10 14 unless $item->flag & 100
1280 0 14 unless -d "$path/$dir"
1285 14 0 if ($item->is_new) { }
1304 4 24 unless (grep {$filename eq $_;} @all_names_in_bag)
1318 0 23 unless $self->dirty & 4
1322 20 3 unless (defined $fetch_str and length $fetch_str)
1324 1 19 if -f $self->_fetch_file($path)
1330 0 3 if ($self->_fetch == 0)
1331 0 0 if -r $self->_fetch_file($path)
1358 0 23 unless $self->dirty & 50
1376 52 67 unless defined $path
1381 12 75 unless -f $self->_payload_file($path, $file)
1384 75 0 if ($self->escape)
1398 0 23 unless $self->dirty & 22
1435 259 90 if ($algorithm =~ /^sha/) { }
1442 52 297 if (not defined $data) { }
244 53 elsif (not ref $data) { }
0 53 elsif (ref $data eq 'SCALAR') { }
53 0 elsif (ref($data) =~ /^IO/) { }
1467 0 25 unless $filename eq $normal
1468 1 24 unless "/$filename" eq $abs