File Coverage

blib/lib/XML/SAX/ByRecord.pm
Criterion Covered Total %
statement 22 22 100.0
branch 3 6 50.0
condition 2 6 33.3
subroutine 4 4 100.0
pod 1 1 100.0
total 32 39 82.0


line stmt bran cond sub pod time code
1             package XML::SAX::ByRecord;
2             {
3             $XML::SAX::ByRecord::VERSION = '0.46';
4             }
5             # ABSTRACT: Record oriented processing of (data) documents
6              
7              
8 2     2   17 use base qw( XML::SAX::Machine );
  2         6  
  2         1420  
9              
10 2     2   14 use strict;
  2         5  
  2         72  
11 2     2   12 use Carp;
  2         6  
  2         657  
12              
13              
14             sub new {
15 2     2 1 7 my $proto = shift;
16 2   33     17 my $class = ref $proto || $proto;
17 2 50 33     20 my @options_hash_if_present = @_ && ref $_[-1] eq "HASH" ? pop : () ;
18              
19 2         5 my $stage_num = 0;
20              
21 2         21 my @machine_spec = (
22             [ Intake => "XML::Filter::DocSplitter" ],
23             map( [ "Stage_" . $stage_num++ => $_ ], @_ ),
24             [ Merger => "XML::Filter::Merger" => qw( Exhaust ) ],
25             );
26              
27 2         12 push @{$machine_spec[$_]}, "Stage_" . $_
28 2         13 for 0..$#machine_spec-2 ;
29              
30 2 50       10 push @{$machine_spec[-2]}, "Merger"
  2         7  
31             if @machine_spec;
32              
33 2         22 my $self = $proto->SUPER::new(
34             @machine_spec,
35             @options_hash_if_present
36             );
37              
38 2         15 my $distributor = $self->find_part( 0 );
39 2 50       22 $distributor->set_aggregator( $self->find_part( -1 ) )
40             if $distributor->can( "set_aggregator" );
41              
42 2         109 return $self;
43             }
44              
45              
46             1;
47              
48             __END__