blib/lib/Pipe/Tube/Csv.pm

filter: Statementstmt 100% 29 / 29 Branchbran 50.0% 1 / 2 Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 81.2% 39 / 48 CC 5 SCAR 8.9
CC
5
Cov
89%
init
4.5
run
2.0
BEGIN
1.0
CRAP 2.4
↑ Summary
1 package Pipe::Tube::Csv;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '0.05';
6  
7 1 ▶use base 'Pipe::Tube';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Text::CSV;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 1 ▶sub init {
Subroutine init: called CC=4 SCAR=15.0
Pod undocumented
13 1 my ($self, $attr) = @_;
14 1 ▶ die "First paramater of csv should be HASH reference or nothing" if $attr and ref $attr ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if $attr and ref $attr ne "HASH" 0 1 1
Condition33%1/3
$attr and ref $attr ne "HASH"
!ll&&!rl&&r
100
MC/DC0%0/2
$attr and ref $attr ne "HASH"
$attr ref $attr ne "HASH"
Truth table33%1/3
A and B
A= $attrB= ref $attr ne "HASH"
ABresult
0X0
100
111
15 1 ▶ $attr ||= {};
Condition50%1/2
$attr ||= {}
l!l
01
MC/DC0%0/1
$attr ||= {}
$attr
Truth table50%1/2
A
A= $attr
Aresult
11
00
16  
17 1 $self->logger("Receiving Csv definition: " . Dumper $attr);
18  
19 1 $self->{csv} = Text::CSV->new($attr);
20  
21 1 return $self;
22 }
23  
24 4 ▶sub run {
Subroutine run: called CC=2 SCAR=6.9
Pod undocumented
25 4 my ($self, @input) = @_;
26  
27 4 my @resp;
28 4 foreach my $line (@input) {
29 2 $self->{csv}->parse($line);
30 2 push @resp, [ $self->{csv}->fields ];
31 }
32 4 return @resp;
33 }
34  
35 1 1;
36  
37 __END__
↑ Summary