Pipe/Tube/Cat.pm

filter: Statementstmt 100% 37 / 37 Branchbran 100% 10 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 96.4% 54 / 56 CC 6 SCAR 9.2
CC
6
Cov
100%
run
4.0
_next_file
3.0
BEGIN
1.0
CRAP 2.5
« Pipe/Tube/Print.pm ↑ Summary Pipe/Tube/Uniq.pm »
1 package Pipe::Tube::Cat;
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 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use base 'Pipe::Tube';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = '0.06';
9  
10 19 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
11 19 my ($self, @files) = @_;
12 19 @{ $self->{files} } = @files;
13  
14 19 return $self;
15 }
16  
17 # implement <> here
18 128 ▶sub run {
Subroutine run: called CC=4 SCAR=13.9
Pod undocumented
19 128 my ($self, @files) = @_;
20  
21 128 push @{ $self->{files} }, @files;
22  
23 128 my $fh = $self->{fh};
24 128 while (1) {
25 157 ▶ if (not defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fh) 47 110 157
26 47 $fh = $self->_next_file;
27 }
28 157 ▶ return if not $fh;
Branch: 1 branch
BranchTrueFalseTotal
unless $fh 18 139 157
29 139 my $row = <$fh>;
30 139 ▶ if (defined $row) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $row) { } 110 29 139
31 110 $self->logger("Row read: $row");
32 110 return $row;
33 } else {
34 29 $fh = undef;
35 }
36 }
37 }
38  
39 47 ▶sub _next_file {
Subroutine _next_file: called CC=3 SCAR=11.0
40 47 my ($self) = @_;
41 47 ▶ while (my $file = shift @{ $self->{files} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $file = shift @{$$self{"files"};}) 30 18 48
42 30 $self->logger("Opening file '$file'");
43 30 ▶ if (open my $fh, "<", $file) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, '<', $file) { } 29 1 30
44 29 return $self->{fh} = $fh;
45 } else {
46 1 warn "Could not open '$file'. $!\n";
47 }
48 }
49 }
50  
51 1 1;
52  
« Pipe/Tube/Print.pm ↑ Summary Pipe/Tube/Uniq.pm »