=head2 delimiters_templates
+Generate report of delimiter tamplates
+
+ my $report = $validate->delimiter_teplates(
+ report => 1,
+ );
+
+Options:
+
+=over 4
+
+=item report
+
+Generate humanly readable report with single fields
+
+=back
=cut
sub delimiters_templates {
my $self = shift;
+ my $args = {@_};
+
my $t = $self->{_delimiters_templates};
my $log = $self->_get_logger;
unless ($t) {
- $log->warn("called without delimiters");
+ $log->error("called without delimiters");
return;
}
my $out;
foreach my $f (sort { $a <=> $b } keys %$t) {
- $out .= "$f\n";
- foreach my $sft (sort { $a cmp $b } keys %{ $t->{$f} }) {
- $out .= "\t" . $t->{$f}->{$sft} . "\t$sft\n";
+ $out .= "$f\n" if ( $args->{report} );
+ foreach my $template (sort { $a cmp $b } keys %{ $t->{$f} }) {
+ my $count = $t->{$f}->{$template};
+ $out .=
+ ( $count ? "" : "# " ) .
+ ( $args->{report} ? "" : "$f\t" ) .
+ "\t$count\t$template\n";
}
}
print $report_fh "$errors\n" if ($report_fh);
}
- print $report_fh "\nAll possible subfields/delimiter templates:\n", $validate->delimiters_templates, "\n\n";
+ print $report_fh "\nAll possible subfields/delimiter templates:\n", $validate->delimiters_templates( report => 1 ), "\n\n";
}
if ($stats) {
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 5;
+use Test::More tests => 6;
use Test::Exception;
use blib;
ok(my $dt = $v->delimiters_templates, 'delimiters_template');
diag $dt;
+
+ok($dt = $v->delimiters_templates( report => 1 ), 'delimiters_template report');
+diag $dt;