Query/Handle.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 50 CC 6 SCAR 33.6
CC
6
Cov
0%
get_rows
42.0
BUILD
2.0
BEGIN
2.0
CRAP 28.7
1 package PSQL::Query::Handle;
2 use Moose;
3  
4 extends 'PSQL::Query';
5  
6 use IO::Handle;
7  
8 has 'handle' => (
9 isa => 'IO::Handle'
10 , is => 'ro'
11 , required => 1
12 );
13  
14 sub BUILD {
15 my $self = shift;
16 $self->get_rows
17 }
18  
19 sub get_rows {
20 my $self = shift;
21  
22 my $h = $self->handle;
23  
24 my @lines = $h->getlines;
25  
26 chomp @lines;
27  
28 ## Preprocess
29 ## Shift off the header
30 until ( (shift @lines) =~ /^-+$/ ) { next };
31  
32 ## ammend the lack of consistancy with the first row
33 $lines[0] = "-> $lines[0]";
34 foreach ( @lines[1..$#lines] ) {
35 $_ = " $_";
36 }
37  
38 my $row;
39 foreach my $line ( @lines ) {
40 chomp $line;
41  
42 next unless $line =~ /\S/;
43 ## Operation
44 if ( $line =~ /[.]{2}/ and $line !~ /:/ ) {
45  
46 $row = PSQL::Query::Token::Row::Operation->new({
47 src => $line
48 });
49 $self->push_row( $row );
50  
51 }
52  
53 ## Footer Rows
54 elsif ( $line =~ /^\s*Total runtime:\s+\d+\.\d+\s*ms$/ ) {}
55 elsif ( $line =~ /^\(\d+ rows\)$/ ) {}
56  
57 ## OperationalInfo
58 elsif ( $line !~ /^\s*->/ ) {
59 $row->add_info_row( $line )
60 }
61  
62 }
63  
64 }
65  
66 1;