line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Toader::Render::Directory::backends::pod; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
24096
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
5
|
1
|
|
|
1
|
|
5
|
use base 'Error::Helper'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
952
|
|
6
|
1
|
|
|
1
|
|
2131
|
use Pod::Simple::HTML; |
|
1
|
|
|
|
|
55077
|
|
|
1
|
|
|
|
|
49
|
|
7
|
1
|
|
|
1
|
|
1488
|
use File::Temp; |
|
1
|
|
|
|
|
21962
|
|
|
1
|
|
|
|
|
85
|
|
8
|
1
|
|
|
1
|
|
12
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
683
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Toader::Render::Directory::backends::pod - This handles the POD backend stuff for Toader::Render::Directory. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 0.1.0 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.1.0'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Toader::Render::Directory::backends::pod; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $renderer=Toader::Render::Directory::backends::pod->new({ toader=>$toader, obj=>$dirObj }); |
27
|
|
|
|
|
|
|
my $rendered; |
28
|
|
|
|
|
|
|
if ( $renderer->error ){ |
29
|
|
|
|
|
|
|
warn( 'Error:'.$renderer->error.': '.$renderer->errorString ); |
30
|
|
|
|
|
|
|
}else{ |
31
|
|
|
|
|
|
|
$rendered=$renderer->render($torender); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 METHODS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 new |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
This initiates the object. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head3 args hash ref |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head4 obj |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
This is the L object to render. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head4 toader |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
This is the L object to use. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $foo=Toader::Render::Directory::backends::pod->new(\%args); |
51
|
|
|
|
|
|
|
if($foo->error){ |
52
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub new{ |
58
|
0
|
|
|
0
|
1
|
|
my %args; |
59
|
0
|
0
|
|
|
|
|
if(defined($_[1])){ |
60
|
0
|
|
|
|
|
|
%args= %{$_[1]}; |
|
0
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my $self={ |
64
|
|
|
|
|
|
|
error=>undef, |
65
|
|
|
|
|
|
|
errorString=>'', |
66
|
|
|
|
|
|
|
perror=>undef, |
67
|
|
|
|
|
|
|
errorExtra=>{ |
68
|
|
|
|
|
|
|
flags=>{ |
69
|
|
|
|
|
|
|
1=>'noObj', |
70
|
|
|
|
|
|
|
2=>'noToaderObj', |
71
|
|
|
|
|
|
|
3=>'notAdirectoryObj', |
72
|
|
|
|
|
|
|
4=>'toaderPerror', |
73
|
|
|
|
|
|
|
5=>'noDirSet', |
74
|
|
|
|
|
|
|
6=>'nothingSpecifiedToRender', |
75
|
|
|
|
|
|
|
7=>'tempOpenFailed', |
76
|
|
|
|
|
|
|
8=>'tempUnlinkFailed', |
77
|
|
|
|
|
|
|
9=>'htmlRenderFailed', |
78
|
|
|
|
|
|
|
}, |
79
|
|
|
|
|
|
|
}, |
80
|
|
|
|
|
|
|
}; |
81
|
0
|
|
|
|
|
|
bless $self; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
#make sure we have a Toader::Directory object. |
84
|
0
|
0
|
|
|
|
|
if ( ! defined( $args{obj} ) ){ |
85
|
0
|
|
|
|
|
|
$self->{perror}=1; |
86
|
0
|
|
|
|
|
|
$self->{error}=1; |
87
|
0
|
|
|
|
|
|
$self->{errorString}='Nothing defined for the Toader::Directory object'; |
88
|
0
|
|
|
|
|
|
$self->warn; |
89
|
0
|
|
|
|
|
|
return $self; |
90
|
|
|
|
|
|
|
} |
91
|
0
|
0
|
|
|
|
|
if ( ref( $args{obj} ) ne 'Toader::Directory' ){ |
92
|
0
|
|
|
|
|
|
$self->{perror}=1; |
93
|
0
|
|
|
|
|
|
$self->{error}=1; |
94
|
0
|
|
|
|
|
|
$self->{errorString}='The specified object is not a Toader::Entry object, but a "'. |
95
|
|
|
|
|
|
|
ref( $args{obj} ).'"'; |
96
|
0
|
|
|
|
|
|
$self->warn; |
97
|
0
|
|
|
|
|
|
return $self; |
98
|
|
|
|
|
|
|
} |
99
|
0
|
|
|
|
|
|
$self->{obj}=$args{obj}; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
#make sure the object does not have a permanent error set |
102
|
0
|
0
|
|
|
|
|
if( ! $self->{obj}->errorblank ){ |
103
|
0
|
|
|
|
|
|
$self->{perror}=1; |
104
|
0
|
|
|
|
|
|
$self->{error}=3; |
105
|
0
|
|
|
|
|
|
$self->{errorString}='The Toader::Directory object has a permanent error set'; |
106
|
0
|
|
|
|
|
|
$self->warn; |
107
|
0
|
|
|
|
|
|
return $self; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
#make sure a Toader object is given |
111
|
0
|
0
|
|
|
|
|
if ( ! defined( $args{toader} ) ){ |
112
|
0
|
|
|
|
|
|
$self->{perror}=1; |
113
|
0
|
|
|
|
|
|
$self->{error}=2; |
114
|
0
|
|
|
|
|
|
$self->{errorString}='Nothing defined for the Toader object'; |
115
|
0
|
|
|
|
|
|
$self->warn; |
116
|
0
|
|
|
|
|
|
return $self; |
117
|
|
|
|
|
|
|
} |
118
|
0
|
0
|
|
|
|
|
if ( ref( $args{toader} ) ne 'Toader' ){ |
119
|
0
|
|
|
|
|
|
$self->{perror}=1; |
120
|
0
|
|
|
|
|
|
$self->{error}=2; |
121
|
0
|
|
|
|
|
|
$self->{errorString}='The specified object is not a Toader object, but a "'. |
122
|
|
|
|
|
|
|
ref( $args{toader} ).'"'; |
123
|
0
|
|
|
|
|
|
$self->warn; |
124
|
0
|
|
|
|
|
|
return $self; |
125
|
|
|
|
|
|
|
} |
126
|
0
|
|
|
|
|
|
$self->{toader}=$args{toader}; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
#make sure the Toader object does not have a permanent error set |
129
|
0
|
0
|
|
|
|
|
if( ! $self->{toader}->errorblank ){ |
130
|
0
|
|
|
|
|
|
$self->{perror}=1; |
131
|
0
|
|
|
|
|
|
$self->{error}=4; |
132
|
0
|
|
|
|
|
|
$self->{errorString}='The Toader object has an permanent error set'; |
133
|
0
|
|
|
|
|
|
$self->warn; |
134
|
0
|
|
|
|
|
|
return $self; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
#make sure a directory is set |
138
|
0
|
0
|
|
|
|
|
if( ! defined( $self->{obj}->dirGet ) ){ |
139
|
0
|
|
|
|
|
|
$self->{perror}=1; |
140
|
0
|
|
|
|
|
|
$self->{error}=5; |
141
|
0
|
|
|
|
|
|
$self->{errorString}='The Toader::Directory object does not have a directory set'; |
142
|
0
|
|
|
|
|
|
$self->warn; |
143
|
0
|
|
|
|
|
|
return $self; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
return $self; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 render |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This renders the object. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
One argument is taken and that is what is to be rendered. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub render{ |
158
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
159
|
0
|
|
|
|
|
|
my $torender=$_[1]; |
160
|
|
|
|
|
|
|
|
161
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
162
|
0
|
|
|
|
|
|
return undef; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
0
|
0
|
|
|
|
|
if ( !defined( $torender ) ){ |
166
|
0
|
|
|
|
|
|
$self->{error}=6; |
167
|
0
|
|
|
|
|
|
$self->{errorString}='Nothing to render specified'; |
168
|
0
|
|
|
|
|
|
$self->warn; |
169
|
0
|
|
|
|
|
|
return undef; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
#create a tmp file |
173
|
0
|
|
|
|
|
|
my $tmpfile = File::Temp::tempnam( File::Spec->tmpdir, 'tdat' ); |
174
|
0
|
|
|
|
|
|
my $fh; |
175
|
0
|
0
|
|
|
|
|
if ( ! open( $fh, '>', $tmpfile ) ){ |
176
|
0
|
|
|
|
|
|
$self->{error}=7; |
177
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to open a temp file, "'.$tmpfile.'",'; |
178
|
0
|
|
|
|
|
|
$self->warn; |
179
|
0
|
|
|
|
|
|
return undef; |
180
|
|
|
|
|
|
|
} |
181
|
0
|
|
|
|
|
|
print $fh $torender; |
182
|
0
|
|
|
|
|
|
close( $fh ); |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
#print `ls $tmpfile; cat $tmpfile`; |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
#renders it |
187
|
0
|
|
|
|
|
|
my $p = Pod::Simple::HTML->new; |
188
|
0
|
|
|
|
|
|
my $html; |
189
|
0
|
|
|
|
|
|
$p->index(1); |
190
|
0
|
|
|
|
|
|
$p->output_string(\$html); |
191
|
0
|
|
|
|
|
|
$p->parse_file( $tmpfile ); |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
#unlinks the file |
194
|
0
|
0
|
|
|
|
|
if (! unlink( $tmpfile ) ){ |
195
|
0
|
|
|
|
|
|
$self->{error}=8; |
196
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to unlink "'.$tmpfile.'"'; |
197
|
0
|
|
|
|
|
|
$self->warn; |
198
|
0
|
|
|
|
|
|
return undef; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
#makes sure something is returned for html |
202
|
0
|
0
|
|
|
|
|
if (! defined( $html ) ){ |
203
|
0
|
|
|
|
|
|
$self->{error}=9; |
204
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to render the html'; |
205
|
0
|
|
|
|
|
|
$self->warn; |
206
|
0
|
|
|
|
|
|
return undef; |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
|
return $html; |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 ERROR CODES |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head2 1, noObj |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
No L object specified. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head2 2, noToaderObj |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
No L object specified. |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head2 3, notAdirectoryObj |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
The L object has a permanent error set. |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head2 4, toaderPerror |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
The L object has a permanent error set. |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=head2 5, noDirSet |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
The L object does not have a directory set. |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head2 6, nothingSpecifiedToRender |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
Nothing specified to render. |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head2 7, tempOpenFailed |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Failed to open a temp file. |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head2 8, tempUnlinkFailed |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
Failed to unlink the the temporary file. |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head2 9, htmlRenderFailed |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
Failed to render the HTML. |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head1 AUTHOR |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
Zane C. Bowers-Hadley, C<< >> |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=head1 BUGS |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
257
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
258
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=head1 SUPPORT |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
perldoc Toader::Render::Directory::backends::pod |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
You can also look for information at: |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=over 4 |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
L |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
L |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=item * CPAN Ratings |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
L |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=item * Search CPAN |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
L |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=back |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
Copyright 2013. Zane C. Bowers-Hadley. |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
298
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
299
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=cut |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
1; # End of Toader::Render::Directory::backends::pod |