line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Report::Generator::Render::TT2; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
40
|
|
5
|
1
|
|
|
1
|
|
6
|
use vars qw(@ISA $VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
56
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
1149
|
use File::ShareDir (); |
|
1
|
|
|
|
|
14317
|
|
|
1
|
|
|
|
|
35
|
|
8
|
1
|
|
|
1
|
|
15
|
use File::Spec (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
9
|
1
|
|
|
1
|
|
6
|
use Params::Util qw(_ARRAY0); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
498
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require Report::Generator::Render; |
12
|
|
|
|
|
|
|
require Template; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Report::Generator::Render::TT2 - class for rendering reports using TT2 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$VERSION = '0.002'; |
21
|
|
|
|
|
|
|
@ISA = qw(Report::Generator::Render); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my %cfg = ( |
26
|
|
|
|
|
|
|
renderer => 'Report::Generator::Render::TT2', |
27
|
|
|
|
|
|
|
'Report::Generator::Render::TT2' => { |
28
|
|
|
|
|
|
|
config => { ABSOLUTE => 1, }, |
29
|
|
|
|
|
|
|
output => 'test1.ext', |
30
|
|
|
|
|
|
|
vars => { }, |
31
|
|
|
|
|
|
|
template => 'test1.tt2', |
32
|
|
|
|
|
|
|
options => {}, |
33
|
|
|
|
|
|
|
}, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
Report::Generator->new({cfg => \%cfg})->generate(); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 DESCRIPTION |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
C provides a base class for rendering |
40
|
|
|
|
|
|
|
reports in L using Template::Toolkit. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
See the C examples in the examples directory of this |
43
|
|
|
|
|
|
|
distribution to get a sense who to use this renderer. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 new |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Instantiates a new TT2 renderer for C. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Report::Generator::Render::TT2->new( |
52
|
|
|
|
|
|
|
{ |
53
|
|
|
|
|
|
|
config => { ... }, |
54
|
|
|
|
|
|
|
vars => { ... }, |
55
|
|
|
|
|
|
|
options => { ... }, |
56
|
|
|
|
|
|
|
template => 'path/to/template', |
57
|
|
|
|
|
|
|
output => 'path/to/output', |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
The parameters C, and are optional, C |
62
|
|
|
|
|
|
|
and C |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
If the C parameter hash contains a flag C with |
65
|
|
|
|
|
|
|
a true value, the next paragraph can be skipped. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
When the C parameter hash doesn't contain a value for C, |
68
|
|
|
|
|
|
|
it's set to C<;> (semicolon) for the I environment or to C<:> |
69
|
|
|
|
|
|
|
(colon) otherwise. The value for C is appended by the |
70
|
|
|
|
|
|
|
Id directory for this distribution. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub new |
75
|
|
|
|
|
|
|
{ |
76
|
1
|
|
|
1
|
1
|
4
|
my ( $proto, $attr ) = @_; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# XXX some checks might be required here ... |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
13
|
my $self = $proto->SUPER::new($attr); |
81
|
1
|
|
50
|
|
|
13
|
my $config = $self->{config} ||= {}; |
82
|
1
|
|
|
|
|
3
|
my $fixed_inc = delete $config->{FIXED_INCLUDE_PATH}; |
83
|
|
|
|
|
|
|
|
84
|
1
|
50
|
|
|
|
4
|
unless ($fixed_inc) |
85
|
|
|
|
|
|
|
{ |
86
|
1
|
50
|
33
|
|
|
15
|
$config->{DELIMITER} ||= $^O eq 'MSWin32' ? ';' : ':'; |
87
|
1
|
50
|
33
|
|
|
10
|
if ( $config->{INCLUDE_PATH} && '' eq ref( $config->{INCLUDE_PATH} ) ) |
88
|
|
|
|
|
|
|
{ |
89
|
0
|
|
|
|
|
0
|
$config->{INCLUDE_PATH} = [ split( $config->{DELIMITER}, $config->{INCLUDE_PATH} ) ]; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
push( |
92
|
1
|
|
|
|
|
2
|
@{ $config->{INCLUDE_PATH} }, |
|
1
|
|
|
|
|
10
|
|
93
|
|
|
|
|
|
|
File::Spec->catdir( File::ShareDir::dist_dir('Report-Generator') ) |
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
1
|
50
|
|
|
|
154
|
$self->{template} or croak("The template parameter is required"); |
98
|
1
|
50
|
|
|
|
5
|
$self->{output} or croak("The output parameter is required"); |
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
|
|
5
|
return $self; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 render |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Renders the given C into specified C |
106
|
|
|
|
|
|
|
knobs. Returns a true value on success or sets C<< $self->{error} >> |
107
|
|
|
|
|
|
|
otherwise. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub render |
112
|
|
|
|
|
|
|
{ |
113
|
1
|
|
|
1
|
1
|
3
|
my $self = $_[0]; |
114
|
|
|
|
|
|
|
|
115
|
1
|
|
|
|
|
15
|
my $template = Template->new( $self->{config} ); |
116
|
1
|
50
|
|
|
|
14
|
my $rc = $template->process( $self->{template}, $self->{vars} || {}, |
117
|
1
|
|
50
|
|
|
506827
|
$self->{output}, %{ $self->{options} || {} } ); |
118
|
1
|
50
|
|
|
|
211
|
$rc or $self->{error} = $template->error(); |
119
|
|
|
|
|
|
|
|
120
|
1
|
|
|
|
|
27
|
return $rc; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 AUTHOR |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Jens Rehsack, C<< >> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 BUGS |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
130
|
|
|
|
|
|
|
C, or through the web interface at |
131
|
|
|
|
|
|
|
L. I |
132
|
|
|
|
|
|
|
will be notified, and then you'll automatically be notified of progress |
133
|
|
|
|
|
|
|
on your bug as I make changes. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 SUPPORT |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
perldoc Report::Generator::Render |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
You can also look for information at: |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=over 4 |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
L |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
L |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item * CPAN Ratings |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
L |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item * Search CPAN |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
L |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=back |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Copyright 2010 Jens Rehsack. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
171
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
172
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
1; |