blib/lib/OPP/Proc/Output.pm

filter: Statementstmt 42.8% 15 / 35 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 1 totaltotal 38.0% 19 / 50 CC 7 SCAR 35.8
CC
7
Cov
35%
process
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 36.0
« blib/lib/OPP/Proc/Dedup.pm ↑ Summary blib/lib/OPP/Proc/Splitsubnet.pm »
1 #
2 # $Id: Output.pm,v cd68184c46bd 2023/03/23 09:32:23 gomor $
3 #
4 package OPP::Proc::Output;
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use base qw(OPP::Proc);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 __PACKAGE__->cgBuildIndices;
10  
11 1 our $VERSION = '1.00';
12  
13 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 #
16 # NOTE: default output format is txt
17 #
18 # | output
19 # | output format=txt
20 #
21 sub process {
22 0 ▶ my $self = shift;
Subroutine process: not called CC=7 SCAR=40.3
Pod undocumented
23 0 my ($input) = @_;
24  
25 0 my $options = $self->options;
26 0 ▶ my $format = $options->{format} || 'txt';
Condition0%0/2
$options->{'format'} || 'txt'
l!l
00
MC/DC0%0/1
$options->{'format'} || 'txt'
$options->{'format'}
Truth table0%0/2
A
A= $options->{'format'}
Aresult
11
00
27  
28 0 ▶ if ($format ne 'txt') {
Branch: 1 branch
BranchTrueFalseTotal
if ($format ne "txt") 0 0 0
29 0 die("output: invalid format given: $format, only accepts 'format=txt'\n");
30 }
31  
32 0 my $print = '';
33 0 for my $field (sort { $a cmp $b } @{$self->fields($input)}) {
34 0 ▶ next if $field =~ m{^_};
Branch: 1 branch
BranchTrueFalseTotal
if $field =~ /^_/ 0 0 0
35 0 my $value = $self->value($input, $field);
36 0 for my $v (@$value) {
37 0 $v =~ s{"}{\\"}g;
38 0 $print .= "$field:\"$v\" ";
39 }
40 }
41  
42 0 ▶ return 1 unless length $print;
Branch: 1 branch
BranchTrueFalseTotal
unless length $print 0 0 0
43  
44 0 $print =~ s{\s*$}{};
45 0 utf8::encode($print);
46 0 print "$print\n";
47  
48 # We don't add to output so nothing will be displayed after this proc:
49 #$self->output->add($input);
50  
51 0 return 1;
52 }
53  
54 1 1;
55  
56 __END__
« blib/lib/OPP/Proc/Dedup.pm ↑ Summary blib/lib/OPP/Proc/Splitsubnet.pm »