line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::VerticalTable; |
2
|
2
|
|
|
2
|
|
130515
|
use strict; |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
55
|
|
3
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
49
|
|
4
|
2
|
|
|
2
|
|
1102
|
use utf8; |
|
2
|
|
|
|
|
25
|
|
|
2
|
|
|
|
|
9
|
|
5
|
2
|
|
|
2
|
|
55
|
use Carp qw/croak/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
86
|
|
6
|
2
|
|
|
2
|
|
2002
|
use overload '""' => '_drawit'; |
|
2
|
|
|
|
|
1655
|
|
|
2
|
|
|
|
|
9
|
|
7
|
2
|
|
|
2
|
|
149
|
use List::Util qw/max/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
941
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
1
|
|
|
1
|
1
|
69
|
my $class = shift; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
|
|
5
|
bless { |
15
|
|
|
|
|
|
|
_tbl => [], |
16
|
|
|
|
|
|
|
}, $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub setHead { |
20
|
2
|
|
|
2
|
1
|
494
|
my ($self, $title) = @_; |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
|
|
3
|
push @{$self->{_tbl}}, { head => $title, lines => [] }; |
|
2
|
|
|
|
|
24
|
|
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
|
|
5
|
$self; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub addRow { |
28
|
6
|
|
|
6
|
1
|
18
|
my $self = shift; |
29
|
|
|
|
|
|
|
|
30
|
6
|
50
|
|
|
|
6
|
if (ref ${$self->{_tbl}}[-1] ne 'HASH') { |
|
6
|
|
|
|
|
14
|
|
31
|
0
|
|
|
|
|
0
|
croak "setHead first"; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
6
|
50
|
33
|
|
|
18
|
my ($key, $value) = scalar(@_) == 1 && ref($_[0]) eq 'ARRAY' ? @{$_[0]} : @_; |
|
0
|
|
|
|
|
0
|
|
35
|
|
|
|
|
|
|
|
36
|
6
|
|
|
|
|
7
|
push @{${$self->{_tbl}}[-1]{lines}}, [$key, $value]; |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
15
|
|
37
|
|
|
|
|
|
|
|
38
|
6
|
|
|
|
|
8
|
$self; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
1
|
|
5
|
sub _drawit {scalar shift()->draw()} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub draw { |
44
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
2
|
my @lines; |
47
|
1
|
|
|
|
|
10
|
my $count = 1; |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
2
|
for my $tbl (@{$self->{_tbl}}) { |
|
1
|
|
|
|
|
4
|
|
50
|
2
|
|
50
|
|
|
11
|
push @lines, sprintf("%s %s. %s %s", '*'x10, $count, $tbl->{head} || 'row', '*'x10); |
51
|
2
|
|
|
|
|
3
|
my $max_key_length = max(map { length $_->[0] } @{$tbl->{lines}}); |
|
6
|
|
|
|
|
22
|
|
|
2
|
|
|
|
|
5
|
|
52
|
2
|
|
|
|
|
4
|
for my $line (@{$tbl->{lines}}) { |
|
2
|
|
|
|
|
4
|
|
53
|
6
|
|
|
|
|
9
|
my ($key, $value) = @{$line}; |
|
6
|
|
|
|
|
7
|
|
54
|
6
|
|
|
|
|
19
|
push @lines, sprintf( |
55
|
|
|
|
|
|
|
"%s: %s", |
56
|
|
|
|
|
|
|
sprintf("%${max_key_length}s", $key), $value |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
} |
59
|
2
|
|
|
|
|
3
|
$count++; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
6
|
join("\n", @lines) . "\n"; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |