Toader/Page.pm

filter: Statementstmt 5.0% 26 / 517 Branchbran 0.0% 0 / 202 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 21.6% 8 / 37 Podpod 100% 29 / 29 totaltotal 7.7% 63 / 810 CC 107 SCAR 49.2
CC
107
Cov
4%
new
552.0
newFromString
210.0
write
132.0
CRAP 136.9
« Toader/Render/General.pm ↑ Summary Toader/Entry.pm »
1 package Toader::Page;
2  
3 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use Email::MIME;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use File::MimeInfo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use Toader::isaToaderDir;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use File::Path qw(make_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use base 'Error::Helper';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 ▶use Toader::pathHelper;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 =head1 NAME
13  
14 Toader::Page - This provides methods for a named page.
15  
16 =head1 VERSION
17  
18 Version 1.0.0
19  
20 =cut
21  
22 6 our $VERSION = '1.0.0';
23  
24 =head1 SYNOPSIS
25  
26 For information on the storage and rendering of entries,
27 please see 'Documentation/Page.pod'.
28  
29 =head1 NEW METHODS
30  
31 If any of the new methods error, the error is permanent.
32  
33 =head2 new
34  
35 This creates the a object that represents a page.
36  
37 Two arguments are taken. The first is a hash reference that
38 is documented below.
39  
40 =head3 args hash
41  
42 =head4 renderer
43  
44 This is the rendering engine the body should use.
45  
46 If not defined, html will be used.
47  
48 =head4 body
49  
50 This is the body.
51  
52 =head4 name
53  
54 This is the short name of the page.
55  
56 =head4 from
57  
58 This is the from address to use.
59  
60 =head4 files
61  
62 This is a list of files that will be made available with this page.
63  
64 =head4 publish
65  
66 Wether or not to publish it or not. This is a boolean value and uses "0"
67 and "1".
68  
69 If not specified, it uses "1".
70  
71 =head4 toader
72  
73 This is a L<Toader> object.
74  
75 my $foo = Toader::isaToaderDir->new(\%args);
76 if ($foo->error){
77 warn('Error:'.$foo->error.': '.$foo->errorString);
78 }
79  
80 =cut
81  
82 0 ▶sub new{
Subroutine new: not called CC=23 SCAR=63.1
Pod documented
83 0 my %args;
84 0 ▶ if(defined($_[1])){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[1]) 0 0 0
85 0 %args= %{$_[1]};
86 };
87  
88 0 my $self={
89 error=>undef,
90 errorString=>'',
91 perror=>undef,
92 dir=>undef,
93 errorExtra=>{
94 flags=>{
95 1=>'noPageName',
96 2=>'emailMIMEcreationFailed',
97 3=>'notAnArray',
98 4=>'fileDoesNotExist',
99 5=>'MIMEinfoError',
100 6=>'unableToOpenFile',
101 7=>'emailMIMEerror',
102 8=>'noBody',
103 9=>'notAtoaderDir',
104 10=>'noLongAtoaderDir',
105 11=>'nodirSet',
106 12=>'pagesDirCreationFailed',
107 13=>'publishValError',
108 14=>'notAtoaderObj',
109 15=>'getVCSerrored',
110 16=>'VCSusableErrored',
111 17=>'underVCSerror',
112 18=>'VCSaddError',
113 19=>'noToaderObj',
114 },
115 },
116 VCSusable=>0,
117 };
118 0 bless $self;
119  
120 0 ▶ if (!defined($args{renderer})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"renderer"}) 0 0 0
121 0 $args{renderer}='html';
122 }
123  
124 0 ▶ if (!defined($args{summary})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"summary"}) 0 0 0
125 0 $args{summary}='';
126 }
127  
128 0 ▶ if (!defined($args{name})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"name"}) 0 0 0
129 0 $self->{error}=1;
130 0 $self->{perror}=1;
131 0 $self->{errorString}='No name specified';
132 0 $self->warn;
133 0 return $self;
134 }
135  
136 0 ▶ if (!defined($args{from})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"from"}) 0 0 0
137 0 $args{from}='';
138 }
139  
140 0 ▶ if (!defined($args{body})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"body"}) 0 0 0
141 0 $args{body}='';
142 }
143  
144 0 ▶ if (!defined($args{publish})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"publish"}) 0 0 0
145 0 $args{publish}='1';
146 }
147  
148 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"publish"} ne 0 and $args{"publish"} ne 1) 0 0 0
Condition0%0/3
$args{"publish"} ne 0 and $args{"publish"} ne 1
!ll&&!rl&&r
000
MC/DC0%0/2
$args{"publish"} ne 0 and $args{"publish"} ne 1
$args{"publish"} ne 0 $args{"publish"} ne 1
Truth table0%0/3
A and B
A= $args{"publish"} ne 0B= $args{"publish"} ne 1
ABresult
0X0
100
111
149 ( $args{publish} ne "0" ) &&
150 ( $args{publish} ne "1" )
151 ){
152 0 $self->{error}=13;
153 0 $self->{perror}=1;
154 0 $self->{errorString}='"'.$args{publish}.'" not a published boolean';
155 0 $self->warn;
156 0 return $self;
157 }
158  
159 #this will hold the various parts
160 0 my @parts;
161 0 my $int=0;
162 0 ▶ if (defined($args{files})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"files"}) 0 0 0
163 0 ▶ if ( ref( $args{files} ne "ARRAY" ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($args{"files"} ne "ARRAY")) 0 0 0
164 0 $self->{perror}=1;
165 0 $self->{error}=3;
166 0 $self->{errorString}="Has files specified, but the passed object is not a array";
167 0 $self->warn;
168 0 return $self;
169 }
170  
171 #puts all the parts together
172 0 ▶ while (defined( $args{files}[$int] )) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"files"}[$int]) 0 0 0
173 0 ▶ if (! -f $args{files}[$int] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $args{"files"}[$int]) 0 0 0
174 0 $self->{error}=4;
175 0 $self->{perror}=1;
176 0 $self->{errorString}="'".$args{files}[$int]."' is not a file or does not exist";
177 0 $self->warn;
178 0 return $self;
179 }
180  
181 #gets the MIME type
182 0 my $mimetype=mimetype( $args{files}[$int] );
183  
184 #makes sure it is a mimetype
185 0 ▶ if ( !defined( $mimetype ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $mimetype) 0 0 0
186 0 $self->{error}=5;
187 0 $self->{perror}=1;
188 0 $self->{errorString}="'".$args{files}[$int]."' could not be read or does not exist";
189 0 $self->warn;
190 0 return $self;
191 }
192  
193 #open and read the file
194 0 my $fh;
195 0 ▶ if ( ! open( $fh, '<', $args{files}[$int] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open $fh, "<", $args{"files"}[$int]) 0 0 0
196 0 $self->{error}=6;
197 0 $self->{perror}=1;
198 0 $self->{errorString}="unable to open '".$args{files}[$int]."'";
199 0 $self->warn;
200 0 return $self;
201 }
202 0 my $file=join('',<$fh>);
203 0 close $fh;
204  
205 #create a short name for it... removing the path
206 0 my $filename=$args{files}[$int];
207 0 $filename=~s/.*\///g;
208
209 0 my $part=Email::MIME->create(attributes=>{
210 filename=>$filename,
211 content_type=>$mimetype,
212 encode=>"base64",
213 },
214 body=>$file,
215 );
216  
217 0 ▶ if (!defined( $part )) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $part) 0 0 0
218 0 $self->{error}=7;
219 0 $self->{perror}=1;
220 0 $self->{errorString}='Unable to create a MIME object for one of the files';
221 0 $self->warn;
222 0 return $self;
223 }
224  
225 0 push(@parts, $part);
226  
227 0 $int++;
228 }
229  
230 }
231  
232 #creates it
233 my $mime=Email::MIME->create(
234 header=>[
235 renderer=>$args{renderer},
236 name=>$args{name},
237 summary=>$args{summary},
238 publish=>$args{publish},
239 ],
240 body=>$args{body},
241 0 );
242  
243 0 ▶ if (!defined($mime)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $mime) 0 0 0
244 0 $self->{error}=2;
245 0 $self->{perror}=1;
246 0 $self->{errorString}='Unable to create Email::MIME object';
247 0 $self->warn;
248 0 return $self;
249 }
250  
251 #this sets the parts if needed
252 0 ▶ if ( defined( $parts[0] ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parts[0]) 0 0 0
253 0 $mime->set_parts( \@parts );
254 }
255  
256 0 $self->{mime}=$mime;
257  
258 #if we have a Toader object, reel it in
259 0 ▶ if ( ! defined( $args{toader} ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"toader"}) 0 0 0
260 0 $self->{perror}=1;
261 0 $self->{error}=19;
262 0 $self->{errorString}='No $args{toader} specified';
263 0 $self->warn;
264 0 return $self;
265 }
266 0 ▶ if ( ref( $args{toader} ) ne "Toader" ){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args{"toader"} ne "Toader") 0 0 0
267 0 $self->{perror}=1;
268 0 $self->{error}=14;
269 0 $self->{errorString}='The object specified is a "'.ref($args{toader}).'"';
270 0 $self->warn;
271 0 return $self;
272 }
273 0 $self->{toader}=$args{toader};
274  
275 #gets the Toader::VCS object
276 0 $self->{vcs}=$self->{toader}->getVCS;
277 0 ▶ if ( $self->{toader}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"toader"}->error) 0 0 0
278 0 $self->{perror}=1;
279 0 $self->{error}=15;
280 $self->{errorString}='Toader->getVCS errored. error="'.
281 0 $self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"';
282 0 $self->warn;
283 0 return $self;
284 }
285
286 #checks if VCS is usable
287 0 $self->{VCSusable}=$self->{vcs}->usable;
288 0 ▶ if ( $self->{vcs}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"vcs"}->error) 0 0 0
289 0 $self->{perror}=1;
290 0 $self->{error}=16;
291 $self->{errorString}='Toader::VCS->usable errored. error="'.
292 0 $self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"';
293 0 $self->warn;
294 0 return $self;
295 }
296  
297 0 return $self;
298 }
299  
300 =head2 newFromString
301  
302 This creates a new page from a string.
303  
304 There are two required arguments, the first being a string
305 containing the page in question and the second being
306 L<Toader> object.
307  
308 my $foo=Toader::Page->newFromString($pageString, $toader);
309 if($foo->error){
310 warn('Error:'.$foo->error.': '.$foo->errorString);
311 }
312  
313 =cut
314  
315 0 ▶sub newFromString{
Subroutine newFromString: not called CC=14 SCAR=53.5
Pod documented
316 0 my $string=$_[1];
317 0 my $toader=$_[2];
318  
319 0 my $self={
320 error=>undef,
321 errorString=>'',
322 module=>'Toader-Page',
323 perror=>undef,
324 dir=>undef,
325 errorExtra=>{
326 flags=>{
327 1=>'noPageName',
328 2=>'emailMIMEcreationFailed',
329 3=>'notAnArray',
330 4=>'fileDoesNotExist',
331 5=>'MIMEinfoError',
332 6=>'unableToOpenFile',
333 7=>'emailMIMEerror',
334 8=>'noBody',
335 9=>'notAtoaderDir',
336 10=>'noLongAtoaderDir',
337 11=>'nodirSet',
338 12=>'pagesDirCreationFailed',
339 13=>'publishValError',
340 14=>'notAtoaderObj',
341 15=>'getVCSfailed',
342 16=>'VCSusableFailed',
343 17=>'underVCSerror',
344 18=>'VCSaddError',
345 19=>'noToaderObj',
346 },
347 },
348 VCSusable=>0,
349 };
350 0 bless $self;
351  
352 #Email::MIME will exit if we pass it a null value
353 0 ▶ if (!defined($string)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 0 0 0
354 0 $self->{error}=8;
355 0 $self->{perror}=1;
356 0 $self->{errorString}='The string is null';
357 0 $self->warn;
358 0 return $self;
359 }
360  
361 #creates the MIME object
362 0 my $mime=Email::MIME->new($string);
363 0 ▶ if (!defined($mime)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $mime) 0 0 0
364 0 $self->{error}=2;
365 0 $self->{perror}=1;
366 0 $self->{errorString}='Unable to create Email::MIME object';
367 0 $self->warn;
368 0 return $self;
369 }
370  
371 #make sure we have a short name
372 0 ▶ if (!defined( $mime->header( "name" ) )) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $mime->header("name")) 0 0 0
373 0 $self->{error}=1;
374 0 $self->{perror}=1;
375 0 $self->{errorString}='No name specified';
376 0 $self->warn;
377 0 return $self;
378 }
379  
380 #make sure we have a from and if not set it to blank
381 0 ▶ if (!defined( $mime->header( "from" ) )) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $mime->header("from")) 0 0 0
382 0 $mime->header_set(from=>'');
383 }
384  
385 #set blank summary if not is specified
386 0 ▶ if (!defined( $mime->header( "summary" ) )) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $mime->header("summary")) 0 0 0
387 0 $mime->header_set(summary=>'');
388 }
389  
390  
391 #make sure we have a renderer type
392 0 ▶ if (!defined( $mime->header( "renderer" ) )) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $mime->header("renderer")) 0 0 0
393 0 $mime->header_set(renderer=>'html');
394 }
395  
396 #make sure we have publish set
397 0 ▶ if (!defined( $mime->header( "publish" ) )) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $mime->header("publish")) 0 0 0
398 0 $mime->header_set(publish=>'1');
399 }
400  
401 #makes sure the publish value is good
402 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($mime->header("publish") ne 0 and $mime->header("publish") ne 1) 0 0 0
Condition0%0/3
$mime->header("publish") ne 0 and $mime->header("publish") ne 1
!ll&&!rl&&r
000
MC/DC0%0/2
$mime->header("publish") ne 0 and $mime->header("publish") ne 1
$mime->header("publish") ne 0 $mime->header("publish") ne 1
Truth table0%0/3
A and B
A= $mime->header("publish") ne 0B= $mime->header("publish") ne 1
ABresult
0X0
100
111
403 ( $mime->header( "publish" ) ne "0" ) &&
404 ( $mime->header( "publish" ) ne "1" )
405 ){
406 0 $self->{perror}=1;
407 0 $self->{error}=13;
408 0 $self->{errorString}='"'.$mime->header( "publish" ).
409 '" is not a recognized boolean value';
410 0 $self->warn;
411 0 return $self;
412 }
413
414 0 $self->{mime}=$mime;
415  
416 #if we have a Toader object, reel it in
417 0 ▶ if ( ! defined( $toader ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $toader) 0 0 0
418 0 $self->{perror}=1;
419 0 $self->{error}=19;
420 0 $self->{errorString}='No Toader object specified';
421 0 $self->warn;
422 0 return $self;
423 }
424 0 ▶ if ( ref( $toader ) ne "Toader" ){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $toader ne "Toader") 0 0 0
425 0 $self->{perror}=1;
426 0 $self->{error}=14;
427 0 $self->{errorString}='The object specified is a "'.ref($toader).'"';
428 0 $self->warn;
429 0 return $self;
430 }
431 0 $self->{toader}=$toader;
432  
433 #gets the Toader::VCS object
434 0 $self->{vcs}=$self->{toader}->getVCS;
435 0 ▶ if ( $toader->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($toader->error) 0 0 0
436 0 $self->{perror}=1;
437 0 $self->{error}=15;
438 $self->{errorString}='Toader->getVCS errored. error="'.
439 0 $self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"';
440 0 $self->warn;
441 0 return $self;
442 }
443
444 #checks if VCS is usable
445 0 $self->{VCSusable}=$self->{vcs}->usable;
446 0 ▶ if ( $self->{vcs}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"vcs"}->error) 0 0 0
447 0 $self->{perror}=1;
448 0 $self->{error}=16;
449 $self->{errorString}='Toader::VCS->usable errored. error="'.
450 0 $self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"';
451 0 $self->warn;
452 0 return $self;
453 }
454  
455 0 return $self;
456 }
457  
458 =head1 GENERAL METHODS
459  
460 =head2 as_string
461  
462 This returns the page as a string.
463  
464 my $mimeString=$foo->as_string;
465 if($foo->error)
466 warn('Error:'.$foo->error.': '.$foo->errorString);
467 }
468  
469 =cut
470  
471 0 ▶sub as_string{
Subroutine as_string: not called CC=2 SCAR=17.9
Pod documented
472 0 my $self=$_[0];
473  
474 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
475 0 return undef;
476 }
477  
478 0 return $self->{mime}->as_string;
479 }
480  
481 =head2 bodyGet
482  
483 This gets body.
484  
485 my $body=$foo->bodyGet;
486 if($foo->error){
487 warn('Error:'.$foo->error.': '.$foo->errorString);
488 }
489  
490 =cut
491  
492 0 ▶sub bodyGet{
Subroutine bodyGet: not called CC=4 SCAR=30.0
Pod documented
493 0 my $self=$_[0];
494  
495 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
496 0 return undef;
497 }
498  
499 0 my @parts=$self->{mime}->subparts;
500
501 0 my $int=0;
502 0 ▶ while ( defined( $parts[$int] ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parts[$int]) 0 0 0
503 0 ▶ if ( ! defined( $parts[$int]->filename ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $parts[$int]->filename) 0 0 0
504 0 return $parts[$int]->body;
505 }
506  
507 0 $int++;
508 }
509  
510 0 return $self->{mime}->body;
511 }
512  
513 =head2 bodySet
514  
515 This sets the body.
516  
517 One argument is required and it is the body.
518  
519 $foo->bodySet($body);
520 if($foo->error){
521 warn('Error:'.$foo->error.': '.$foo->errorString);
522 }
523  
524 =cut
525  
526 0 ▶sub bodySet{
Subroutine bodySet: not called CC=6 SCAR=37.4
Pod documented
527 0 my $self=$_[0];
528 0 my $body=$_[1];
529  
530 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
531 0 return undef;
532 }
533  
534 0 ▶ if (!defined($body)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $body) 0 0 0
535 0 $self->{error}=8;
536 0 $self->{errorString}='No body defined';
537 0 $self->warn;
538 0 return undef;
539 }
540  
541  
542 0 my @parts=$self->{mime}->subparts;
543
544 0 ▶ if ( defined( $parts[1] ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parts[1]) 0 0 0
545 0 my $int=0;
546 0 ▶ while ( defined( $parts[$int] ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parts[$int]) 0 0 0
547 0 ▶ if ( ! defined( $parts[$int]->filename ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $parts[$int]->filename) 0 0 0
548 0 $parts[$int]->body_set($body);
549 }
550  
551 0 $int++;
552 }
553  
554 0 $self->{mime}->parts_set( \@parts );
555  
556 0 return 1;
557 }
558  
559 0 $self->{mime}->body_set($body);
560  
561 0 return 1;
562 }
563  
564 =head2 dirGet
565  
566 This gets L<Toader> directory this entry is associated with.
567  
568 This will only error if a permanent error is set.
569  
570 my $dir=$foo->dirGet;
571 if($foo->error){
572 warn('Error:'.$foo->error.': '.$foo->errorString);
573 }
574  
575 =cut
576  
577 0 ▶sub dirGet{
Subroutine dirGet: not called CC=2 SCAR=17.9
Pod documented
578 0 my $self=$_[0];
579  
580 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
581 0 return undef;
582 }
583  
584 0 return $self->{dir};
585 }
586  
587 =head2 dirSet
588  
589 This sets L<Toader> directory this entry is associated with.
590  
591 One argument is taken and it is the L<Toader> directory to set it to.
592  
593 $foo->dirSet($toaderDirectory);
594 if($foo->error){
595 warn('Error:'.$foo->error.': '.$foo->errorString);
596 }
597  
598 =cut
599  
600 0 ▶sub dirSet{
Subroutine dirSet: not called CC=3 SCAR=24.8
Pod documented
601 0 my $self=$_[0];
602 0 my $dir=$_[1];
603  
604 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
605 0 return undef;
606 }
607  
608 #cleans up the naming
609 0 my $pathHelper=Toader::pathHelper->new($dir);
610 0 $dir=$pathHelper->cleanup($dir);
611  
612 #checks if the directory is Toader directory or not
613 0 my $isatd=Toader::isaToaderDir->new;
614 0 my $returned=$isatd->isaToaderDir($dir);
615 0 ▶ if (! $returned ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($returned) 0 0 0
616 0 $self->{error}=9;
617 0 $self->{errorString}='"'.$dir.'" is not a Toader directory';
618 0 $self->warn;
619 0 return undef;
620 }
621  
622 0 $self->{dir}=$dir;
623  
624 0 return 1;
625 }
626  
627 =head2 fromGet
628  
629 This returns the from.
630  
631 my $from=$foo->fromGet;
632 if($foo->error){
633 warn('error: '.$foo->error.":".$foo->errorString);
634 }
635  
636 =cut
637  
638 0 ▶sub fromGet{
Subroutine fromGet: not called CC=2 SCAR=17.9
Pod documented
639 0 my $self=$_[0];
640  
641 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
642 0 return undef;
643 }
644  
645 0 return $self->{mime}->header('From');
646 }
647  
648 =head2 fromSet
649  
650 This sets the from.
651  
652 One argument is taken and it is the name.
653  
654 $foo->fromSet($name);
655 if($foo->error){
656 warn('error: '.$foo->error.":".$foo->errorString);
657 }
658  
659 =cut
660  
661 0 ▶sub fromSet{
Subroutine fromSet: not called CC=3 SCAR=24.8
Pod documented
662 0 my $self=$_[0];
663 0 my $from=$_[1];
664  
665 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
666 0 return undef;
667 }
668  
669 0 ▶ if (!defined( $from )) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $from) 0 0 0
670 0 $self->{error}=9;
671 0 $self->{errorString}='No short name specified';
672 0 $self->warn;
673 0 return $self;
674 }
675  
676 0 $self->{mime}->header_set('From'=>$from);
677  
678 0 return 1;
679 }
680  
681 =head2 nameGet
682  
683 This returns the name.
684  
685 my $name=$foo->nameGet;
686 if($foo->error){
687 warn('error: '.$foo->error.":".$foo->errorString);
688 }
689  
690 =cut
691  
692 0 ▶sub nameGet{
Subroutine nameGet: not called CC=2 SCAR=17.9
Pod documented
693 0 my $self=$_[0];
694  
695 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
696 0 return undef;
697 }
698  
699 0 return $self->{mime}->header('name');
700 }
701  
702 =head2 nameSet
703  
704 This sets the short name.
705  
706 One argument is taken and it is the name.
707  
708 $foo->nameSet($name);
709 if($foo->error){
710 warn('error: '.$foo->error.":".$foo->errorString);
711 }
712  
713 =cut
714  
715 0 ▶sub nameSet{
Subroutine nameSet: not called CC=3 SCAR=24.8
Pod documented
716 0 my $self=$_[0];
717 0 my $name=$_[1];
718  
719 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
720 0 return undef;
721 }
722  
723 0 ▶ if (!defined( $name )) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $name) 0 0 0
724 0 $self->{error}=1;
725 0 $self->{errorString}='No short name specified';
726 0 $self->warn;
727 0 return $self;
728 }
729  
730 0 $self->{mime}->header_set('name'=>$name);
731  
732 0 return 1;
733 }
734  
735 =head2 publishGet
736  
737 This returns the publish value.
738  
739 my $publish=$foo->publishGet;
740 if($foo->error){
741 warn('error: '.$foo->error.":".$foo->errorString);
742 }
743  
744 =cut
745  
746 0 ▶sub publishGet{
Subroutine publishGet: not called CC=5 SCAR=34.0
Pod documented
747 0 my $self=$_[0];
748  
749 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
750 0 return undef;
751 }
752  
753 0 my $publish=$self->{mime}->header('publish');
754  
755 #if not defined, return the default
756 0 ▶ if ( ! defined( $publish ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $publish) 0 0 0
757 0 return '1';
758 }
759  
760 #make sure it is a recognized boolean value
761 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($publish ne 0 and $publish ne 1) 0 0 0
Condition0%0/3
$publish ne 0 and $publish ne 1
!ll&&!rl&&r
000
MC/DC0%0/2
$publish ne 0 and $publish ne 1
$publish ne 0 $publish ne 1
Truth table0%0/3
A and B
A= $publish ne 0B= $publish ne 1
ABresult
0X0
100
111
762 ( $publish ne '0' ) &&
763 ( $publish ne '1' )
764 ){
765 0 $self->{error}=13;
766 0 $self->{errorString}='Not a recognized boolean value';
767 0 $self->warn;
768 0 return undef;
769 }
770  
771 0 return $publish;
772 }
773  
774 =head2 publishSet
775  
776 This sets the publish value.
777  
778 One argument is taken and it is the publish value.
779  
780 If no value is set, it uses the default, "1".
781  
782 It must be a recognized boolean value, either "0" or "1".
783  
784 $foo->publishSet($publish);
785 if($foo->error){
786 warn('error: '.$foo->error.":".$foo->errorString);
787 }
788  
789 =cut
790  
791 0 ▶sub publishSet{
Subroutine publishSet: not called CC=5 SCAR=34.0
Pod documented
792 0 my $self=$_[0];
793 0 my $publish=$_[1];
794  
795 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
796 0 return undef;
797 }
798  
799 0 ▶ if (!defined( $publish )) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $publish) 0 0 0
800 0 $publish='1';
801 }
802  
803 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($publish ne 0 and $publish ne 1) 0 0 0
Condition0%0/3
$publish ne 0 and $publish ne 1
!ll&&!rl&&r
000
MC/DC0%0/2
$publish ne 0 and $publish ne 1
$publish ne 0 $publish ne 1
Truth table0%0/3
A and B
A= $publish ne 0B= $publish ne 1
ABresult
0X0
100
111
804 ( $publish ne '0' ) &&
805 ( $publish ne '1' )
806 ){
807 0 $self->error=13;
808 0 $self->errorString='The publish value is not "0" or "1", but "'.$publish.'"';
809 0 $self->warn;
810 0 return undef;
811 }
812
813  
814 0 $self->{mime}->header_set('publish'=>$publish);
815  
816 0 return 1;
817 }
818  
819 =head2 rendererGet
820  
821 This returns the renderer type.
822  
823 my $renderer=$foo->rendererGet;
824 if($foo->error){
825 warn('error: '.$foo->error.":".$foo->errorString);
826 }
827  
828 =cut
829  
830 0 ▶sub rendererGet{
Subroutine rendererGet: not called CC=2 SCAR=17.9
Pod documented
831 0 my $self=$_[0];
832  
833 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
834 0 return undef;
835 }
836  
837 0 return $self->{mime}->header('renderer');
838 }
839  
840 =head2 rendererSet
841  
842 This sets the renderer type.
843  
844 One argument is taken and it is the render type.
845  
846 A value of undef sets it to the default, 'html'.
847  
848 my $renderer=$foo->rendererGet;
849 if($foo->error){
850 warn('error: '.$foo->error.":".$foo->errorString);
851 }
852  
853 =cut
854  
855 0 ▶sub rendererSet{
Subroutine rendererSet: not called CC=3 SCAR=24.8
Pod documented
856 0 my $self=$_[0];
857 0 my $renderer=$_[1];
858  
859 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
860 0 return undef;
861 }
862  
863 0 ▶ if (!defined( $renderer )) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $renderer) 0 0 0
864 0 $renderer='html';
865 }
866  
867 0 $self->{mime}->header_set('renderer'=>$renderer);
868  
869 0 return 1;
870 }
871  
872 =head2 subpartsAdd
873  
874 This adds a new file as a subpart.
875  
876 One argument is required and it is the path to the file.
877  
878 $foo->subpartsAdd( $file );
879 if ( $foo->error ){
880 warn('Error:'.$foo->error.': '.$foo->errorString);
881 }
882  
883 =cut
884  
885 0 ▶sub subpartsAdd{
Subroutine subpartsAdd: not called CC=6 SCAR=37.4
Pod documented
886 0 my $self=$_[0];
887 0 my $file=$_[1];
888  
889 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
890 0 return undef;
891 }
892  
893 #makes sure a file is specified
894 0 ▶ if ( ! defined( $file ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $file) 0 0 0
895 0 $self->{error}=18;
896 0 $self->{errorstring}='No file specified';
897 0 $self->warn;
898 0 return undef;
899 }
900  
901 #makes sure the file exists and is a file
902 0 ▶ if ( ! -f $file ){
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $file) 0 0 0
903 0 $self->{error}=4;
904 0 $self->{errorString}='The file, "'.$file.'", does not exist or is not a file';
905 0 $self->warn;
906 0 return undef;
907 }
908  
909 #gets the MIME type
910 0 my $mimetype=mimetype( $file );
911
912 #makes sure it is a mimetype
913 0 ▶ if ( !defined( $mimetype ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $mimetype) 0 0 0
914 0 $self->{error}=5;
915 0 $self->{errorString}="'".$file."' could not be read or does not exist";
916 0 $self->warn;
917 0 return $self;
918 }
919  
920 #create a short name for it... removing the path
921 0 my $filename=$file;
922 0 $filename=~s/.*\///g;
923  
924 #open and read the file
925 0 my $fh;
926 0 ▶ if ( ! open( $fh, '<', $file ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open $fh, "<", $file) 0 0 0
927 0 $self->{error}=6;
928 0 $self->{errorString}="Unable to open '".$file."'";
929 0 $self->warn;
930 0 return undef;
931 }
932 0 my $body=join('',<$fh>);
933 0 close $fh;
934  
935  
936 #creates the part
937 0 my $part=Email::MIME->create(attributes=>{
938 filename=>$filename,
939 content_type=>$mimetype,
940 encode=>"base64",
941 },
942 body=>$body,
943 );
944 0 my @parts;
945 0 push( @parts, $part );
946 0 $self->{mime}->parts_add( \@parts );
947  
948 0 return 1;
949 }
950  
951 =head2 subpartsExtract
952  
953 This extracts the subparts of a entry.
954  
955 One argument is extracted, it is the directory
956 to extract the files to.
957  
958 $foo->subpartsExtract( $dir );
959 if ( $foo->error ){
960 warn('Error:'.$foo->error.': '.$foo->errorString);
961 }
962  
963 =cut
964  
965 0 ▶sub subpartsExtract{
Subroutine subpartsExtract: not called CC=9 SCAR=45.0
Pod documented
966 0 my $self=$_[0];
967 0 my $dir=$_[1];
968  
969 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
970 0 return undef;
971 }
972  
973 0 ▶ if ( ! defined( $dir ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $dir) 0 0 0
974 0 $self->{error}=11;
975 0 $self->{errorString}='No directory specified';
976 0 $self->warn;
977 0 return undef;
978 }
979  
980 #make sure it exists and is a directory
981 0 ▶ if ( ! -d $dir ){
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $dir) 0 0 0
982 0 $self->{error}=17;
983 0 $self->{errorString}='"'.$dir.'" is not a directory or does not exist';
984 0 $self->warn;
985 0 return undef;
986 }
987  
988 0 my @subparts=$self->subpartsGet;
989 0 ▶ if ( $self->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->error) 0 0 0
990 0 $self->warnString('Failed to get the subparts');
991 0 return undef;
992 }
993  
994 # no subparts to write to the FS
995 0 ▶ if ( ! defined( $subparts[0] ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $subparts[0]) 0 0 0
996 0 return 1;
997 }
998  
999 0 my $int=0;
1000 0 ▶ while ( defined( $subparts[$int] ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $subparts[$int]) 0 0 0
1001 0 my $file=$subparts[$int]->filename;
1002 0 ▶ if( defined( $file ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $file) 0 0 0
1003 0 my $file=$dir.'/'.$file;
1004
1005 0 my $fh;
1006 0 ▶ if ( ! open( $fh, '>', $file ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (open $fh, ">", $file) 0 0 0
1007 0 $self->{error}=18;
1008 0 $self->{errorString}='"Failed to open "'.$file.
1009 '" for writing the body of a subpart out to';
1010 0 $self->warn;
1011 0 return undef;
1012 }
1013 0 print $fh $subparts[$int]->body;
1014 0 close( $fh );
1015 }
1016  
1017 0 $int++;
1018 }
1019  
1020 0 return 1;
1021 }
1022  
1023 =head2 subpartsGet
1024  
1025 This returns the results from the subparts
1026 methods from the internal L<Email::MIME> object.
1027  
1028 my @parts=$foo->subpartsGet;
1029 if ( $foo->error ){
1030 warn('Error:'.$foo->error.': '.$foo->errorString);
1031 }
1032  
1033 =cut
1034  
1035 0 ▶sub subpartsGet{
Subroutine subpartsGet: not called CC=2 SCAR=17.9
Pod documented
1036 0 my $self=$_[0];
1037  
1038 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
1039 0 return undef;
1040 }
1041  
1042 0 return $self->{mime}->subparts;
1043 }
1044  
1045 =head2 subpartsList
1046  
1047 This returns a list filenames for the subparts.
1048  
1049 my @files=$foo->subpartsList;
1050 if ( $foo->error ){
1051 warn('Error:'.$foo->error.': '.$foo->errorString);
1052 }
1053  
1054 =cut
1055  
1056 0 ▶sub subpartsList{
Subroutine subpartsList: not called CC=5 SCAR=34.0
Pod documented
1057 0 my $self=$_[0];
1058  
1059 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
1060 0 return undef;
1061 }
1062  
1063 0 my @subparts=$self->subpartsGet;
1064 0 ▶ if ( $self->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->error) 0 0 0
1065 0 $self->warnString('Failed to get the subparts');
1066 0 return undef;
1067 }
1068  
1069 0 my @files;
1070 0 my $int=0;
1071 0 ▶ while( defined( $subparts[$int] ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $subparts[$int]) 0 0 0
1072 0 ▶ if ( defined( $subparts[$int]->filename ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $subparts[$int]->filename) 0 0 0
1073 0 push( @files, $subparts[$int]->filename );
1074 }
1075  
1076 0 $int++;
1077 }
1078  
1079 0 return @files;
1080 }
1081  
1082 =head2 subpartsRemove
1083  
1084 This removes the specified subpart.
1085  
1086 One argument is required and it is the name of the
1087 file to remove.
1088  
1089 $foo->subpartsRemove( $filename );
1090 if ( $foo->error ){
1091 warn('Error:'.$foo->error.': '.$foo->errorString);
1092 }
1093  
1094 =cut
1095  
1096 0 ▶sub subpartsRemove{
Subroutine subpartsRemove: not called CC=6 SCAR=37.4
Pod documented
1097 0 my $self=$_[0];
1098 0 my $file=$_[1];
1099  
1100 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
1101 0 return undef;
1102 }
1103  
1104 #makes sure a file is specified
1105 0 ▶ if ( ! defined( $file ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $file) 0 0 0
1106 0 $self->{error}=18;
1107 0 $self->{errorstring}='No file specified';
1108 0 $self->warn;
1109 0 return undef;
1110 }
1111  
1112 0 my @parts=$self->{mime}->parts;
1113 0 my @newparts;
1114 0 my $int=0;
1115 0 ▶ while ( defined( $parts[$int] ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parts[$int]) 0 0 0
1116 0 my $partFilename=$parts[$int]->filename;
1117 0 ▶ if ( ( ! defined( $partFilename ) ) ||
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $partFilename or $file ne $partFilename) 0 0 0
Condition0%0/3
not defined $partFilename or $file ne $partFilename
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $partFilename or $file ne $partFilename
not defined $partFilename $file ne $partFilename
Truth table0%0/3
not(A) or B
A= not defined $partFilenameB= $file ne $partFilename
ABresult
1X1
011
000
1118 ( $file ne $partFilename ) ){
1119 0 push( @newparts, $parts[$int] );
1120 }
1121  
1122 0 $int++;
1123 }
1124  
1125 0 $self->{mime}->parts_set( \@newparts );
1126  
1127 0 return 1;
1128 }
1129  
1130 =head2 summaryGet
1131  
1132 This returns the summary.
1133  
1134 my $summary=$foo->summaryGet;
1135 if($foo->error){
1136 warn('error: '.$foo->error.":".$foo->errorString);
1137 }
1138  
1139 =cut
1140  
1141 0 ▶sub summaryGet{
Subroutine summaryGet: not called CC=3 SCAR=24.8
Pod documented
1142 0 my $self=$_[0];
1143  
1144 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
1145 0 return undef;
1146 }
1147  
1148 0 my $summary=$self->{mime}->header('summary');
1149  
1150 0 ▶ if ( ! defined( $summary ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $summary) 0 0 0
1151 0 $summary='';
1152 }
1153  
1154 0 return $summary;
1155 }
1156  
1157 =head2 summarySet
1158  
1159 This sets the summary.
1160  
1161 One argument is taken and it is the summary.
1162  
1163 $foo->summarySet($summary);
1164 if($foo->error){
1165 warn('error: '.$foo->error.":".$foo->errorString);
1166 }
1167  
1168 =cut
1169  
1170 0 ▶sub summarySet{
Subroutine summarySet: not called CC=3 SCAR=24.8
Pod documented
1171 0 my $self=$_[0];
1172 0 my $summary=$_[1];
1173  
1174 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
1175 0 return undef;
1176 }
1177  
1178 0 ▶ if (!defined( $summary )) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $summary) 0 0 0
1179 0 $self->{error}=15;
1180 0 $self->{errorString}='No summary specified';
1181 0 $self->warn;
1182 0 return $self;
1183 }
1184  
1185 0 $self->{mime}->header_set('summary'=>$summary);
1186  
1187 0 return 1;
1188 }
1189  
1190 =head2 write
1191  
1192 This saves the page file. It requires dirSet to
1193 have been called previously.
1194  
1195 $foo->write;
1196 if($foo->error){
1197 warn('error: '.$foo->error.":".$foo->errorString);
1198 }
1199  
1200 =cut
1201  
1202 0 ▶sub write{
Subroutine write: not called CC=11 SCAR=48.8
Pod documented
1203 0 my $self=$_[0];
1204  
1205 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
1206 0 return undef;
1207 }
1208  
1209 #makes so a directory has been specified
1210 0 ▶ if (!defined( $self->{dir} )) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"dir"}) 0 0 0
1211 0 $self->{error}=11;
1212 0 $self->{errorString}='No directory has been specified yet';
1213 0 $self->warn;
1214 0 return undef;
1215 }
1216  
1217 #makes sure it is still a toader directory...
1218 0 ▶ if (! -d $self->{dir}.'/.toader/' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $self->{"dir"} . '/.toader/') 0 0 0
1219 0 $self->{error}=10;
1220 0 $self->{errorString}='No directory has been specified yet';
1221 0 $self->warn;
1222 0 return undef;
1223 }
1224  
1225 #if there is no entry directory, generate one...
1226 0 ▶ if (! -d $self->{dir}.'/.toader/pages/' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $self->{"dir"} . '/.toader/pages/') 0 0 0
1227 0 ▶ if (! make_path( $self->{dir}.'/.toader/pages/' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (make_path($self->{"dir"} . '/.toader/pages/')) 0 0 0
1228 0 $self->{error}=12;
1229 0 $self->{errorString}='The pages directory did not exist and was not able to create it';
1230 0 $self->warn;
1231 0 return undef;
1232 }
1233 }
1234  
1235 #figure out the file will be
1236 0 my $file=$self->{dir}.'/.toader/pages/'.$self->nameGet;
1237  
1238 #converts the page to a string
1239 0 my $pageString=$self->as_string;
1240  
1241 #writes the file
1242 0 my $fh;
1243 0 ▶ if ( ! open($fh, '>', $file) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (open $fh, ">", $file) 0 0 0
1244 0 $self->{error}=13;
1245 0 $self->{errorString}='Unable to open "'.$file.'" for writing';
1246 0 $self->warn;
1247 0 return undef;
1248 }
1249 0 print $fh $pageString;
1250 0 close($fh);
1251  
1252 #if VCS is not usable, stop here
1253 0 ▶ if ( ! $self->{VCSusable} ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"VCSusable"}) 0 0 0
1254 0 return 1;
1255 }
1256  
1257 #if it is under VCS, we have nothing to do
1258 0 my $underVCS=$self->{vcs}->underVCS($file);
1259 0 ▶ if ( $self->{vcs}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"vcs"}->error) 0 0 0
1260 0 $self->{error}=17;
1261 $self->{errorString}='Toader::VCS->underVCS errored. error="'.
1262 0 $self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"';
1263 0 $self->warn;
1264 0 return undef;
1265 }
1266 0 ▶ if ( $underVCS ){
Branch: 1 branch
BranchTrueFalseTotal
if ($underVCS) 0 0 0
1267 0 return 1;
1268 }
1269  
1270 #add it as if we reach here it is not under VCS and VCS is being used
1271 0 $self->{vcs}->add( $file );
1272 0 ▶ if ( $self->{vcs}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"vcs"}->error) 0 0 0
1273 0 $self->{error}=18;
1274 $self->{errorString}='Toader::VCS->add errored. error="'.
1275 0 $self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"';
1276 0 $self->warn;
1277 0 return undef;
1278 }
1279  
1280 0 return 1;
1281 }
1282  
1283 =head1 REQUIRED RENDERING METHODS
1284  
1285 =head2 filesDir
1286  
1287 This returns the file directory for the object.
1288  
1289 This is not a full path, but a partial path that should
1290 be appended the directory current directory being outputted to.
1291  
1292 =cut
1293  
1294 0 ▶sub filesDir{
Subroutine filesDir: not called CC=3 SCAR=24.8
Pod documented
1295 0 my $self=$_[0];
1296  
1297 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
1298 0 return undef;
1299 }
1300  
1301 0 ▶ if ( ! defined( $self->{mime}->header('name') ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"mime"}->header("name")) 0 0 0
1302 0 $self->{error}=16;
1303 0 $self->{errorString}='No entry name has been set';
1304 0 $self->warn;
1305 0 return undef;
1306 }
1307  
1308 0 return $self->renderDir.'/'.$self->{mime}->header('name').'/.files';
1309 }
1310  
1311  
1312 =head2 locationID
1313  
1314 This returns the location ID.
1315  
1316 This one requires the object to be initialized.
1317  
1318 =cut
1319  
1320 0 ▶sub locationID{
Subroutine locationID: not called CC=2 SCAR=17.9
Pod documented
1321 0 my $self=$_[0];
1322  
1323 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
1324 0 return undef;
1325 }
1326  
1327 0 return 'Page='.$self->nameGet;
1328 }
1329  
1330 =head2 renderDir
1331  
1332 This is the directory that it will be rendered to.
1333  
1334 The base directory that will be used for rendering.
1335  
1336 =cut
1337  
1338 0 ▶sub renderDir{
Subroutine renderDir: not called CC=1 SCAR=6.9
Pod documented
1339 0 return '.pages';
1340 }
1341  
1342 =head2 renderUsing
1343  
1344 This returns the module to use for rendering.
1345  
1346 my $module=$foo->renderUsing;
1347  
1348 =cut
1349  
1350 0 ▶sub renderUsing{
Subroutine renderUsing: not called CC=1 SCAR=6.9
Pod documented
1351 0 return 'Toader::Render::Page';
1352 }
1353  
1354 =head2 toaderRenderable
1355  
1356 This method returns true and marks it as being L<Toader>
1357 renderable.
1358  
1359 =cut
1360  
1361 0 ▶sub toaderRenderable{
Subroutine toaderRenderable: not called CC=1 SCAR=6.9
Pod documented
1362 0 return 1;
1363 }
1364  
1365 =head2 toDir
1366  
1367 This returns the relative path to the object.
1368  
1369 This is not a full path, but a partial path that should
1370 be appended the directory current directory being outputted to.
1371  
1372 =cut
1373  
1374 0 ▶sub toDir{
Subroutine toDir: not called CC=3 SCAR=24.8
Pod documented
1375 0 my $self=$_[0];
1376  
1377 0 ▶ if (!$self->errorblank){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
1378 0 return undef;
1379 }
1380  
1381 0 ▶ if ( ! defined( $self->{entryName} ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"entryName"}) 0 0 0
1382 0 $self->{error}=16;
1383 0 $self->{errorString}='No entry name has been set';
1384 0 $self->warn;
1385 0 return undef;
1386 }
1387  
1388 0 return $self->renderDir.'/'.$self->{entryName};
1389 }
1390  
1391 =head1 ERROR CODES/FLAGS
1392  
1393 =head2 1, noPageName
1394  
1395 No name specified.
1396  
1397 =head2 2, emailMIMEcreationFailed
1398  
1399 Unable to create L<Email::MIME> object.
1400  
1401 =head2 3, notAnArray
1402  
1403 Has files specified, but the passed object is not a array.
1404  
1405 =head2 4, fileDoesNotExist
1406  
1407 The file does not exist or is not a file.
1408  
1409 =head2 5, MIMEinfoError
1410  
1411 File::MimeInfo->mimetype returned undef, meaning the file does not exist or is not readable.
1412  
1413 =head2 6, unableToOpenFile
1414  
1415 Unable to open the file.
1416  
1417 =head2 7, emailMIMEerror
1418  
1419 Unable to create a L<Email::MIME> object for one of the parts/files.
1420  
1421 =head2 8, noBody
1422  
1423 No body defined.
1424  
1425 =head2 9, notAtoaderDir
1426  
1427 Not a L<Toader> directory.
1428  
1429 =head2 10, noLonderAtoaderDir
1430  
1431 No longer appears to be a L<Toader> directory.
1432  
1433 =head2 11, noDirSet
1434  
1435 No directory has been specified.
1436  
1437 =head2 12, pagesDirCreationFailed
1438  
1439 The pages directory could not be created.
1440  
1441 =head2 13, publishValError
1442  
1443 The publish value is not a recognized boolean value.
1444  
1445 Only '0' and '1' is recognized.
1446  
1447 =head2 14, notAtoaderObj
1448  
1449 The specified object is not a L<Toader> object.
1450  
1451 =head2 15, getVCSerrored
1452  
1453 L<Toader>->getVCS errored.
1454  
1455 =head2 16, VCSusableErrored
1456  
1457 L<Toader::VCS>->usable errored.
1458  
1459 =head2 17, underVCSerror
1460  
1461 L<Toader::VCS>->underVCS errored.
1462  
1463 =head2 18, VCSaddErrored
1464  
1465 L<Toader::VCS>->add errored.
1466  
1467 =head2 19, noToaderObj
1468  
1469 No L<Toader> object specified.
1470  
1471 =head1 AUTHOR
1472  
1473 Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >>
1474  
1475 =head1 BUGS
1476  
1477 Please report any bugs or feature requests to C<bug-toader at rt.cpan.org>, or through
1478 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Toader>. I will be notified, and then you'll
1479 automatically be notified of progress on your bug as I make changes.
1480  
1481  
1482  
1483  
1484 =head1 SUPPORT
1485  
1486 You can find documentation for this module with the perldoc command.
1487  
1488 perldoc Toader::Page
1489  
1490  
1491 You can also look for information at:
1492  
1493 =over 4
1494  
1495 =item * RT: CPAN's request tracker
1496  
1497 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Toader>
1498  
1499 =item * AnnoCPAN: Annotated CPAN documentation
1500  
1501 L<http://annocpan.org/dist/Toader>
1502  
1503 =item * CPAN Ratings
1504  
1505 L<http://cpanratings.perl.org/d/Toader>
1506  
1507 =item * Search CPAN
1508  
1509 L<http://search.cpan.org/dist/Toader/>
1510  
1511 =back
1512  
1513  
1514 =head1 ACKNOWLEDGEMENTS
1515  
1516  
1517 =head1 LICENSE AND COPYRIGHT
1518  
1519 Copyright 2011 Zane C. Bowers-Hadley.
1520  
1521 This program is free software; you can redistribute it and/or modify it
1522 under the terms of either: the GNU General Public License as published
1523 by the Free Software Foundation; or the Artistic License.
1524  
1525 See http://dev.perl.org/licenses/ for more information.
1526  
1527  
1528 =cut
1529  
1530 6 1; # End of Toader
« Toader/Render/General.pm ↑ Summary Toader/Entry.pm »