File Coverage

blib/lib/Google/Fusion/Result.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Google::Fusion::Result;
2 1     1   31 use 5.006;
  1         4  
  1         44  
3 1     1   8 use Moose;
  1         1  
  1         11  
4 1     1   7752 use Carp;
  1         3  
  1         471  
5              
6             =head1 NAME
7              
8             Google::Fusion::Result - A Query result
9              
10             =head1 VERSION
11              
12             Version 0.03
13              
14             =cut
15              
16             our $VERSION = '0.03';
17              
18              
19             =head1 SYNOPSIS
20              
21             my $fusion = Google::Fusion->new( %fusion_params );
22              
23             # Get the result for a query
24             my $result = $fusion->query( $sql );
25            
26             # Print out the rows returned
27             foreach( @{ $result->rows } ){
28             print join( ',', @{ $_ } ) . "\n";
29             }
30              
31             =head1 PARAMS/ACCESSORS
32              
33             =over 2
34              
35             =item * query <Str>
36              
37             The query string
38              
39             =item * response <HTTP::Response>
40              
41             The response object associated with the query
42              
43             =item * error <Str>
44              
45             Error string, if an error occurred
46              
47             =item * num_columns <Int>
48              
49             Number of columns the result has
50              
51             =item * num_rows <Int>
52              
53             Number of rows this result has (excluding headers).
54              
55             =item * max_lengths <ArrayRef[Int]>
56              
57             Array of the maximum lengths of fields for each column
58              
59             =item * has_headers <Bool>
60              
61             True if this result has headers
62              
63             =item * query_time <Num>
64              
65             Seconds (using Time::HiRes) the query took
66              
67             =item * auth_time <Num>
68              
69             Seconds (using Time::HiRes) the authentication part of the query took
70              
71             =item * total_time <Num>
72              
73             Total time for the query
74              
75             =item * rows <ArrayRef[ArrayRef]>
76              
77             The actual results
78              
79             =item * columns <ArrayRef>
80              
81             The column names (if has_headers is true).
82              
83             =back
84              
85             =cut
86              
87             has 'query' => ( is => 'ro', isa => 'Str', required => 1 );
88             has 'response' => ( is => 'ro', isa => 'HTTP::Response', required => 1 );
89             has 'error' => ( is => 'rw', isa => 'Str', );
90             has 'num_columns' => ( is => 'rw', isa => 'Int', required => 1, default => 0 );
91             has 'num_rows' => ( is => 'rw', isa => 'Int', required => 1, default => 0 );
92             has 'max_lengths' => ( is => 'rw', isa => 'ArrayRef', required => 1, default => sub{ [] } );
93             has 'has_headers' => ( is => 'rw', isa => 'Bool', required => 1, default => 0 );
94             has 'query_time' => ( is => 'rw', isa => 'Num', required => 1, default => 0 );
95             has 'auth_time' => ( is => 'rw', isa => 'Num', required => 1, default => 0 );
96             has 'total_time' => ( is => 'rw', isa => 'Num', required => 1, default => 0 );
97             has 'rows' => (
98             is => 'rw',
99             isa => 'ArrayRef[ArrayRef]',
100             required => 1,
101             default => sub{ [] },
102             trigger => sub{ $_[0]->num_rows( scalar( @{ $_[1] } ) ) },
103             );
104              
105             has 'columns' => (
106             is => 'rw',
107             isa => 'ArrayRef',
108             required => 1,
109             default => sub{ [] },
110             trigger => sub{ $_[0]->num_columns( scalar( @{ $_[1] } ) ) },
111             );
112              
113             =head1 AUTHOR
114              
115             Robin Clarke, C<< <perl at robinclarke.net> >>
116              
117             =head1 LICENSE AND COPYRIGHT
118              
119             Copyright 2011 Robin Clarke.
120              
121             This program is free software; you can redistribute it and/or modify it
122             under the terms of either: the GNU General Public License as published
123             by the Free Software Foundation; or the Artistic License.
124              
125             See http://dev.perl.org/licenses/ for more information.
126              
127              
128             =cut
129              
130             1;