Branch Coverage

blib/lib/Catmandu/MARC.pm
Criterion Covered Total %
branch 236 430 54.8


line true false branch
24 596 30 ref $_[2] ? :
28 0 626 unless $context
33 0 0 wantarray ? :
0 626 unless defined $record and ref $record eq 'ARRAY'
54 0 400 if $context->{'is_regex_field'} == 0 and $$field[0] ne $context->{'field'} or defined $context->{'ind1'} and !defined($$field[1]) || $$field[1] ne $context->{'ind1'} or defined $context->{'ind2'} and !defined($$field[2]) || $$field[2] ne $context->{'ind2'} or $context->{'is_regex_field'} == 1 and not $$field[0] =~ /$context->{'field_regex'}/
58 48 352 if ($value_set) { }
61 34 62 if ($$field[$i] =~ /$subfield_regex/)
70 16 336 if ($pluck) { }
86 417 143 if ($$field[$i] =~ /$subfield_regex/)
92 298 54 if (@$v) { }
93 227 71 unless ($split)
98 51 247 if (defined(my $off = $context->{'from'}))
99 11 40 if (ref $v eq 'ARRAY')
104 41 10 if (length $v > $off) { }
116 322 78 if (defined $v)
117 71 251 if ($split) { }
118 11 60 unless defined $v and ref $v eq 'ARRAY'
119 41 30 if (defined $vals and ref $vals eq 'ARRAY') { }
123 40 1 if ($nested_arrays == 1) { }
131 9 21 if ($nested_arrays == 1) { }
145 30 596 if ($split and defined $vals) { }
402 194 elsif ($append) { }
134 60 elsif (defined $vals) { }
167 10 0 if ($marc_path =~ /^\w{3}$/)
176 6 14 unless length $code == 1
179 6 8 if ($value =~ /^\$\.(\S+)$/)
184 3 11 if (Catmandu::Util::is_array_ref($value)) { }
0 11 elsif (Catmandu::Util::is_hash_ref($value)) { }
11 0 elsif (Catmandu::Util::is_value($value) and length $value > 0) { }
202 10 0 if @field > 3
214 0 1 unless defined $record
216 0 1 if ($value =~ /^\$\.(\S+)/)
221 0 1 if (Catmandu::Util::is_array_ref($value)) { }
0 1 elsif (Catmandu::Util::is_hash_ref($value)) { }
234 0 1 unless $context
239 0 19 if ($context->{'is_regex_field'}) { }
240 0 0 unless $tag =~ /$context->{'field_regex'}/
243 18 1 unless $tag eq $context->{'field'}
246 0 1 if (defined $context->{'ind1'})
247 0 0 if (not defined $ind1 or $ind1 ne $context->{'ind1'})
251 0 1 if (defined $context->{'ind2'})
252 0 0 if (not defined $ind2 or $ind2 ne $context->{'ind2'})
257 0 1 if ($context->{'subfield'}) { }
259 0 0 if ($subfields[$i] =~ /$context->{'subfield'}/)
276 0 3 unless defined $record
278 0 3 if ($value =~ /^\$\.(\S+)/)
283 0 3 if (Catmandu::Util::is_array_ref($value)) { }
0 3 elsif (Catmandu::Util::is_hash_ref($value)) { }
296 0 3 unless $context
301 0 57 if ($context->{'is_regex_field'}) { }
302 0 0 unless $tag =~ /$context->{'field_regex'}/
305 52 5 unless $tag eq $context->{'field'}
308 0 5 if (defined $context->{'ind1'})
309 0 0 if (not defined $ind1 or $ind1 ne $context->{'ind1'})
313 0 5 if (defined $context->{'ind2'})
314 0 0 if (not defined $ind2 or $ind2 ne $context->{'ind2'})
320 5 1 if ($subfields[$i] =~ /$context->{'subfield'}/)
334 0 8 unless defined $record
336 3 5 if ($value =~ /^\$\.(\S+)/)
341 0 8 if (Catmandu::Util::is_array_ref($value)) { }
0 8 elsif (Catmandu::Util::is_hash_ref($value)) { }
354 0 8 unless $context
359 0 168 if ($context->{'is_regex_field'}) { }
360 0 0 unless $tag =~ /$context->{'field_regex'}/
363 160 8 unless $tag eq $context->{'field'}
366 2 6 if (defined $context->{'ind1'})
367 0 2 if (not defined $ind1 or $ind1 ne $context->{'ind1'})
371 0 8 if (defined $context->{'ind2'})
372 0 0 if (not defined $ind2 or $ind2 ne $context->{'ind2'})
379 5 8 if ($subfields[$i] =~ /$context->{'subfield'}/)
380 1 4 if (defined $context->{'from'}) { }
390 3 5 if ($found == 0)
406 0 7 unless $context
411 7 113 if ($context->{'is_regex_field'} == 0 and $$field[0] eq $context->{'field'} or $context->{'is_regex_field'} == 1 and $$field[0] =~ /$context->{'field_regex'}/)
419 1 6 if (defined $context->{'ind1'} and defined $context->{'ind2'}) { }
0 6 elsif (defined $context->{'ind1'}) { }
1 5 elsif (defined $context->{'ind2'}) { }
421 0 0 if defined $$field[1] and $$field[1] eq $context->{'ind1'} and defined $$field[2] and $$field[2] eq $context->{'ind2'}
424 0 0 if defined $$field[1] and $$field[1] eq $context->{'ind1'}
427 1 0 if defined $$field[2] and $$field[2] eq $context->{'ind2'}
433 4 3 if ($ind_match and not defined $context->{'subfield_regex'})
437 3 0 if (defined $context->{'subfield_regex'})
441 2 4 unless ($$field[$i] =~ /$subfield_regex/)
447 2 1 if $ind_match
468 47 0 if (ref $_[2]) { }
486 0 47 if ($nested_arrays)
496 2 45 unless @fields
500 2 43 if ($field_spec->has_indicator1)
504 3 42 if ($field_spec->has_indicator2)
513 17 58 if ($sp->has_char_start)
514 2 15 '#' eq $sp->char_start ? :
523 18 27 if ($ms->has_subfields) { }
526 17 1 unless ($pluck)
532 4 14 if ($invert)
548 1 26 if defined $value_set
560 0 64 if ($nested_arrays) { }
29 35 elsif ($split) { }
569 44 0 if (defined $field_spec->index_start)
579 36 78 $prev_tag eq $current_tag && defined $tag_index ? :
584 21 93 if (defined $indicator1)
585 19 2 unless defined $$field[1] and $$field[1] =~ /$indicator1/
588 22 73 if (defined $indicator2)
590 14 8 unless defined $$field[2] and $$field[2] =~ /$indicator2/
594 81 0 if (defined $index_range)
595 9 72 unless Catmandu::Util::array_includes($index_range, $tag_index)
599 2 70 if ($field_spec->has_subspecs)
601 1 1 unless $valid
606 29 42 if ($ms->has_subfields) { }
609 12 34 if ($invert and not $sf->has_subspecs)
610 6 6 if (-1 == $sf->index_length and not $sf->has_char_start) { }
4 2 elsif ($sf->has_char_start) { }
611 1 5 if $invert_level == 3
623 5 40 $invert_level == 3 ? :
626 64 78 if ($$field[$i] =~ /$code/)
631 5 40 if ($invert_level == 3)
632 1 4 if (@subfield)
636 0 5 if ($referred and $value_set)
643 10 30 unless @subfield
646 30 0 if (defined $sf->index_start)
650 1 29 if ($invert_level == 2) { }
652 1 2 Catmandu::Util::array_includes($sf_range, $_) ? :
660 36 2 defined $subfield[$_] ? :
665 2 28 unless @subfield
669 0 28 if $value_set
672 0 28 if ($sf->has_subspecs)
674 0 0 unless $valid
679 7 21 if (defined $char_start)
680 4 3 if ($invert_level == 1) { }
693 0 28 unless @subfield
696 22 7 if @subfields
703 10 37 defined $char_start ? :
708 0 42 unless @contents
712 2 42 unless $referred
714 4 38 if ($append) { }
15 23 elsif ($split) { }
715 1 3 if $split
729 7 7 if ref $subspec->$side eq 'MARC::Spec::Comparisonstring'
731 0 7 unless $tag eq $subspec->$side->field->tag
738 1 3 if (ref $subspec eq 'ARRAY') { }
743 1 3 if $valid
750 1 2 unless $valid
760 7 0 if ('!' ne $subspec->operator and '?' ne $subspec->operator)
761 7 0 if (ref $subspec->left ne 'MARC::Spec::Comparisonstring') { }
767 0 7 unless defined $left_subterm
774 0 7 if (ref $subspec->right ne 'MARC::Spec::Comparisonstring') { }
780 0 0 unless (defined $right_subterm)
788 0 7 if ($subspec->operator eq '?')
789 0 0 @{$right_subterm;} ? :
792 0 7 if ($subspec->operator eq '!')
793 0 0 @{$right_subterm;} ? :
796 7 0 if ($subspec->operator eq '=')
798 3 4 if &List::Util::any(sub { $v eq $_; } , @{$right_subterm;})
802 0 4 if ($subspec->operator eq '!=')
804 0 0 if &List::Util::any(sub { $v eq $_; } , @{$right_subterm;})
809 0 4 if ($subspec->operator eq '~')
811 0 0 if &List::Util::any(sub { $v =~ /$_/; } , @{$right_subterm;})
815 0 4 if ($subspec->operator eq '!~')
817 0 0 if &List::Util::any(sub { $v =~ /$_/; } , @{$right_subterm;})
868 1 0 if (my $marc = delete $data->{'record'})
872 1 5 if ($tag eq 'LDR') { }
2 3 elsif ($tag eq 'FMT' or substr($tag, 0, 2) eq '00') { }
882 3 0 !defined($subfields[0]) || $subfields[0] eq '_' ? :
902 1 0 if (Catmandu::Util::is_string($data->{'leader'}))
906 1 0 if (Catmandu::Util::is_array_ref($data->{'fields'}))
908 0 5 unless Catmandu::Util::is_hash_ref($field)
913 2 3 if ($tag eq 'FMT' or substr($tag, 0, 2) eq '00') { }
3 0 elsif (Catmandu::Util::is_hash_ref($val)) { }
919 0 3 unless Catmandu::Util::is_array_ref($val->{'subfields'})
923 0 5 unless Catmandu::Util::is_hash_ref($sf)
936 1 0 if (@$record > 0)
1049 0 0 ref $marc_path ? :
1051 0 0 unless $context
1056 0 0 wantarray ? :
0 0 unless defined $record and ref $record eq 'ARRAY'
1066 0 0 if ($context->{'is_regex_field'} == 0 and $tag ne $context->{'field'} or $context->{'is_regex_field'} == 1 and not $tag =~ /$context->{'field_regex'}/)
1071 0 0 if $is_cut
1075 0 0 if (defined $context->{'ind1'})
1076 0 0 if (not defined $ind1 or $ind1 ne $context->{'ind1'})
1077 0 0 if $is_cut
1081 0 0 if (defined $context->{'ind2'})
1082 0 0 if (not defined $ind2 or $ind2 ne $context->{'ind2'})
1083 0 0 if $is_cut
1088 0 0 if ($context->{'subfield'}) { }
1091 0 0 if ($subfields[$i] =~ /$context->{'subfield'}/)
1092 0 0 if (defined $marc_value) { }
1093 0 0 if $subfields[$i + 1] =~ /$marc_value/
1101 0 0 unless ($found)
1102 0 0 if $is_cut
1107 0 0 if (defined $marc_value)
1115 0 0 unless ($string =~ /$marc_value/)
1116 0 0 if $is_cut
1126 0 0 if (defined $$field[1]) { }
1133 0 0 if (defined $$field[2]) { }
1140 0 0 if ($$field[3] eq '_')
1154 0 0 if ($is_cut)
1170 0 0 unless Catmandu::Util::is_array_ref($value)
1180 0 0 unless Catmandu::Util::is_hash_ref($part) and exists $part->{'tag'} and exists $part->{'ind1'} and exists $part->{'ind2'} and exists $part->{'content'} || exists $part->{'subfields'}
1188 0 0 if (defined $content) { }
0 0 elsif (defined $subfields and Catmandu::Util::is_array_ref($subfields)) { }
1208 0 0 if (defined $marc_path) { }
1211 0 0 unless $context
1222 0 0 if ($context->{'is_regex_field'}) { }
1223 0 0 unless $tag =~ /$context->{'field_regex'}/
1226 0 0 unless $tag eq $context->{'field'}
1229 0 0 if (defined $context->{'ind1'})
1230 0 0 if (not defined $ind1 or $ind1 ne $context->{'ind1'})
1234 0 0 if (defined $context->{'ind2'})
1235 0 0 if (not defined $ind2 or $ind2 ne $context->{'ind2'})
1240 0 0 if ($context->{'subfield'}) { }
1242 0 0 if ($subfields[$i] =~ /$context->{'subfield'}/)
1243 0 0 if (defined $marc_value) { }
1244 0 0 if $subfields[$i + 1] =~ /$marc_value/
1252 0 0 if (defined $marc_value) { }
1260 0 0 if ($string =~ /$marc_value/) { }
1273 0 0 if (defined $found_match)