Toader/Entry/Manage.pm

filter: Statementstmt 8.0% 23 / 286 Branchbran 0.0% 0 / 100 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 43.7% 7 / 16 Podpod 100% 9 / 9 totaltotal 9.3% 39 / 416 CC 52 SCAR 41.5
CC
52
Cov
6%
remove
156.0
published
72.0
new
56.0
CRAP 63.4
« Toader/Templates.pm ↑ Summary Toader/Entry/Cache.pm »
1 package Toader::Entry::Manage;
2  
3 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use Toader::isaToaderDir;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use Toader::Entry::Helper;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 7 ▶use Toader::Entry;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 7 ▶use base 'Error::Helper';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 7 ▶use Toader::Entry::Cache;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 =head1 NAME
12  
13 Toader::Entry::Manage - Manage entries.
14  
15 =head1 VERSION
16  
17 Version 1.0.0
18  
19 =cut
20  
21 7 our $VERSION = '1.0.0';
22  
23 =head1 METHODS
24  
25 =head2 new
26  
27 This initiates the object.
28  
29 One argument is required and it is a L<Toader> object.
30  
31 After calling this, you should call setDir to set the directory to use.
32  
33 my $foo = Toader::New->new( $toader );
34  
35 =cut
36  
37 0 ▶sub new{
Subroutine new: not called CC=7 SCAR=40.3
Pod documented
38 0 my $toader=$_[1];
39  
40 0 my $self={
41 error=>undef,
42 errorString=>'',
43 dir=>undef,
44 edir=>undef,
45 isatd=>Toader::isaToaderDir->new,
46 helper=>undef,
47 VCSusable=>0,
48 toader=>undef,
49 errorExtra=>{
50 flags=>{
51 1=>'noDirSpecified',
52 2=>'isaToaderDirErrored',
53 3=>'notAtoaderDir',
54 4=>'noDirDefined',
55 5=>'openDirFailed',
56 6=>'noEntrySpecified',
57 7=>'invalidEntryName',
58 8=>'entryDoesNotExist',
59 9=>'unlinkFailed',
60 10=>'openEntryFailed',
61 11=>'entryObjCreationFailed',
62 12=>'notAtoaderObj',
63 13=>'getVCSerrored',
64 14=>'VCSusableErrored',
65 15=>'underVCSerrored',
66 16=>'VCSdeleteErrored',
67 17=>'noToaderObj',
68 18=>'helperNewErrored',
69 19=>'cacheNewErrored',
70 20=>'cacheDirSetErrored',
71 21=>'cacheUpdateAllErrored',
72 22=>'entryNameSetErrored',
73 23=>'entryWriteErrored',
74 },
75 },
76 };
77 0 bless $self;
78  
79 #if we have a Toader object, reel it in
80 0 ▶ if ( ! defined( $toader ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $toader) 0 0 0
81 0 $self->{perror}=1;
82 0 $self->{error}=17;
83 0 $self->{errorString}='No Toader object specified';
84 0 $self->warn;
85 0 return $self;
86 }
87 0 ▶ if ( ref( $toader ) ne "Toader" ){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $toader ne "Toader") 0 0 0
88 0 $self->{perror}=1;
89 0 $self->{error}=12;
90 0 $self->{errorString}='The object specified is a "'.ref($toader).'"';
91 0 $self->warn;
92 0 return $self;
93 }
94 0 $self->{toader}=$toader;
95  
96 #init the helper
97 0 $self->{helper}=Toader::Entry::Helper->new( $self->{toader} );
98 0 ▶ if ( $self->{helper}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"helper"}->error) 0 0 0
99 0 $self->{perror}=1;
100 0 $self->{error}=18;
101 $self->{errorString}='Failed to initialize Toader::Entry::Helper.'.
102 0 'error="'.$self->{helper}->error.'" errorString="'.$self->{helper}->errorString.'"';
103 0 $self->warn;
104 0 return $self;
105 }
106
107 #gets the Toader::VCS object
108 0 $self->{vcs}=$self->{toader}->getVCS;
109 0 ▶ if ( $toader->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($toader->error) 0 0 0
110 0 $self->{perror}=1;
111 0 $self->{error}=13;
112 $self->{errorString}='Toader->getVCS errored. error="'.
113 0 $self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"';
114 0 $self->warn;
115 0 return $self;
116 }
117
118 #checks if VCS is usable
119 0 $self->{VCSusable}=$self->{vcs}->usable;
120 0 ▶ if ( $self->{vcs}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"vcs"}->error) 0 0 0
121 0 $self->{perror}=1;
122 0 $self->{error}=14;
123 $self->{errorString}='Toader::VCS->usable errored. error="'.
124 0 $self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"';
125 0 $self->warn;
126 0 return $self;
127 }
128  
129 #inits the cache
130 0 my $cache=Toader::Entry::Cache->new( $toader );
131 0 ▶ if ( $cache->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($cache->error) 0 0 0
132 0 $self->{perror}=1;
133 0 $self->{error}=19;
134 0 $self->{errorString}='Toader::Entry::Cache->new errored. error="'.
135 $cache->error.'" errorString="'.$cache->errorString.'"';
136 0 $self->warn;
137 0 return $self;
138 }
139 0 $self->{cache}=$cache;
140  
141 0 return $self;
142 }
143  
144 =head2 cacheGet
145  
146 This returns the L<Toader::Entry::Cache> object.
147  
148 There are no arguments taken.
149  
150 my $cache=$foo->cacheGet;
151 if($foo->error){
152 warn('error: '.$foo->error.":".$foo->errorString);
153 }
154  
155 =cut
156  
157 0 ▶sub cacheGet{
Subroutine cacheGet: not called CC=3 SCAR=24.8
Pod documented
158 0 my $self=$_[0];
159  
160 #blank any previous errors
161 0 ▶ if (!$self->errorblank) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
162 0 return undef;
163 }
164  
165 #make sure a directory has been set
166 0 ▶ if (!defined($self->{dir})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"dir"}) 0 0 0
167 0 $self->{error}='4';
168 0 $self->{errorString}='No directory has been set yet';
169 0 $self->warn;
170 0 return undef;
171 }
172  
173 0 return $self->{cache};
174 }
175  
176 =head2 cacheUpdateAll
177  
178 This updates the cache for all entries.
179  
180 There are no arguments taken.
181  
182 $foo->cacheUpdateAll;
183 if($foo->error){
184 warn('error: '.$foo->error.":".$foo->errorString);
185 }
186  
187 =cut
188  
189 0 ▶sub cacheUpdateAll{
Subroutine cacheUpdateAll: not called CC=4 SCAR=30.0
Pod documented
190 0 my $self=$_[0];
191  
192 #blank any previous errors
193 0 ▶ if (!$self->errorblank) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
194 0 return undef;
195 }
196  
197 #make sure a directory has been set
198 0 ▶ if (!defined($self->{dir})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"dir"}) 0 0 0
199 0 $self->{error}='4';
200 0 $self->{errorString}='No directory has been set yet';
201 0 $self->warn;
202 0 return undef;
203 }
204  
205 0 $self->{cache}->updateAll;
206 0 ▶ if ( $self->{cache}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"cache"}->error) 0 0 0
207 0 $self->{error}=21;
208 $self->{errorString}='Toader::Entry::Cache->updateAll errored. error="'.
209 0 $self->{cache}->error.'" errorString="'.$self->{cache}->errorString.'"';
210 0 $self->warn;
211 0 return undef;
212 }
213  
214 0 return 1;
215 }
216  
217 =head2 list
218  
219 This lists the available entries.
220  
221 my @entries=$foo->list;
222 if($foo->error){
223 warn('error: '.$foo->error.":".$foo->errorString);
224 }
225  
226 =cut
227  
228 0 ▶sub list{
Subroutine list: not called CC=6 SCAR=37.4
Pod documented
229 0 my $self=$_[0];
230  
231 #blank any previous errors
232 0 ▶ if (!$self->errorblank) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
233 0 return undef;
234 }
235  
236 #make sure a directory has been set
237 0 ▶ if (!defined($self->{dir})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"dir"}) 0 0 0
238 0 $self->{error}='4';
239 0 $self->{errorString}='No directory has been set yet';
240 0 $self->warn;
241 0 return undef;
242 }
243  
244 #this will be returned
245 0 my @entries;
246  
247 #makes sure we have a entry directory
248 0 ▶ if (!-d $self->{edir}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $self->{"edir"}) 0 0 0
249 0 return @entries;
250 }
251  
252 #read what is present in the directory
253 0 my $dh;
254 0 ▶ if (!opendir($dh, $self->{edir})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (opendir $dh, $self->{"edir"}) 0 0 0
255 0 $self->{error}='5';
256 0 $self->{errorString}='Failed to open the directory "'.$self->{dir}.'"';
257 0 $self->warn;
258 0 return undef;
259 }
260 0 ▶ @entries=grep( { -f $self->{edir}.'/'.$_ && /$self->{helper}->{regex}/ } readdir($dh) );
Condition0%0/3
-f $self->{'edir'} . '/' . $_ && /$self->{'helper'}{'regex'}/
!ll&&!rl&&r
000
MC/DC0%0/2
-f $self->{'edir'} . '/' . $_ && /$self->{'helper'}{'regex'}/
-f $self->{'edir'} . '/' . $_ /$self->{'helper'}{'regex'}/
Truth table0%0/3
A && B
A= -f $self->{'edir'} . '/' . $_B= /$self->{'helper'}{'regex'}/
ABresult
0X0
100
111
261 0 close($dh);
262  
263 0 return @entries;
264 }
265  
266 =head2 published
267  
268 This returns a list of published or unpublished entries.
269  
270 One argument is accepted and that is the return value from
271 Toader::Entry->publishGet. If that is not defined, then '1'
272 is used.
273  
274 This will throw a warning for entries that can not be read,
275 it will not throw a error.
276  
277 my @published=$foo->published;
278 if ( $foo->error ){
279 warn( 'Error:'.$foo->error.': '.$foo->errorStrin );
280 }
281  
282 =cut
283  
284 0 ▶sub published{
Subroutine published: not called CC=8 SCAR=42.8
Pod documented
285 0 my $self=$_[0];
286 0 my $bool=$_[1];
287  
288 #blank any previous errors
289 0 ▶ if (!$self->errorblank) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
290 0 return undef;
291 }
292  
293 #set the default
294 0 ▶ if ( ! defined( $bool ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $bool) 0 0 0
295 0 $bool='1';
296 }
297  
298 #make sure the boolean is definitely zero or one
299 0 ▶ if ( $bool ){
Branch: 1 branch
BranchTrueFalseTotal
if ($bool) { } 0 0 0
300 0 $bool='1';
301 }else{
302 0 $bool='0';
303 }
304  
305 0 my @entries=$self->list;
306 0 ▶ if ( $self->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->error) 0 0 0
307 0 $self->warnString('Failed to list the entries');
308 0 return undef;
309 }
310
311 #checks for them all
312 0 my @published;
313 0 my $int=0;
314 0 ▶ while ( defined( $entries[$int] ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $entries[$int]) 0 0 0
315 0 my $entry=$self->read( $entries[$int] );
316  
317 0 ▶ if ( $self->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->error) { } 0 0 0
318 0 $self->warnString('Failed to read entry "'.$entries[$int].'"');
319 }else{
320 0 my $ispublished=$entry->publishGet;
321 0 ▶ if ( $ispublished eq $bool ){
Branch: 1 branch
BranchTrueFalseTotal
if ($ispublished eq $bool) 0 0 0
322 0 push( @published, $entries[$int] );
323 }
324 }
325  
326 0 $int++;
327 }
328  
329 0 return @published;
330 }
331  
332 =head2 read
333  
334 This reads a entry.
335  
336 One argument is taken and that is the entry name.
337  
338 my $entry=$foo->read( $entryName );
339 if ( $foo->error ){
340 warn( 'Error:'.$foo->error.': '.$foo->errorStrin );
341 }
342  
343 =cut
344  
345 0 ▶sub read{
Subroutine read: not called CC=7 SCAR=40.3
Pod documented
346 0 my $self=$_[0];
347 0 my $entry=$_[1];
348  
349 #blank any previous errors
350 0 ▶ if (!$self->errorblank) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
351 0 return undef;
352 }
353  
354 #make sure a directory has been set
355 0 ▶ if (!defined($self->{dir})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"dir"}) 0 0 0
356 0 $self->{error}='4';
357 0 $self->{errorString}='No directory has been set yet';
358 0 $self->warn;
359 0 return undef;
360 }
361  
362 #make sure it is valid and exists
363 0 my $returned=$self->{helper}->entryExists($entry);
364 0 ▶ if (!$returned) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($returned) 0 0 0
365 0 ▶ if ($self->{helper}->error){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'helper'}->error) { } 0 0 0
366 0 $self->{error}=7;
367 0 $self->{errorString}='The entry name is not valid';
368 }else {
369 0 $self->{error}=8;
370 0 $self->{errorString}='The entry does not exist';
371 }
372 0 $self->warn;
373 0 return undef;
374 }
375  
376 #the file that will be read
377 0 my $file=$self->{dir}.'/.toader/entries/'.$entry;
378  
379 #reads it
380 0 my $entryString;
381 my $fh;
382 0 ▶ if ( ! open($fh, '<', $file) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (open $fh, "<", $file) 0 0 0
383 0 $self->{error}=10;
384 0 $self->{errorString}='Unable to open "'.$file.'" for writing';
385 0 $self->warn;
386 0 return undef;
387 }
388 0 $entryString=join("", <$fh>);
389 0 close($fh);
390  
391 0 my $entryObj=Toader::Entry->newFromString($entryString, $self->{toader});
392 0 ▶ if ($entryObj->error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entryObj->error) 0 0 0
393 0 $self->{error}=11;
394 0 $self->{errorString}='Unable to generate a Toader::Entry object from ';
395 0 $self->warn;
396 0 return undef;
397 }
398  
399 #sets the directory
400 0 $entryObj->dirSet($self->{dir});
401 0 $entryObj->entryNameSet($entry);
402  
403 0 return $entryObj;
404 }
405  
406 =head2 remove
407  
408 This removes a entry. It will remove it from VCS and the cache as well.
409  
410 One argument is required and it is entry name.
411  
412 $foo->remove($entry);
413 if($foo->error){
414 warn('error: '.$foo->error.":".$foo->errorString);
415 }
416  
417 =cut
418  
419 0 ▶sub remove{
Subroutine remove: not called CC=12 SCAR=50.5
Pod documented
420 0 my $self=$_[0];
421 0 my $entry=$_[1];
422  
423 #blank any previous errors
424 0 ▶ if (!$self->errorblank) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
425 0 return undef;
426 }
427  
428 #makes sure a entry is specified
429 0 ▶ if (!defined($entry)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $entry) 0 0 0
430 0 $self->{error}='6';
431 0 $self->{errorString}='No entry specified';
432 0 $self->warn;
433 0 return undef;
434 }
435  
436 #make sure a directory has been set
437 0 ▶ if (!defined($self->{dir})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"dir"}) 0 0 0
438 0 $self->{error}='4';
439 0 $self->{errorString}='No directory has been set yet';
440 0 $self->warn;
441 0 return undef;
442 }
443  
444 #make sure it is valid and exists
445 0 my $returned=$self->{helper}->entryExists($entry);
446 0 ▶ if (!$returned) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($returned) 0 0 0
447 0 ▶ if ($self->{helper}->error){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'helper'}->error) { } 0 0 0
448 0 $self->{error}=7;
449 0 $self->{errorString}='The entry name is not valid';
450 }else {
451 0 $self->{error}=8;
452 0 $self->{errorString}='The entry does not exist';
453 }
454 0 $self->warn;
455 0 return undef;
456 }
457  
458 #saves this for later
459 0 my $file=$self->{edir}.'/'.$entry;
460
461 #unlinks it
462 0 ▶ if (!unlink( $file )) {
Branch: 1 branch
BranchTrueFalseTotal
unless (unlink $file) 0 0 0
463 0 $self->{error}=9;
464 0 $self->{errorString}='Failed to unlink the entry';
465 0 $self->warn;
466 0 return undef;
467 }
468  
469 #if VCS is not usable, return here
470 0 ▶ if ( ! $self->{VCSusable} ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"VCSusable"}) 0 0 0
471 0 return 1;
472 }
473
474 #if it is not under VCS, we have nothing to do
475 0 my $underVCS=$self->{vcs}->underVCS($file);
476 0 ▶ if ( $self->{vcs}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"vcs"}->error) 0 0 0
477 0 $self->{error}=15;
478 $self->{errorString}='Toader::VCS->underVCS errored. error="'.
479 0 $self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"';
480 0 $self->warn;
481 0 return undef;
482 }
483 0 ▶ if ( $underVCS ){
Branch: 1 branch
BranchTrueFalseTotal
if ($underVCS) 0 0 0
484 0 return 1;
485 }
486  
487 #delete it as if we reach here it is not under VCS and VCS is being used
488 0 $self->{vcs}->delete( $file );
489 0 ▶ if ( $self->{vcs}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"vcs"}->error) 0 0 0
490 0 $self->{error}=16;
491 $self->{errorString}='Toader::VCS->delete errored. error="'.
492 0 $self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"';
493 0 $self->warn;
494 0 return undef;
495 }
496  
497 #deletes the entry from the cache
498 0 $self->{cache}->deleteEntry( $entry );
499 0 ▶ if ( $self->{cache}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"cache"}->error) 0 0 0
500 0 $self->{error}=24;
501 $self->{errorString}='Toader::Entry::Cache->deleteEntry errored. error="'.
502 0 $self->{cache}->error.' errorString="'.$self->{cache}->errorString.'"';
503 0 $self->warn;
504 0 return undef;
505 }
506  
507 0 return 1;
508 }
509  
510 =head2 setDir
511  
512 This sets the directory the module will work on.
513  
514 One argument is taken and that is the path for the L<Toader> directory
515 in question.
516  
517 $foo->setDir($toaderDirectory)
518 if($foo->error){
519 warn('error: '.$foo->error.":".$foo->errorString);
520 }
521  
522 =cut
523  
524 0 ▶sub setDir{
Subroutine setDir: not called CC=6 SCAR=37.4
Pod documented
525 0 my $self=$_[0];
526 0 my $directory=$_[1];
527  
528 #blank any previous errors
529 0 ▶ if (!$self->errorblank) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
530 0 return undef;
531 }
532  
533 #makes sure a directory is specified
534 0 ▶ if (!defined($directory)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $directory) 0 0 0
535 0 $self->{error}='1';
536 0 $self->{errorString}='No directory specified';
537 0 $self->warn;
538 0 return undef;
539 }
540  
541 #cleans up the naming
542 0 my $pathHelper=Toader::pathHelper->new( $directory );
543 0 $directory=$pathHelper->cleanup( $directory );
544
545 #makes sure it is a directory
546 0 my $returned=$self->{isatd}->isaToaderDir($directory);
547 0 ▶ if(!$returned){
Branch: 1 branch
BranchTrueFalseTotal
unless ($returned) 0 0 0
548 0 ▶ if($self->{isatd}->error){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"isatd"}->error) 0 0 0
549 0 $self->{error}='2';
550 0 $self->{errorString}='isaToaderDir errored. error="'.$self->{isatd}->error.'" errorString="'.$self->{isatd}->errorString.'"';
551 0 $self->warn;
552 0 return undef;
553 }
554 0 $self->{error}='3';
555 0 $self->{errorString}='"'.$directory.'" is not a Toader directory';
556 0 $self->warn;
557 0 return undef;
558 }
559  
560 #it has been verified, so set it
561 0 $self->{dir}=$directory;
562 0 $self->{helper}->setDir($directory); #if the previous check has been worked, then this well
563 0 $self->{edir}=$self->{helper}->entryDirectory;
564  
565 #sets it for the cache
566 0 $self->{cache}->setDir( $directory );
567 0 ▶ if ( $self->{cache}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"cache"}->error) 0 0 0
568 0 $self->{error}=20;
569 $self->{errorString}='Toader::Entry::Cache->setDir errored. error="'.
570 0 $self->{cache}->error.'" errorString="'.$self->{cache}->errorString.'"';
571 0 $self->warn;
572 0 return undef;
573 }
574  
575 0 return 1;
576 }
577  
578 =head2 touch
579  
580 This updates the entry name to a newer one.
581  
582 =cut
583  
584 0 ▶sub touch{
Subroutine touch: not called CC=7 SCAR=40.3
Pod documented
585 0 my $self=$_[0];
586 0 my $entryName=$_[1];
587  
588 #blank any previous errors
589 0 ▶ if (!$self->errorblank) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
590 0 return undef;
591 }
592  
593 #make sure a directory has been set
594 0 ▶ if (!defined($self->{dir})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"dir"}) 0 0 0
595 0 $self->{error}='4';
596 0 $self->{errorString}='No directory has been set yet';
597 0 $self->warn;
598 0 return undef;
599 }
600  
601 0 my $entry=$self->read( $entryName );
602 0 ▶ if ( $self->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->error) 0 0 0
603 0 return undef;
604 }
605  
606 #sets a new entryname
607 0 $entry->entryNameSet;
608 0 ▶ if ( $entry->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->error) 0 0 0
609 0 $self->{error}=22;
610 0 $self->{errorString}='Toader::Entry->entyNameSet errored. error="'.
611 $entry->error.' errorString="'.$entry->errorString.'"';
612 0 $self->warn;
613 0 return undef;
614 }
615  
616 #writes it out
617 0 $entry->write;
618 0 ▶ if ( $entry->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->error) 0 0 0
619 0 $self->{error}=23;
620 0 $self->{errorString}='Toader::Entry->write errored. error="'.
621 $entry->error.' errorString="'.$entry->errorString.'"';
622 0 $self->warn;
623 0 return undef;
624 }
625  
626 #deletes the old one
627 0 $self->remove( $entryName );
628 0 ▶ if ( $self->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->error) 0 0 0
629 0 return undef;
630 }
631  
632 0 return 1;
633 }
634  
635 =head1 ERROR CODES/Flags
636  
637 =head2 1, noDirSpecified
638  
639 No directory specified.
640  
641 =head2 2, isaToaderDirErrored
642  
643 isaToaderDir errored.
644  
645 =head2 3, notAtoaderDir
646  
647 Is not a L<Toader> directory.
648  
649 =head2 4, noDirDefined
650  
651 No directory has been defined.
652  
653 =head2 5, openDirFailed
654  
655 Failed to open the directory.
656  
657 =head2 6, noEntrySpecified
658  
659 No entry specified.
660  
661 =head2 7, invalidEntryName
662  
663 The entry is not a valid name.
664  
665 =head2 8, entryDoesNotExist
666  
667 The entry does not exist.
668  
669 =head2 9, unlinkFailed
670  
671 Failed to unlink the entry.
672  
673 =head2 10, openEntryFailed
674  
675 Unable to open the entry file for reading.
676  
677 =head2 11, entryObjCreationFailed
678  
679 Generating a L<Toader::Entry> object from a alredy existing entry failed.
680  
681 =head2 12, notAtoaderObj
682  
683 The object specified is not a L<Toader> object.
684  
685 =head2 13, getVCSerrored
686  
687 L<Toader>->getVCS errored.
688  
689 =head2 14, VCSusableErrored
690  
691 L<Toader::VCS>->usable errored.
692  
693 =head2 15, underVCSerrored
694  
695 L<Toader::VCS>->underVCS errored.
696  
697 =head2 16, VCSdeleteErrored
698  
699 L<Toader::VCS>->delete errored.
700  
701 =head2 17, noToaderObj
702  
703 No L<Toader> object specified.
704  
705 =head2 18, helperNewErrored
706  
707 L<Toader::Entry::Helper>->new errored.
708  
709 =head2 19, cacheNewErrored
710  
711 L<Toader::Entry::Cache>->new errored.
712  
713 =head2 20, cacheDirSetErrored
714  
715 L<Toader::Entry::Cache>->setDir errored.
716  
717 =head2 21, cacheUpdateAllErrored
718  
719 L<Toader::Entry::Cache>->updateAll errored.
720  
721 =head2 22, entryNameSetErrored
722  
723 L<Toader::Entry>->entryNameSet errored.
724  
725 =head2 23, entryWriteErrored
726  
727 L<Toader::Entry>->write errored.
728  
729 =head2 24, cacheDeleteEntryErrored
730  
731 L<Toader::Entry::Cache>->deleteEntry errored.
732  
733 If this errors it means the cache is screwed in some manner and
734 needs reinited via L<Toader::Entry::Cache>->reinit.
735  
736 =head1 AUTHOR
737  
738 Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >>
739  
740  
741 =head1 BUGS
742  
743 Please report any bugs or feature requests to C<bug-toader at rt.cpan.org>, or through
744 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Toader>. I will be notified, and then you'll
745 automatically be notified of progress on your bug as I make changes.
746  
747  
748  
749  
750 =head1 SUPPORT
751  
752 You can find documentation for this module with the perldoc command.
753  
754 perldoc Toader::Entry::Manage
755  
756  
757 You can also look for information at:
758  
759 =over 4
760  
761 =item * RT: CPAN's request tracker
762  
763 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Toader>
764  
765 =item * AnnoCPAN: Annotated CPAN documentation
766  
767 L<http://annocpan.org/dist/Toader>
768  
769 =item * CPAN Ratings
770  
771 L<http://cpanratings.perl.org/d/Toader>
772  
773 =item * Search CPAN
774  
775 L<http://search.cpan.org/dist/Toader/>
776  
777 =back
778  
779  
780 =head1 ACKNOWLEDGEMENTS
781  
782  
783 =head1 LICENSE AND COPYRIGHT
784  
785 Copyright 2014 Zane C. Bowers-Hadley.
786  
787 This program is free software; you can redistribute it and/or modify it
788 under the terms of either: the GNU General Public License as published
789 by the Free Software Foundation; or the Artistic License.
790  
791 See http://dev.perl.org/licenses/ for more information.
792  
793  
794 =cut
795  
796 7 1; # End of Toader
« Toader/Templates.pm ↑ Summary Toader/Entry/Cache.pm »