File Coverage

lib/Parse/File/Taxonomy/Auxiliary.pm
Criterion Covered Total %
statement 6 21 28.5
branch 0 4 0.0
condition n/a
subroutine 2 5 40.0
pod 0 2 0.0
total 8 32 25.0


line stmt bran cond sub pod time code
1             package Parse::File::Taxonomy::Auxiliary;
2 7     7   31 use strict;
  7         8  
  7         253  
3 7     7   91 use Carp;
  7         8  
  7         1776  
4             our ($VERSION, @ISA, @EXPORT_OK);
5             $VERSION = '0.03';
6             @ISA = qw( Exporter );
7             @EXPORT_OK = qw(
8             path_check_fields
9             components_check_fields
10             );
11              
12             =head1 NAME
13              
14             Parse::File::Taxonomy::Auxiliary - Utility subroutines for Parse::File::Taxonomy
15              
16             =head1 SYNOPSIS
17              
18             use Parse::File::Taxonomy::Auxiliary qw(
19             path_check_fields
20             components_check_fields
21             );
22              
23             =cut
24              
25             =head1 SUBROUTINES
26              
27             =cut
28              
29             sub path_check_fields {
30 0     0 0   my ($data, $fields_ref) = @_;
31 0           _check_fields($data, $fields_ref, 0);
32             }
33              
34             sub components_check_fields {
35 0     0 0   my ($data, $fields_ref) = @_;
36 0           _check_fields($data, $fields_ref, 1);
37             }
38              
39             sub _check_fields {
40 0     0     my ($data, $fields_ref, $components) = @_;
41 0           my %header_fields_seen;
42 0           for my $f (@{$fields_ref}) {
  0            
43 0 0         if (exists $header_fields_seen{$f}) {
44 0           my $error_msg = '';
45 0 0         if ($components) {
46 0           $error_msg = "Duplicate field '$f' observed in 'fields' array ref";
47             }
48             else {
49 0           $error_msg = "Duplicate field '$f' observed in '$data->{file}'";
50             }
51 0           croak $error_msg;
52             }
53             else {
54 0           $header_fields_seen{$f}++;
55             }
56             }
57             }
58              
59             1;
60              
61             # vim: formatoptions=crqot