line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (C) 2003-2007, G. Allen Morris III, all rights reserved |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
178
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Data::Tabular::Output::TXT; |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
16
|
use base qw(Data::Tabular::Output); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
2424
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
20
|
use Carp qw (croak); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
163
|
|
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
16
|
use overload '""' => \&_render; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
17
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new |
14
|
|
|
|
|
|
|
{ |
15
|
3
|
|
|
3
|
1
|
7
|
my $class = shift; |
16
|
3
|
|
|
|
|
8
|
my $args = { @_ }; |
17
|
|
|
|
|
|
|
|
18
|
3
|
|
|
|
|
10
|
my $self = bless {}, $class; |
19
|
|
|
|
|
|
|
|
20
|
3
|
50
|
|
|
|
12
|
die 'No table' unless $args->{table}; |
21
|
3
|
|
|
|
|
215
|
$self->{table} = $args->{table}; |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
33
|
|
|
15
|
$self->{output} = $args->{output} || croak "Need output"; |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
|
|
17
|
$self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _render |
29
|
|
|
|
|
|
|
{ |
30
|
3
|
|
|
3
|
|
6
|
my $self = shift; |
31
|
3
|
|
|
|
|
9
|
$self->text; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub text |
35
|
|
|
|
|
|
|
{ |
36
|
3
|
|
|
3
|
1
|
6
|
my $self = shift; |
37
|
3
|
|
|
|
|
4
|
my $ret = "\n"; |
38
|
|
|
|
|
|
|
|
39
|
3
|
|
|
|
|
22
|
my $output = $self->output; |
40
|
|
|
|
|
|
|
|
41
|
3
|
|
|
|
|
5
|
my @table; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my @col_length; |
44
|
|
|
|
|
|
|
|
45
|
3
|
|
|
|
|
12
|
for my $row ($self->rows(output => $self->output)) { |
46
|
48
|
|
|
|
|
204
|
for my $cell ($row->cells($output->headers)) { |
47
|
260
|
|
|
|
|
686
|
my $cell_data = $cell->data; |
48
|
|
|
|
|
|
|
|
49
|
260
|
|
|
|
|
412
|
my $width = 20; # $cell->width; |
50
|
260
|
|
|
|
|
978
|
$cell_data =~ s/^\s*(.*)\s*$/$1/; |
51
|
260
|
100
|
100
|
|
|
1485
|
if ((my $length = length($cell_data)) >= ($col_length[$cell->col_id] || 0)) { |
52
|
124
|
|
|
|
|
319
|
$col_length[$cell->col_id] = $length; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
3
|
|
|
|
|
67
|
my $right = 0; |
58
|
3
|
|
|
|
|
24
|
for my $row ($self->rows(output => $self->output)) { |
59
|
48
|
|
|
|
|
190
|
for my $cell ($row->cells()) { |
60
|
260
|
100
|
|
|
|
693
|
push(@table, " ") if $cell->col_id; |
61
|
260
|
|
|
|
|
708
|
my $cell_data = $cell->html_string; |
62
|
260
|
|
|
|
|
1032
|
my $width = $col_length[$cell->col_id]; |
63
|
260
|
|
|
|
|
655
|
$cell_data =~ s/^\s*(.*)\s*$/$1/; |
64
|
260
|
|
|
|
|
866
|
my $length = $width - length($cell_data); |
65
|
260
|
50
|
|
|
|
794
|
if ($right) { |
66
|
0
|
|
|
|
|
0
|
push(@table, " " x $length); |
67
|
|
|
|
|
|
|
} |
68
|
260
|
|
|
|
|
494
|
push(@table, $cell_data); |
69
|
260
|
50
|
|
|
|
604
|
if (!$right) { |
70
|
260
|
|
|
|
|
1131
|
push(@table, " " x $length); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
48
|
|
|
|
|
269
|
push(@table, "\n"); |
74
|
|
|
|
|
|
|
} |
75
|
3
|
|
|
|
|
122
|
$ret .= join('', @table); |
76
|
|
|
|
|
|
|
|
77
|
3
|
|
|
|
|
1138
|
$ret; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
__END__ |