blib/lib/Pipeline/Dumper.pm untested

filter: Statementstmt 0.0% 0 / 56 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 84 CC 5 SCAR 13.9
CC
5
Cov
0%
init
6.0
dispatch_a_segment
6.0
print
6.0
CRAP 4.0
1 package Pipeline::Dumper;
2  
3 use strict;
4 use warnings;
5  
6 use Pipeline::Dispatch;
7 use base qw( Pipeline::Dispatch );
8  
9 our $VERSION = "3.12";
10  
11 sub init {
12 my $self = shift;
13 if ($self->SUPER::init( @_ )) {
14 $self->{ indent } = 0;
15 return $self;
16 }
17 }
18  
19 sub dispatch_a_segment {
20 my $self = shift;
21 my $seg = shift;
22 if ($seg->isa('Pipeline')) {
23 $self->next_pipeline( $seg );
24 } else {
25 $self->next_segment( $seg );
26 }
27 return 1;
28 }
29  
30 sub next_pipeline {
31 my $self = shift;
32 my $seg = shift;
33 my $pipe = $seg->parent();
34 $self->indent;
35 $self->print($seg);
36 $self->indent;
37  
38 ## this sets up the dispatcher in the next pipeline
39 $seg->dispatcher(
40 ref($self)->new()
41 ->indent( $self->indent_val )
42 ->segments(
43 $seg->dispatcher
44 ->segments
45 )
46 );
47 $seg->dispatch();
48 $self->undent;
49 $self->undent;
50 }
51  
52 sub next_segment {
53 my $self = shift;
54 my $seg = shift;
55 my $pipe = $seg->parent();
56 $self->print($seg);
57 }
58  
59 sub print {
60 my $self = shift;
61 my $seg = shift;
62 print " " x $self->indent_val();
63 if ($seg->isa('Pipeline')) { print "> " }
64 else { print "| " }
65 print ref($seg);
66 print "\n";
67 }
68  
69 sub indent {
70 my $self = shift;
71 my $val = shift;
72 if (defined( $val )) {
73 $self->{ indent } = $val;
74 return $self;
75 } else {
76 $self->{ indent }++;
77 }
78 }
79  
80 sub undent {
81 my $self = shift;
82 $self->{ indent }--;
83 }
84  
85 sub indent_val {
86 my $self = shift;
87 return $self->{ indent };
88 }
89  
90  
91 1;
92  
93 __END__