lib/Net/SinFP3/Output/Console.pm untested

filter: Statementstmt 0.0% 0 / 43 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 67 CC 6 SCAR 26.6
CC
6
Cov
0%
run
30.0
_print
6.0
new
2.0
CRAP 14.3
1 #
2 # $Id: Console.pm,v 008243d3e89a 2018/07/21 14:54:07 gomor $
3 #
4 package Net::SinFP3::Output::Console;
5 use strict;
6 use warnings;
7  
8 use base qw(Net::SinFP3::Output);
9 __PACKAGE__->cgBuildIndices;
10  
11 sub new {
12 my $self = shift->SUPER::new(
13 @_,
14 );
15  
16 return $self;
17 }
18  
19 sub take {
20 return [
21 'Net::SinFP3::Result::Active',
22 'Net::SinFP3::Result::Passive',
23 'Net::SinFP3::Result::Unknown',
24 'Net::SinFP3::Result::PortError',
25 ];
26 }
27  
28 sub run {
29 my $self = shift->SUPER::run(@_) or return;
30  
31 my $global = $self->global;
32 my $log = $global->log;
33 my @results = $global->result;
34  
35 my $buf = '';
36 my $first = 1;
37 for my $r (@results) {
38 my $ref = ref($r);
39 if ($ref =~ /^Net::SinFP3::Result::Unknown$/) {
40 $buf .= $self->_print($r, \$first);
41 print $buf;
42 return 1;
43 }
44 elsif ($ref =~ /^Net::SinFP3::Result::PortError$/) {
45 $buf .= $self->_print($r, \$first);
46 print $buf;
47 return 1;
48 }
49 elsif ($ref =~ /^Net::SinFP3::Result::Active$/) {
50 $buf .= $self->_print($r, \$first);
51 }
52 elsif ($ref =~ /^Net::SinFP3::Result::Passive$/) {
53 $buf .= $self->_print($r, \$first);
54 }
55 else {
56 $log->warning("Don't know what to do with this result object ".
57 "with type: [$ref]");
58 }
59 }
60  
61 print $buf;
62  
63 return 1;
64 }
65  
66 sub _print {
67 my $self = shift;
68 my ($r, $first) = @_;
69 my $buf = '';
70 if ($$first) {
71 $buf .= $r->printSignature."\n";
72 $$first = 0;
73 }
74 $buf .= $r->print."\n";
75 return $buf;
76 }
77  
78 1;
79  
80 __END__