| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::RecordStream::Operation::tohtml; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = "4.0.24"; |
|
4
|
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
735
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
45
|
|
|
6
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
45
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
8
|
use base qw(App::RecordStream::Operation); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
1073
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub init { |
|
11
|
5
|
|
|
5
|
0
|
8
|
my $this = shift; |
|
12
|
5
|
|
|
|
|
7
|
my $args = shift; |
|
13
|
|
|
|
|
|
|
|
|
14
|
5
|
|
|
|
|
7
|
my $no_header; |
|
15
|
5
|
|
|
|
|
8
|
my $row_attributes = ''; |
|
16
|
5
|
|
|
|
|
8
|
my $cell_attributes = ''; |
|
17
|
|
|
|
|
|
|
|
|
18
|
5
|
|
|
|
|
23
|
my $key_groups = App::RecordStream::KeyGroups->new(); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $spec = { |
|
21
|
2
|
|
|
2
|
|
1413
|
'keys|k|fields|f=s' => sub { $key_groups->add_groups($_[1]); }, |
|
22
|
5
|
|
|
|
|
28
|
'noheader' => \$no_header, |
|
23
|
|
|
|
|
|
|
'rowattributes=s' => \$row_attributes, |
|
24
|
|
|
|
|
|
|
'cellattributes=s' => \$cell_attributes, |
|
25
|
|
|
|
|
|
|
}; |
|
26
|
|
|
|
|
|
|
|
|
27
|
5
|
|
|
|
|
19
|
$this->parse_options($args, $spec); |
|
28
|
|
|
|
|
|
|
|
|
29
|
5
|
|
|
|
|
10
|
$this->{'KEY_GROUPS'} = $key_groups; |
|
30
|
5
|
|
|
|
|
10
|
$this->{'NO_HEADER'} = $no_header; |
|
31
|
5
|
|
|
|
|
8
|
$this->{'ROW_ATTRIBUTES'} = $row_attributes; |
|
32
|
5
|
|
|
|
|
42
|
$this->{'CELL_ATTRIBUTES'} = $cell_attributes; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub accept_record { |
|
36
|
25
|
|
|
25
|
0
|
36
|
my $this = shift; |
|
37
|
25
|
|
|
|
|
31
|
my $record = shift; |
|
38
|
|
|
|
|
|
|
|
|
39
|
25
|
|
|
|
|
53
|
$this->print_start($record); |
|
40
|
|
|
|
|
|
|
|
|
41
|
25
|
|
|
|
|
34
|
my $fields = $this->{'FIELDS'}; |
|
42
|
25
|
|
|
|
|
36
|
my $row_attributes = $this->{'ROW_ATTRIBUTES'}; |
|
43
|
25
|
|
|
|
|
32
|
my $cell_attributes = $this->{'CELL_ATTRIBUTES'}; |
|
44
|
|
|
|
|
|
|
|
|
45
|
25
|
|
|
|
|
69
|
$this->push_line(" |
");
|
46
|
|
|
|
|
|
|
|
|
47
|
25
|
|
|
|
|
42
|
foreach my $field (@$fields) { |
|
48
|
45
|
|
50
|
|
|
60
|
my $value = ${$record->guess_key_from_spec($field)} || ''; |
|
49
|
45
|
|
|
|
|
140
|
$this->push_line(" | $value | ");
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
25
|
|
|
|
|
57
|
$this->push_line(" |
");
|
53
|
|
|
|
|
|
|
|
|
54
|
25
|
|
|
|
|
95
|
return 1; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub print_start { |
|
58
|
25
|
|
|
25
|
0
|
30
|
my $this = shift; |
|
59
|
25
|
|
|
|
|
32
|
my $record = shift; |
|
60
|
|
|
|
|
|
|
|
|
61
|
25
|
100
|
|
|
|
49
|
return if ( $this->{'PRINTED_START'} ); |
|
62
|
5
|
|
|
|
|
13
|
$this->{'PRINTED_START'} = 1; |
|
63
|
|
|
|
|
|
|
|
|
64
|
5
|
|
|
|
|
16
|
$this->push_line("");
|
65
|
|
|
|
|
|
|
|
|
66
|
5
|
|
|
|
|
7
|
my $groups = $this->{'KEY_GROUPS'}; |
|
67
|
5
|
100
|
|
|
|
16
|
if ( $groups->has_any_group() ) { |
|
68
|
2
|
|
|
|
|
6
|
my $specs = $this->{'KEY_GROUPS'}->get_keyspecs($record); |
|
69
|
2
|
|
|
|
|
14
|
$this->{'FIELDS'} = $specs; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
else { |
|
72
|
3
|
|
|
|
|
14
|
$this->{'FIELDS'} = [sort keys %$record]; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
5
|
100
|
|
|
|
15
|
return if ( $this->{'NO_HEADER'} ); |
|
76
|
|
|
|
|
|
|
|
|
77
|
4
|
|
|
|
|
15
|
$this->print_header(); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub print_header { |
|
81
|
4
|
|
|
4
|
0
|
38
|
my $this = shift; |
|
82
|
|
|
|
|
|
|
|
|
83
|
4
|
|
|
|
|
23
|
my $fields = $this->{'FIELDS'}; |
|
84
|
|
|
|
|
|
|
|
|
85
|
4
|
|
|
|
|
20
|
my $row_attributes = $this->{'ROW_ATTRIBUTES'}; |
|
86
|
4
|
|
|
|
|
6
|
my $cell_attributes = $this->{'CELL_ATTRIBUTES'}; |
|
87
|
|
|
|
|
|
|
|
|
88
|
4
|
|
|
|
|
15
|
$this->push_line(" | ");
|
89
|
|
|
|
|
|
|
|
|
90
|
4
|
|
|
|
|
8
|
foreach my $field (@$fields) { |
|
91
|
7
|
|
|
|
|
18
|
$this->push_line(" | $field | ");
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
4
|
|
|
|
|
8
|
$this->push_line(" | ");
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub stream_done { |
|
98
|
5
|
|
|
5
|
0
|
8
|
my $this = shift; |
|
99
|
5
|
|
|
|
|
10
|
$this->push_line(" | "); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub add_help_types { |
|
103
|
5
|
|
|
5
|
0
|
9
|
my $this = shift; |
|
104
|
5
|
|
|
|
|
18
|
$this->use_help_type('keyspecs'); |
|
105
|
5
|
|
|
|
|
13
|
$this->use_help_type('keygroups'); |
|
106
|
5
|
|
|
|
|
11
|
$this->use_help_type('keys'); |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub usage { |
|
110
|
0
|
|
|
0
|
0
|
|
my $this = shift; |
|
111
|
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
my $options = [ |
|
113
|
|
|
|
|
|
|
['keys ', 'Keys to print in the table. May be specified multiple times, may be comma separated. Default to all fields in the first record. May be a keyspec or a keygroup, see \'--help-keys\' for more information'], |
|
114
|
|
|
|
|
|
|
['noheader', 'Do not print the header row'], |
|
115
|
|
|
|
|
|
|
['rowattributes', 'HTML attributes to put on the tr tags'], |
|
116
|
|
|
|
|
|
|
['cellattributes', 'HTML attributes to put on the td and th tag'], |
|
117
|
|
|
|
|
|
|
]; |
|
118
|
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
my $args_string = $this->options_string($options); |
|
120
|
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
return <
|
|
122
|
|
|
|
|
|
|
Usage: recs-totable [] |
|
123
|
|
|
|
|
|
|
__FORMAT_TEXT__ |
|
124
|
|
|
|
|
|
|
Prints out an html table for the records from input or from . |
|
125
|
|
|
|
|
|
|
__FORMAT_TEXT__ |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
$args_string |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Examples: |
|
130
|
|
|
|
|
|
|
Print all fields |
|
131
|
|
|
|
|
|
|
recs-tohhtml |
|
132
|
|
|
|
|
|
|
Print foo and bar fields, without a header |
|
133
|
|
|
|
|
|
|
recs-tohtml --fields foo,bar --noheader |
|
134
|
|
|
|
|
|
|
USAGE |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |