| 1 | package Toader::Entry::Manage; | ||||||||||
| 2 | |||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 4 | ▶ | use Toader::isaToaderDir; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 4 | ▶ | use Toader::Entry::Helper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 4 | ▶ | use Toader::Entry; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 4 | ▶ | use base 'Error::Helper'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | =head1 NAME | ||||||||||
| 11 | |||||||||||
| 12 | Toader::Entry::Manage - Manage entries. | ||||||||||
| 13 | |||||||||||
| 14 | =head1 VERSION | ||||||||||
| 15 | |||||||||||
| 16 | Version 1.0.0 | ||||||||||
| 17 | |||||||||||
| 18 | =cut | ||||||||||
| 19 | |||||||||||
| 20 | 4 | our $VERSION = '1.0.0'; | |||||||||
| 21 | |||||||||||
| 22 | =head1 METHODS | ||||||||||
| 23 | |||||||||||
| 24 | =head2 new | ||||||||||
| 25 | |||||||||||
| 26 | This initiates the object. | ||||||||||
| 27 | |||||||||||
| 28 | One argument is required and it is a L<Toader> object. | ||||||||||
| 29 | |||||||||||
| 30 | After calling this, you should call setDir to set the directory to use. | ||||||||||
| 31 | |||||||||||
| 32 | my $foo = Toader::New->new( $toader ); | ||||||||||
| 33 | |||||||||||
| 34 | =cut | ||||||||||
| 35 | |||||||||||
| 36 | sub new{ | ||||||||||
| 37 | 0 | ▶ | my $toader=$_[1]; | ||||||||
|
Subroutine
new: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||
| 38 | |||||||||||
| 39 | 0 | my $self={ | |||||||||
| 40 | error=>undef, | ||||||||||
| 41 | errorString=>'', | ||||||||||
| 42 | dir=>undef, | ||||||||||
| 43 | edir=>undef, | ||||||||||
| 44 | isatd=>Toader::isaToaderDir->new, | ||||||||||
| 45 | helper=>undef, | ||||||||||
| 46 | VCSusable=>0, | ||||||||||
| 47 | toader=>undef, | ||||||||||
| 48 | errorExtra=>{ | ||||||||||
| 49 | flags=>{ | ||||||||||
| 50 | 1=>'noDirSpecified', | ||||||||||
| 51 | 2=>'isaToaderDirErrored', | ||||||||||
| 52 | 3=>'notAtoaderDir', | ||||||||||
| 53 | 4=>'noDirDefined', | ||||||||||
| 54 | 5=>'openDirFailed', | ||||||||||
| 55 | 6=>'noEntrySpecified', | ||||||||||
| 56 | 7=>'invalidEntryName', | ||||||||||
| 57 | 8=>'entryDoesNotExist', | ||||||||||
| 58 | 9=>'unlinkFailed', | ||||||||||
| 59 | 10=>'openEntryFailed', | ||||||||||
| 60 | 11=>'entryObjCreationFailed', | ||||||||||
| 61 | 12=>'notAtoaderObj', | ||||||||||
| 62 | 13=>'getVCSerrored', | ||||||||||
| 63 | 14=>'VCSusableErrored', | ||||||||||
| 64 | 15=>'underVCSerrored', | ||||||||||
| 65 | 16=>'VCSdeleteErrored', | ||||||||||
| 66 | 17=>'noToaderObj', | ||||||||||
| 67 | 18=>'helperNewErrored', | ||||||||||
| 68 | }, | ||||||||||
| 69 | }, | ||||||||||
| 70 | }; | ||||||||||
| 71 | 0 | bless $self; | |||||||||
| 72 | |||||||||||
| 73 | #if we have a Toader object, reel it in | ||||||||||
| 74 | 0 | ▶ | if ( ! defined( $toader ) ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 75 | 0 | $self->{perror}=1; | |||||||||
| 76 | 0 | $self->{error}=17; | |||||||||
| 77 | 0 | $self->{errorString}='No Toader object specified'; | |||||||||
| 78 | 0 | $self->warn; | |||||||||
| 79 | 0 | return $self; | |||||||||
| 80 | } | ||||||||||
| 81 | 0 | ▶ | if ( ref( $toader ) ne "Toader" ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 82 | 0 | $self->{perror}=1; | |||||||||
| 83 | 0 | $self->{error}=12; | |||||||||
| 84 | 0 | $self->{errorString}='The object specified is a "'.ref($toader).'"'; | |||||||||
| 85 | 0 | $self->warn; | |||||||||
| 86 | 0 | return $self; | |||||||||
| 87 | } | ||||||||||
| 88 | 0 | $self->{toader}=$toader; | |||||||||
| 89 | |||||||||||
| 90 | #init the helper | ||||||||||
| 91 | 0 | $self->{helper}=Toader::Entry::Helper->new( $self->{toader} ); | |||||||||
| 92 | 0 | ▶ | if ( $self->{helper}->error ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 93 | 0 | $self->{perror}=1; | |||||||||
| 94 | 0 | $self->{error}=18; | |||||||||
| 95 | $self->{errorString}='Failed to initialize Toader::Page::Helper.'. | ||||||||||
| 96 | 0 | 'error="'.$self->{helper}->error.'" errorString="'.$self->{helper}->errorString.'"'; | |||||||||
| 97 | 0 | $self->warn; | |||||||||
| 98 | 0 | return $self; | |||||||||
| 99 | } | ||||||||||
| 100 | |||||||||||
| 101 | |||||||||||
| 102 | #gets the Toader::VCS object | ||||||||||
| 103 | 0 | $self->{vcs}=$self->{toader}->getVCS; | |||||||||
| 104 | 0 | ▶ | if ( $toader->error ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 105 | 0 | $self->{perror}=1; | |||||||||
| 106 | 0 | $self->{error}=13; | |||||||||
| 107 | $self->{errorString}='Toader->getVCS errored. error="'. | ||||||||||
| 108 | 0 | $self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"'; | |||||||||
| 109 | 0 | $self->warn; | |||||||||
| 110 | 0 | return $self; | |||||||||
| 111 | } | ||||||||||
| 112 | |||||||||||
| 113 | #checks if VCS is usable | ||||||||||
| 114 | 0 | $self->{VCSusable}=$self->{vcs}->usable; | |||||||||
| 115 | 0 | ▶ | if ( $self->{vcs}->error ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 116 | 0 | $self->{perror}=1; | |||||||||
| 117 | 0 | $self->{error}=14; | |||||||||
| 118 | $self->{errorString}='Toader::VCS->usable errored. error="'. | ||||||||||
| 119 | 0 | $self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"'; | |||||||||
| 120 | 0 | $self->warn; | |||||||||
| 121 | 0 | return $self; | |||||||||
| 122 | } | ||||||||||
| 123 | |||||||||||
| 124 | 0 | return $self; | |||||||||
| 125 | } | ||||||||||
| 126 | |||||||||||
| 127 | =head2 list | ||||||||||
| 128 | |||||||||||
| 129 | This lists the available entries. | ||||||||||
| 130 | |||||||||||
| 131 | my @entries=$foo->list; | ||||||||||
| 132 | if($foo->error){ | ||||||||||
| 133 | warn('error: '.$foo->error.":".$foo->errorString); | ||||||||||
| 134 | } | ||||||||||
| 135 | |||||||||||
| 136 | =cut | ||||||||||
| 137 | |||||||||||
| 138 | sub list{ | ||||||||||
| 139 | 0 | ▶ | my $self=$_[0]; | ||||||||
|
Subroutine
list: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||
| 140 | |||||||||||
| 141 | #blank any previous errors | ||||||||||
| 142 | 0 | ▶ | if (!$self->errorblank) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 143 | 0 | return undef; | |||||||||
| 144 | } | ||||||||||
| 145 | |||||||||||
| 146 | #make sure a directory has been set | ||||||||||
| 147 | 0 | ▶ | if (!defined($self->{dir})) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 148 | 0 | $self->{error}='4'; | |||||||||
| 149 | 0 | $self->{errorString}='No directory has been set yet'; | |||||||||
| 150 | 0 | $self->warn; | |||||||||
| 151 | 0 | return undef; | |||||||||
| 152 | } | ||||||||||
| 153 | |||||||||||
| 154 | #this will be returned | ||||||||||
| 155 | 0 | my @entries; | |||||||||
| 156 | |||||||||||
| 157 | #makes sure we have a entry directory | ||||||||||
| 158 | 0 | ▶ | if (!-d $self->{edir}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 159 | 0 | return @entries; | |||||||||
| 160 | } | ||||||||||
| 161 | |||||||||||
| 162 | #read what is present in the directory | ||||||||||
| 163 | 0 | my $dh; | |||||||||
| 164 | 0 | ▶ | if (!opendir($dh, $self->{edir})) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 165 | 0 | $self->{error}='5'; | |||||||||
| 166 | 0 | $self->{errorString}='Failed to open the directory "'.$self->{dir}.'"'; | |||||||||
| 167 | 0 | $self->warn; | |||||||||
| 168 | 0 | return undef; | |||||||||
| 169 | } | ||||||||||
| 170 | 0 | ▶ | @entries=grep( { -f $self->{edir}.'/'.$_ && /$self->{helper}->{regex}/ } readdir($dh) ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 171 | 0 | close($dh); | |||||||||
| 172 | |||||||||||
| 173 | 0 | return @entries; | |||||||||
| 174 | } | ||||||||||
| 175 | |||||||||||
| 176 | =head2 published | ||||||||||
| 177 | |||||||||||
| 178 | This returns a list of published or unpublished entries. | ||||||||||
| 179 | |||||||||||
| 180 | One argument is accepted and that is the return value from | ||||||||||
| 181 | Toader::Entry->publishGet. If that is not defined, then '1' | ||||||||||
| 182 | is used. | ||||||||||
| 183 | |||||||||||
| 184 | This will throw a warning for entries that can not be read, | ||||||||||
| 185 | it will not throw a error. | ||||||||||
| 186 | |||||||||||
| 187 | my @published=$foo->published; | ||||||||||
| 188 | if ( $foo->error ){ | ||||||||||
| 189 | warn( 'Error:'.$foo->error.': '.$foo->errorStrin ); | ||||||||||
| 190 | } | ||||||||||
| 191 | |||||||||||
| 192 | =cut | ||||||||||
| 193 | |||||||||||
| 194 | sub published{ | ||||||||||
| 195 | 0 | ▶ | my $self=$_[0]; | ||||||||
|
Subroutine
published: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||
| 196 | 0 | my $bool=$_[1]; | |||||||||
| 197 | |||||||||||
| 198 | #blank any previous errors | ||||||||||
| 199 | 0 | ▶ | if (!$self->errorblank) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 200 | 0 | return undef; | |||||||||
| 201 | } | ||||||||||
| 202 | |||||||||||
| 203 | #set the default | ||||||||||
| 204 | 0 | ▶ | if ( ! defined( $bool ) ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 205 | 0 | $bool='1'; | |||||||||
| 206 | } | ||||||||||
| 207 | |||||||||||
| 208 | #make sure the boolean is definitely zero or one | ||||||||||
| 209 | 0 | ▶ | if ( $bool ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 210 | 0 | $bool='1'; | |||||||||
| 211 | }else{ | ||||||||||
| 212 | 0 | $bool='0'; | |||||||||
| 213 | } | ||||||||||
| 214 | |||||||||||
| 215 | 0 | my @entries=$self->list; | |||||||||
| 216 | 0 | ▶ | if ( $self->error ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 217 | 0 | $self->warnString('Failed to list the entries'); | |||||||||
| 218 | 0 | return undef; | |||||||||
| 219 | } | ||||||||||
| 220 | |||||||||||
| 221 | #checks for them all | ||||||||||
| 222 | 0 | my @published; | |||||||||
| 223 | 0 | my $int=0; | |||||||||
| 224 | 0 | ▶ | while ( defined( $entries[$int] ) ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 225 | 0 | my $entry=$self->read( $entries[$int] ); | |||||||||
| 226 | |||||||||||
| 227 | 0 | ▶ | if ( $self->error ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 228 | 0 | $self->warnString('Failed to read entry "'.$entries[$int].'"'); | |||||||||
| 229 | }else{ | ||||||||||
| 230 | 0 | my $ispublished=$entry->publishGet; | |||||||||
| 231 | 0 | ▶ | if ( $ispublished eq $bool ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 232 | 0 | push( @published, $entries[$int] ); | |||||||||
| 233 | } | ||||||||||
| 234 | } | ||||||||||
| 235 | |||||||||||
| 236 | 0 | $int++; | |||||||||
| 237 | } | ||||||||||
| 238 | |||||||||||
| 239 | 0 | return @published; | |||||||||
| 240 | } | ||||||||||
| 241 | |||||||||||
| 242 | =head2 read | ||||||||||
| 243 | |||||||||||
| 244 | This reads a entry. | ||||||||||
| 245 | |||||||||||
| 246 | One argument is taken and that is the entry name. | ||||||||||
| 247 | |||||||||||
| 248 | my $entry=$foo->read( $entryName ); | ||||||||||
| 249 | if ( $foo->error ){ | ||||||||||
| 250 | warn( 'Error:'.$foo->error.': '.$foo->errorStrin ); | ||||||||||
| 251 | } | ||||||||||
| 252 | |||||||||||
| 253 | =cut | ||||||||||
| 254 | |||||||||||
| 255 | sub read{ | ||||||||||
| 256 | 0 | ▶ | my $self=$_[0]; | ||||||||
|
Subroutine
read: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||
| 257 | 0 | my $entry=$_[1]; | |||||||||
| 258 | |||||||||||
| 259 | #blank any previous errors | ||||||||||
| 260 | 0 | ▶ | if (!$self->errorblank) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 261 | 0 | return undef; | |||||||||
| 262 | } | ||||||||||
| 263 | |||||||||||
| 264 | #make sure a directory has been set | ||||||||||
| 265 | 0 | ▶ | if (!defined($self->{dir})) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 266 | 0 | $self->{error}='4'; | |||||||||
| 267 | 0 | $self->{errorString}='No directory has been set yet'; | |||||||||
| 268 | 0 | $self->warn; | |||||||||
| 269 | 0 | return undef; | |||||||||
| 270 | } | ||||||||||
| 271 | |||||||||||
| 272 | #make sure it is valid and exists | ||||||||||
| 273 | 0 | my $returned=$self->{helper}->entryExists($entry); | |||||||||
| 274 | 0 | ▶ | if (!$returned) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 275 | 0 | ▶ | if ($self->{helper}->error){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 276 | 0 | $self->{error}=7; | |||||||||
| 277 | 0 | $self->{errorString}='The entry name is not valid'; | |||||||||
| 278 | }else { | ||||||||||
| 279 | 0 | $self->{error}=8; | |||||||||
| 280 | 0 | $self->{errorString}='The entry does not exist'; | |||||||||
| 281 | } | ||||||||||
| 282 | 0 | $self->warn; | |||||||||
| 283 | 0 | return undef; | |||||||||
| 284 | } | ||||||||||
| 285 | |||||||||||
| 286 | #the file that will be read | ||||||||||
| 287 | 0 | my $file=$self->{dir}.'/.toader/entries/'.$entry; | |||||||||
| 288 | |||||||||||
| 289 | #reads it | ||||||||||
| 290 | 0 | my $entryString; | |||||||||
| 291 | my $fh; | ||||||||||
| 292 | 0 | ▶ | if ( ! open($fh, '<', $file) ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 293 | 0 | $self->{error}=10; | |||||||||
| 294 | 0 | $self->{errorString}='Unable to open "'.$file.'" for writing'; | |||||||||
| 295 | 0 | $self->warn; | |||||||||
| 296 | 0 | return undef; | |||||||||
| 297 | } | ||||||||||
| 298 | 0 | $entryString=join("", <$fh>); | |||||||||
| 299 | 0 | close($fh); | |||||||||
| 300 | |||||||||||
| 301 | 0 | my $entryObj=Toader::Entry->newFromString($entryString, $self->{toader}); | |||||||||
| 302 | 0 | ▶ | if ($entryObj->error) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 303 | 0 | $self->{error}=11; | |||||||||
| 304 | 0 | $self->{errorString}='Unable to generate a Toader::Entry object from '; | |||||||||
| 305 | 0 | $self->warn; | |||||||||
| 306 | 0 | return undef; | |||||||||
| 307 | } | ||||||||||
| 308 | |||||||||||
| 309 | #sets the directory | ||||||||||
| 310 | 0 | $entryObj->dirSet($self->{dir}); | |||||||||
| 311 | 0 | $entryObj->entryNameSet($entry); | |||||||||
| 312 | |||||||||||
| 313 | 0 | return $entryObj; | |||||||||
| 314 | } | ||||||||||
| 315 | |||||||||||
| 316 | =head2 remove | ||||||||||
| 317 | |||||||||||
| 318 | This removes a entry. | ||||||||||
| 319 | |||||||||||
| 320 | One argument is required and it is entry name. | ||||||||||
| 321 | |||||||||||
| 322 | $foo->remove($entry); | ||||||||||
| 323 | if($foo->error){ | ||||||||||
| 324 | warn('error: '.$foo->error.":".$foo->errorString); | ||||||||||
| 325 | } | ||||||||||
| 326 | |||||||||||
| 327 | =cut | ||||||||||
| 328 | |||||||||||
| 329 | sub remove{ | ||||||||||
| 330 | 0 | ▶ | my $self=$_[0]; | ||||||||
|
Subroutine
remove: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||
| 331 | 0 | my $entry=$_[1]; | |||||||||
| 332 | |||||||||||
| 333 | #blank any previous errors | ||||||||||
| 334 | 0 | ▶ | if (!$self->errorblank) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 335 | 0 | return undef; | |||||||||
| 336 | } | ||||||||||
| 337 | |||||||||||
| 338 | #makes sure a entry is specified | ||||||||||
| 339 | 0 | ▶ | if (!defined($entry)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 340 | 0 | $self->{error}='6'; | |||||||||
| 341 | 0 | $self->{errorString}='No entry specified'; | |||||||||
| 342 | 0 | $self->warn; | |||||||||
| 343 | 0 | return undef; | |||||||||
| 344 | } | ||||||||||
| 345 | |||||||||||
| 346 | #make sure a directory has been set | ||||||||||
| 347 | 0 | ▶ | if (!defined($self->{dir})) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 348 | 0 | $self->{error}='4'; | |||||||||
| 349 | 0 | $self->{errorString}='No directory has been set yet'; | |||||||||
| 350 | 0 | $self->warn; | |||||||||
| 351 | 0 | return undef; | |||||||||
| 352 | } | ||||||||||
| 353 | |||||||||||
| 354 | #make sure it is valid and exists | ||||||||||
| 355 | 0 | my $returned=$self->{helper}->entryExists($entry); | |||||||||
| 356 | 0 | ▶ | if (!$returned) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 357 | 0 | ▶ | if ($self->{helper}->error){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 358 | 0 | $self->{error}=7; | |||||||||
| 359 | 0 | $self->{errorString}='The entry name is not valid'; | |||||||||
| 360 | }else { | ||||||||||
| 361 | 0 | $self->{error}=8; | |||||||||
| 362 | 0 | $self->{errorString}='The entry does not exist'; | |||||||||
| 363 | } | ||||||||||
| 364 | 0 | $self->warn; | |||||||||
| 365 | 0 | return undef; | |||||||||
| 366 | } | ||||||||||
| 367 | |||||||||||
| 368 | #saves this for later | ||||||||||
| 369 | 0 | my $file=$self->{edir}.'/'.$entry; | |||||||||
| 370 | |||||||||||
| 371 | #unlinks it | ||||||||||
| 372 | 0 | ▶ | if (!unlink( $file )) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 373 | 0 | $self->{error}=9; | |||||||||
| 374 | 0 | $self->{errorString}='Failed to unlink the entry'; | |||||||||
| 375 | 0 | $self->warn; | |||||||||
| 376 | 0 | return undef; | |||||||||
| 377 | } | ||||||||||
| 378 | |||||||||||
| 379 | #if VCS is not usable, return here | ||||||||||
| 380 | 0 | ▶ | if ( ! $self->{VCSusable} ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 381 | 0 | return 1; | |||||||||
| 382 | } | ||||||||||
| 383 | |||||||||||
| 384 | #if it is not under VCS, we have nothing to do | ||||||||||
| 385 | 0 | my $underVCS=$self->{vcs}->underVCS($file); | |||||||||
| 386 | 0 | ▶ | if ( $self->{vcs}->error ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 387 | 0 | $self->{error}=15; | |||||||||
| 388 | $self->{errorString}='Toader::VCS->underVCS errored. error="'. | ||||||||||
| 389 | 0 | $self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"'; | |||||||||
| 390 | 0 | $self->warn; | |||||||||
| 391 | 0 | return undef; | |||||||||
| 392 | } | ||||||||||
| 393 | 0 | ▶ | if ( $underVCS ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 394 | 0 | return 1; | |||||||||
| 395 | } | ||||||||||
| 396 | |||||||||||
| 397 | #delete it as if we reach here it is not under VCS and VCS is being used | ||||||||||
| 398 | 0 | $self->{vcs}->delete( $file ); | |||||||||
| 399 | 0 | ▶ | if ( $self->{vcs}->error ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 400 | 0 | $self->{error}=16; | |||||||||
| 401 | $self->{errorString}='Toader::VCS->delete errored. error="'. | ||||||||||
| 402 | 0 | $self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"'; | |||||||||
| 403 | 0 | $self->warn; | |||||||||
| 404 | 0 | return undef; | |||||||||
| 405 | } | ||||||||||
| 406 | |||||||||||
| 407 | 0 | return 1; | |||||||||
| 408 | } | ||||||||||
| 409 | |||||||||||
| 410 | =head2 setDir | ||||||||||
| 411 | |||||||||||
| 412 | This sets the directory the module will work on. | ||||||||||
| 413 | |||||||||||
| 414 | One argument is taken and that is the path for the L<Toader> directory | ||||||||||
| 415 | in question. | ||||||||||
| 416 | |||||||||||
| 417 | $foo->setDir($toaderDirectory) | ||||||||||
| 418 | if($foo->error){ | ||||||||||
| 419 | warn('error: '.$foo->error.":".$foo->errorString); | ||||||||||
| 420 | } | ||||||||||
| 421 | |||||||||||
| 422 | =cut | ||||||||||
| 423 | |||||||||||
| 424 | sub setDir{ | ||||||||||
| 425 | 0 | ▶ | my $self=$_[0]; | ||||||||
|
Subroutine
setDir: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 426 | 0 | my $directory=$_[1]; | |||||||||
| 427 | |||||||||||
| 428 | #blank any previous errors | ||||||||||
| 429 | 0 | ▶ | if (!$self->errorblank) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 430 | 0 | return undef; | |||||||||
| 431 | } | ||||||||||
| 432 | |||||||||||
| 433 | #makes sure a directory is specified | ||||||||||
| 434 | 0 | ▶ | if (!defined($directory)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 435 | 0 | $self->{error}='1'; | |||||||||
| 436 | 0 | $self->{errorString}='No directory specified'; | |||||||||
| 437 | 0 | $self->warn; | |||||||||
| 438 | 0 | return undef; | |||||||||
| 439 | } | ||||||||||
| 440 | |||||||||||
| 441 | #cleans up the naming | ||||||||||
| 442 | 0 | my $pathHelper=Toader::pathHelper->new( $directory ); | |||||||||
| 443 | 0 | $directory=$pathHelper->cleanup( $directory ); | |||||||||
| 444 | |||||||||||
| 445 | |||||||||||
| 446 | #makes sure it is a directory | ||||||||||
| 447 | 0 | my $returned=$self->{isatd}->isaToaderDir($directory); | |||||||||
| 448 | 0 | ▶ | if(!$returned){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 449 | 0 | ▶ | if($self->{isatd}->error){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 450 | 0 | $self->{error}='2'; | |||||||||
| 451 | 0 | $self->{errorString}='isaToaderDir errored. error="'.$self->{isatd}->error.'" errorString="'.$self->{isatd}->errorString.'"'; | |||||||||
| 452 | 0 | $self->warn; | |||||||||
| 453 | 0 | return undef; | |||||||||
| 454 | } | ||||||||||
| 455 | 0 | $self->{error}='3'; | |||||||||
| 456 | 0 | $self->{errorString}='"'.$directory.'" is not a Toader directory'; | |||||||||
| 457 | 0 | $self->warn; | |||||||||
| 458 | 0 | return undef; | |||||||||
| 459 | } | ||||||||||
| 460 | |||||||||||
| 461 | #it has been verified, so set it | ||||||||||
| 462 | 0 | $self->{dir}=$directory; | |||||||||
| 463 | 0 | $self->{helper}->setDir($directory); #if the previous check has been worked, then this well | |||||||||
| 464 | 0 | $self->{edir}=$self->{helper}->entryDirectory; | |||||||||
| 465 | |||||||||||
| 466 | 0 | return 1; | |||||||||
| 467 | } | ||||||||||
| 468 | |||||||||||
| 469 | =head1 ERROR CODES | ||||||||||
| 470 | |||||||||||
| 471 | =head2 1, noDirSpecified | ||||||||||
| 472 | |||||||||||
| 473 | No directory specified. | ||||||||||
| 474 | |||||||||||
| 475 | =head2 2, isaToaderDirErrored | ||||||||||
| 476 | |||||||||||
| 477 | isaToaderDir errored. | ||||||||||
| 478 | |||||||||||
| 479 | =head2 3, notAtoaderDir | ||||||||||
| 480 | |||||||||||
| 481 | Is not a L<Toader> directory. | ||||||||||
| 482 | |||||||||||
| 483 | =head2 4, noDirDefined | ||||||||||
| 484 | |||||||||||
| 485 | No directory has been defined. | ||||||||||
| 486 | |||||||||||
| 487 | =head2 5, openDirFailed | ||||||||||
| 488 | |||||||||||
| 489 | Failed to open the directory. | ||||||||||
| 490 | |||||||||||
| 491 | =head2 6, noEntrySpecified | ||||||||||
| 492 | |||||||||||
| 493 | No entry specified. | ||||||||||
| 494 | |||||||||||
| 495 | =head2 7, invalidEntryName | ||||||||||
| 496 | |||||||||||
| 497 | The entry is not a valid name. | ||||||||||
| 498 | |||||||||||
| 499 | =head2 8, entryDoesNotExist | ||||||||||
| 500 | |||||||||||
| 501 | The entry does not exist. | ||||||||||
| 502 | |||||||||||
| 503 | =head2 9, unlinkFailed | ||||||||||
| 504 | |||||||||||
| 505 | Failed to unlink the entry. | ||||||||||
| 506 | |||||||||||
| 507 | =head2 10, openEntryFailed | ||||||||||
| 508 | |||||||||||
| 509 | Unable to open the entry file for reading. | ||||||||||
| 510 | |||||||||||
| 511 | =head2 11, entryObjCreationFailed | ||||||||||
| 512 | |||||||||||
| 513 | Generating a L<Toader::Entry> object from a alredy existing entry failed. | ||||||||||
| 514 | |||||||||||
| 515 | =head2 12, notAtoaderObj | ||||||||||
| 516 | |||||||||||
| 517 | The object specified is not a L<Toader> object. | ||||||||||
| 518 | |||||||||||
| 519 | =head2 13, getVCSerrored | ||||||||||
| 520 | |||||||||||
| 521 | L<Toader>->getVCS errored. | ||||||||||
| 522 | |||||||||||
| 523 | =head2 14, VCSusableErrored | ||||||||||
| 524 | |||||||||||
| 525 | L<Toader::VCS>->usable errored. | ||||||||||
| 526 | |||||||||||
| 527 | =head2 15, underVCSerrored | ||||||||||
| 528 | |||||||||||
| 529 | L<Toader::VCS>->underVCS errored. | ||||||||||
| 530 | |||||||||||
| 531 | =head2 16, VCSdeleteErrored | ||||||||||
| 532 | |||||||||||
| 533 | L<Toader::VCS>->delete errored. | ||||||||||
| 534 | |||||||||||
| 535 | =head2 17, noToaderObj | ||||||||||
| 536 | |||||||||||
| 537 | No L<Toader> object specified. | ||||||||||
| 538 | |||||||||||
| 539 | =head2 18, helperNewErrored | ||||||||||
| 540 | |||||||||||
| 541 | L<Toader::Entry::Helper>->new errored. | ||||||||||
| 542 | |||||||||||
| 543 | =head1 AUTHOR | ||||||||||
| 544 | |||||||||||
| 545 | Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >> | ||||||||||
| 546 | |||||||||||
| 547 | |||||||||||
| 548 | =head1 BUGS | ||||||||||
| 549 | |||||||||||
| 550 | Please report any bugs or feature requests to C<bug-toader at rt.cpan.org>, or through | ||||||||||
| 551 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Toader>. I will be notified, and then you'll | ||||||||||
| 552 | automatically be notified of progress on your bug as I make changes. | ||||||||||
| 553 | |||||||||||
| 554 | |||||||||||
| 555 | |||||||||||
| 556 | |||||||||||
| 557 | =head1 SUPPORT | ||||||||||
| 558 | |||||||||||
| 559 | You can find documentation for this module with the perldoc command. | ||||||||||
| 560 | |||||||||||
| 561 | perldoc Toader::Entry::Manage | ||||||||||
| 562 | |||||||||||
| 563 | |||||||||||
| 564 | You can also look for information at: | ||||||||||
| 565 | |||||||||||
| 566 | =over 4 | ||||||||||
| 567 | |||||||||||
| 568 | =item * RT: CPAN's request tracker | ||||||||||
| 569 | |||||||||||
| 570 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Toader> | ||||||||||
| 571 | |||||||||||
| 572 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||
| 573 | |||||||||||
| 574 | L<http://annocpan.org/dist/Toader> | ||||||||||
| 575 | |||||||||||
| 576 | =item * CPAN Ratings | ||||||||||
| 577 | |||||||||||
| 578 | L<http://cpanratings.perl.org/d/Toader> | ||||||||||
| 579 | |||||||||||
| 580 | =item * Search CPAN | ||||||||||
| 581 | |||||||||||
| 582 | L<http://search.cpan.org/dist/Toader/> | ||||||||||
| 583 | |||||||||||
| 584 | =back | ||||||||||
| 585 | |||||||||||
| 586 | |||||||||||
| 587 | =head1 ACKNOWLEDGEMENTS | ||||||||||
| 588 | |||||||||||
| 589 | |||||||||||
| 590 | =head1 LICENSE AND COPYRIGHT | ||||||||||
| 591 | |||||||||||
| 592 | Copyright 2013 Zane C. Bowers-Hadley. | ||||||||||
| 593 | |||||||||||
| 594 | This program is free software; you can redistribute it and/or modify it | ||||||||||
| 595 | under the terms of either: the GNU General Public License as published | ||||||||||
| 596 | by the Free Software Foundation; or the Artistic License. | ||||||||||
| 597 | |||||||||||
| 598 | See http://dev.perl.org/licenses/ for more information. | ||||||||||
| 599 | |||||||||||
| 600 | |||||||||||
| 601 | =cut | ||||||||||
| 602 | |||||||||||
| 603 | 4 | 1; # End of Toader | |||||||||