blib/lib/DBI/Format/CSV.pm

filter: Statementstmt 97.8% 45 / 46 Branchbran 50.0% 2 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 87.3% 55 / 63 CC 4 SCAR 5.9
CC
4
Cov
92%
row
3.0
header
2.0
BEGIN
1.0
CRAP 1.8
« blib/lib/DBI/Shell/Timing.pm ↑ Summary dbish_config »
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 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 package DBI::Format::CSV;
15  
16 1 @DBI::Format::CSV::ISA = qw(DBI::Format::Base);
17  
18 1 ▶use Text::Abbrev;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use Text::Reform qw(form break_with);
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use Text::CSV_XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 sub header {
23 3 ▶ my($self, $sth, $fh, $sep) = @_;
Subroutine header: called CC=2 SCAR=6.9
Pod undocumented
24 3 $self->{'fh'} = $self->setup_fh($fh);
25 3 $self->{'sth'} = $sth;
26 3 $self->{'data'} = [];
27 3 $self->{'formats'} = [];
28 3 ▶ $self->{sep} = $sep if defined $sep;
Branch: 1 branch
BranchTrueFalseTotal
if defined $sep 3 0 3
29  
30 $self->{csv_obj} = Text::CSV_XS->new({
31 binary => 1,
32 sep_char => $self->{sep},
33 3 always_quote => 1,
34 });
35  
36 3 my $names = $sth->{'NAME'};
37 3 my $csv = $self->{csv_obj};
38 3 my $status = $csv->print($fh, $names);
39 3 $fh->print( "\n" );
40 3 return 1;
41 }
42  
43 sub row {
44 30 ▶ my($self, $orig_row) = @_;
Subroutine row: called CC=3 SCAR=11.1
Pod undocumented
45 30 my $i = 0;
46 30 my @row = @$orig_row; # don't mess with the original row
47  
48 # default value for null, is blank.
49 30 ▶ my $null = $self->{'null'} || '';
Condition50%1/2
$self->{'null'} || ''
l!l
030
MC/DC0%0/1
$self->{'null'} || ''
$self->{'null'}
Truth table50%1/2
A
A= $self->{'null'}
Aresult
11
00
50 30 my $columns = $self->{'columns'};
51  
52 30 my $breaks = $self->{'breaks'};
53  
54 map {
55 30 ▶ if (!defined($_)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $_) { } 0 150 150
56 0 $_ = $null;
57 } else {
58 150 $_ =~ s/\n/\\n/g;
59 150 $_ =~ s/\t/\\t/g;
60 150 $_ =~ s/\r/\\r/g;
61 150 $_ =~ s/[\000-\037\177-\237]/./g;
62 }
63 150 ++$i;
64 } @row;
65  
66 30 my $fh = $self->{'fh'};
67 30 my $csv = $self->{csv_obj};
68 30 my $status = $csv->print($fh, \@row);
69 30 $fh->print( "\n" );
70  
71 30 return ++$self->{rows};
72 }
73  
74  
75 sub trailer {
76 3 ▶ my $self = shift;
Subroutine trailer: called CC=1 SCAR=0.0
Pod undocumented
77 # $self->SUPER::trailer(@_);
78 }
79  
80 1 1;
81  
82 =head1 NAME
83  
84 DBI::Format::CSV - A package for displaying result tables
85  
86 =head1 SYNOPSIS
87  
88 =head1 DESCRIPTION
89  
90 THIS PACKAGE IS STILL VERY EXPERIMENTAL. THINGS WILL CHANGE.
91  
92 =head1 AUTHOR AND COPYRIGHT
93  
94 Orignal Format module is Copyright (c) 1997, 1998
95  
96 Jochen Wiedmann
97 Am Eisteich 9
98 72555 Metzingen
99 Germany
100  
101 Email: joe@ispsoft.de
102 Phone: +49 7123 14887
103  
104 SQLMinus is Copyright (c) 2001, 2002 Thomas A. Lowery
105  
106 The DBI::Format::CSV module is free software; you can redistribute it and/or
107 modify it under the same terms as Perl itself.
108  
109  
110 =head1 SEE ALSO
111  
112 L<DBI::Shell>, L<DBI>, L<dbish>
« blib/lib/DBI/Shell/Timing.pm ↑ Summary dbish_config »