File Coverage

blib/lib/DBI/Format/CSV.pm
Criterion Covered Total %
statement 33 33 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 0 3 0.0
total 40 43 93.0


line stmt bran cond sub pod time code
1             # -*- perl -*-
2             # vim:ts=4:sw=4:aw:ai:
3             #
4             # DBI::Format::CSV - a package for displaying result tables
5             #
6             # Copyright (c) 2001, 2002 Thomas A. Lowery
7             #
8             # The DBI::Shell::CSV module is free software; you can redistribute
9             # it and/or modify it under the same terms as Perl itself.
10             #
11              
12 1     1   7 use strict;
  1         2  
  1         65  
13              
14             package DBI::Format::CSV;
15              
16             our $VERSION = '11.97'; # VERSION
17              
18             @DBI::Format::CSV::ISA = qw(DBI::Format::Base);
19              
20 1     1   6 use Text::Abbrev;
  1         2  
  1         52  
21 1     1   5 use Text::Reform qw(form break_with);
  1         2  
  1         8  
22 1     1   1130 use Text::CSV_XS;
  1         12188  
  1         272  
23              
24             sub header {
25 3     3 0 9 my ($self, $sth, $fh, $sep) = @_;
26 3         19 $self->SUPER::header($sth, $fh, $sep);
27 3         7 $self->{'data'} = [];
28 3         7 $self->{'formats'} = [];
29              
30             $self->{csv_obj} = Text::CSV_XS->new({
31             binary => 1,
32             sep_char => $self->{sep},
33 3         25 always_quote => 1,
34             });
35              
36 3         517 my $names = $sth->{'NAME'};
37 3         9 my $csv = $self->{csv_obj};
38 3         57 my $status = $csv->print($fh, $names);
39 3         165 $fh->print( "\n" );
40 3         43 return 1;
41             }
42              
43             sub row {
44 30     30 0 50 my($self, $orig_row) = @_;
45 30         42 my $i = 0;
46 30         113 my @row = $self->SUPER::row([@$orig_row]); # don't alter original
47              
48 30         66 my $columns = $self->{'columns'};
49 30         47 my $breaks = $self->{'breaks'};
50              
51 30         43 my $fh = $self->{'fh'};
52 30         61 my $csv = $self->{csv_obj};
53 30         181 my $status = $csv->print($fh, \@row);
54 30         1299 $fh->print( "\n" );
55              
56 30         439 return ++$self->{rows};
57             }
58              
59              
60             sub trailer {
61 3     3 0 7 my $self = shift;
62             # $self->SUPER::trailer(@_);
63             }
64              
65             1;
66              
67             =head1 NAME
68              
69             DBI::Format::CSV - A package for displaying result tables
70              
71             =head1 SYNOPSIS
72              
73             =head1 DESCRIPTION
74              
75             THIS PACKAGE IS STILL VERY EXPERIMENTAL. THINGS WILL CHANGE.
76              
77             =head1 AUTHOR AND COPYRIGHT
78              
79             Orignal Format module is Copyright (c) 1997, 1998
80              
81             Jochen Wiedmann
82             Am Eisteich 9
83             72555 Metzingen
84             Germany
85              
86             Email: joe@ispsoft.de
87             Phone: +49 7123 14887
88              
89             SQLMinus is Copyright (c) 2001, 2002 Thomas A. Lowery
90              
91             The DBI::Format::CSV module is free software; you can redistribute it and/or
92             modify it under the same terms as Perl itself.
93              
94              
95             =head1 SEE ALSO
96              
97             L, L, L