File Coverage

blib/lib/Data/Grid/CSV.pm
Criterion Covered Total %
statement 24 43 55.8
branch 0 8 0.0
condition 0 2 0.0
subroutine 8 16 50.0
pod 5 5 100.0
total 37 74 50.0


line stmt bran cond sub pod time code
1             package Data::Grid::CSV;
2              
3 1     1   1043 use warnings FATAL => 'all';
  1         3  
  1         43  
4 1     1   5 use strict;
  1         2  
  1         21  
5              
6 1     1   4 use base 'Data::Grid';
  1         2  
  1         54  
7              
8 1     1   627 use Text::CSV;
  1         13947  
  1         40  
9 1     1   6 use IO::File;
  1         1  
  1         237  
10              
11             =head1 NAME
12              
13             Data::Grid::CSV - CSV driver for Data::Grid
14              
15             =head1 VERSION
16              
17             Version 0.01_01
18              
19             =cut
20              
21             our $VERSION = '0.01_01';
22              
23             =head2 new
24              
25             =cut
26              
27             sub new {
28 0     0 1   my $class = shift;
29 0           my %p = @_;
30 0 0 0       $p{driver} = Text::CSV->new($p{options} || {}) or die $!;
31 0           bless \%p, $class;
32             }
33              
34             =head2 tables
35              
36             =cut
37              
38             sub tables {
39 0     0 1   my $self = shift;
40             #warn @Data::Grid::CSV::Table::ISA;
41 0           my $table = $self->table_class->new($self, 0);
42 0 0         wantarray ? ($table) : [$table];
43             }
44              
45             =head2 table_class
46              
47             =cut
48              
49             sub table_class {
50 0     0 1   'Data::Grid::CSV::Table';
51             }
52              
53             =head2 row_class
54              
55             =cut
56              
57             sub row_class {
58 0     0 1   'Data::Grid::CSV::Row';
59             }
60              
61             =head2 cell_class
62              
63             =cut
64              
65             sub cell_class {
66 0     0 1   'Data::Grid::CSV::Cell';
67             }
68              
69             package Data::Grid::CSV::Table;
70              
71             #use Data::Grid::Table;
72              
73 1     1   6 use base 'Data::Grid::Table';
  1         2  
  1         146  
74              
75             sub rewind {
76 0     0     my $self = shift;
77 0           seek $self->parent->{fh}, 0, 0;
78             }
79              
80             sub next {
81 0     0     my $self = shift;
82 0 0         my $row = $self->parent->{driver}->getline($self->parent->{fh}) or return;
83 0           $self->parent->row_class->new($self, $self->{counter}++, $row);
84             }
85              
86             package Data::Grid::CSV::Row;
87              
88 1     1   6 use base 'Data::Grid::Row';
  1         1  
  1         91  
89              
90             sub cells {
91 0     0     my $self = shift;
92 0           my @cells = @{$self->proxy};
  0            
93 0 0         wantarray ? @cells : \@cells;
94             }
95              
96             package Data::Grid::CSV::Cell;
97              
98 1     1   5 use base 'Data::Grid::Cell';
  1         3  
  1         62  
99              
100             =head1 AUTHOR
101              
102             Dorian Taylor, C<< >>
103              
104             =head1 BUGS
105              
106             Please report any bugs or feature requests to C, or through
107             the web interface at L. I will be notified, and then you'll
108             automatically be notified of progress on your bug as I make changes.
109              
110             =head1 SUPPORT
111              
112             You can find documentation for this module with the perldoc command.
113              
114             perldoc Data::Grid::CSV
115              
116             You can also look for information at:
117              
118             =over 4
119              
120             =item * RT: CPAN's request tracker
121              
122             L
123              
124             =item * AnnoCPAN: Annotated CPAN documentation
125              
126             L
127              
128             =item * CPAN Ratings
129              
130             L
131              
132             =item * Search CPAN
133              
134             L
135              
136             =back
137              
138              
139             =head1 ACKNOWLEDGEMENTS
140              
141              
142             =head1 LICENSE AND COPYRIGHT
143              
144             Copyright 2010 Dorian Taylor.
145              
146             This program is free software; you can redistribute it and/or modify it
147             under the terms of either: the GNU General Public License as published
148             by the Free Software Foundation; or the Artistic License.
149              
150             See http://dev.perl.org/licenses/ for more information.
151              
152              
153             =cut
154              
155             1; # End of Data::Grid::CSV