Toader/Gallery.pm untested

filter: Statementstmt 0.0% 0 / 465 Branchbran 0.0% 0 / 222 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 36 Podpod 0.0% 0 / 31 totaltotal 0.0% 0 / 754 SCAR 94.5
CC
112
Cov
0%
usable
132.0
delConfig
72.0
dirSet
72.0
CRAP 12656.0
1 package Toader::Gallery;
2  
3 use warnings;
4 use strict;
5 use base 'Error::Helper';
6 use Toader::isaToaderDir;
7 use Config::Tiny;
8  
9 =head1 NAME
10  
11 Toader::Gallery - Handle image galleries.
12  
13 =head1 VERSION
14  
15 Version 0.1.0
16  
17 =cut
18  
19 our $VERSION = '0.1.0';
20  
21 =head1 METHODS
22  
23 =head2 new
24  
25 This initiates the object.
26  
27 There is one argument is required and this is a
28 L<Toader> object.
29  
30 my $foo = Toader::AutoDoc->new($toader);
31 if ( $foo->error ){
32 warn('error:'.$foo->error.': '.$foo->errorString);
33 }
34  
35 =cut
36  
37 sub new{
38 my $toader=$_[1];
39  
40 my $self={
41 error=>undef,
42 errorString=>'',
43 perror=>undef,
44 dir=>undef,
45 errorExtra=>{
46 flags=>{
47 1=>'noDirSpecified',
48 2=>'notAtoaderDir',
49 3=>'readConfigFailed',
50 4=>'noConfig',
51 5=>'nonNumericResolution',
52 6=>'noSrcPath',
53 7=>'noSrcURL',
54 8=>'noOutputPath',
55 9=>'noOutputURL',
56 10=>'dirAlreadyInit',
57 11=>'pathHelperErrored',
58 12=>'notAtoaderObj',
59 13=>'getVCSerrored',
60 14=>'VCSusableErrored',
61 15=>'underVCSerrored',
62 16=>'VCSaddErrored',
63 17=>'VCSdeleteErrored',
64 18=>'noToaderObj',
65 },
66 },
67 VCSusable=>0,
68 };
69 bless $self;
70  
71 #if we have a Toader object, reel it in
72 if ( ! defined( $toader ) ){
73 $self->{perror}=1;
74 $self->{error}=18;
75 $self->{errorString}='No Toader object specified';
76 $self->warn;
77 return $self;
78 }
79 if ( ref( $toader ) ne "Toader" ){
80 $self->{perror}=1;
81 $self->{error}=12;
82 $self->{errorString}='The object specified is a "'.ref($toader).'"';
83 $self->warn;
84 return $self;
85 }
86 $self->{toader}=$toader;
87  
88 #gets the Toader::VCS object
89 $self->{vcs}=$self->{toader}->getVCS;
90 if ( $toader->error ){
91 $self->{perror}=1;
92 $self->{error}=13;
93 $self->{errorString}='Toader->getVCS errored. error="'.
94 $self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"';
95 $self->warn;
96 return $self;
97 }
98
99 #checks if VCS is usable
100 $self->{VCSusable}=$self->{vcs}->usable;
101 if ( $self->{vcs}->error ){
102 $self->{perror}=1;
103 $self->{error}=14;
104 $self->{errorString}='Toader::VCS->usable errored. error="'.
105 $self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"';
106 $self->warn;
107 return $self;
108 }
109  
110 return $self;
111 }
112  
113 =head2 delConfig
114  
115 This removes a gallery config for a directory.
116  
117 =cut
118  
119 sub delConfig{
120 my $self=$_[0];
121  
122 if (!$self->errorblank){
123 return undef;
124 }
125  
126 if ( ! defined( $self->{config} ) ){
127 $self->{error}=4;
128 $self->{errorString}='No config for the current directory';
129 $self->warn;
130 return undef;
131 }
132  
133 my $file=$self->{dir}.'/.toader/gallery.ini';
134 if ( ! unlink( $file ) ){
135 $self->{error}=11;
136 $self->{errorString}='Failed to write the config out to "'.$file.'"';
137 $self->warn;
138 return undef;
139 }
140
141 #if VCS is not usable, stop here
142 if ( ! $self->{VCSusable} ){
143 return 1;
144 }
145  
146 #if it is under VCS, we have nothing to do
147 my $underVCS=$self->{vcs}->underVCS($file);
148 if ( $self->{vcs}->error ){
149 $self->{error}=15;
150 $self->{errorString}='Toader::VCS->underVCS errored. error="'.
151 $self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"';
152 $self->warn;
153 return undef;
154 }
155 if ( $underVCS ){
156 return 1;
157 }
158  
159 #delete it as if we reach here it is not under VCS and VCS is being used
160 $self->{vcs}->delete( $file );
161 if ( $self->{vcs}->error ){
162 $self->{error}=17;
163 $self->{errorString}='Toader::VCS->delete errored. error="'.
164 $self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"';
165 $self->warn;
166 return undef;
167 }
168  
169 return 1;
170 }
171  
172 =head2 dirGet
173  
174 This gets L<Toader> directory this entry is associated with.
175  
176 This will only error if a permanent error is set.
177  
178 This will return undef if no directory has been set.
179  
180 my $dir=$foo->dirGet;
181 if($foo->error){
182 warn('Error:'.$foo->error.': '.$foo->errorString);
183 }
184  
185 =cut
186  
187 sub dirGet{
188 my $self=$_[0];
189  
190 if (!$self->errorblank){
191 return undef;
192 }
193  
194 return $self->{dir};
195 }
196  
197 =head2 dirSet
198  
199 This sets L<Toader> directory this entry is associated with.
200  
201 One argument is taken and it is the L<Toader> directory to set it to.
202  
203 my $dir=$foo->dirSet($toaderDirectory);
204 if($foo->error){
205 warn('Error:'.$foo->error.': '.$foo->errorString);
206 }
207  
208 =cut
209  
210 sub dirSet{
211 my $self=$_[0];
212 my $dir=$_[1];
213  
214 if (!$self->errorblank){
215 return undef;
216 }
217  
218 #make sure a directory has been specified
219 if (!defined($dir)) {
220 $self->{error}=1;
221 $self->{errorString}='No directory specified.';
222 $self->warn;
223 return undef;
224 }
225  
226 #cleans up the naming
227 my $pathHelper=Toader::pathHelper->new($dir);
228 if ( $pathHelper->error ){
229 $self->{error}=11;
230 $self->{errorString}='Failed to initialize Toader::pathHelper';
231 $self->warn;
232 return undef;
233 }
234 $dir=$pathHelper->cleanup( $dir );
235  
236 #checks if the directory is Toader directory or not
237 my $isatd=Toader::isaToaderDir->new;
238 my $returned=$isatd->isaToaderDir($dir);
239 if (! $returned ) {
240 $self->{error}=2;
241 $self->{errorString}='"'.$dir.'" is not a Toader directory.';
242 $self->warn;
243 return undef;
244 }
245  
246 $self->{dir}=$dir;
247  
248 if ( defined( $self->{config} ) ){
249 delete( $self->{config} );
250 }
251
252 my $configfile=$self->{dir}.'/.toader/gallery.ini';
253 if ( -f $configfile ){
254 $self->{config}=Config::Tiny->read( $configfile );
255 if ( ! defined( $self->{config} ) ){
256 $self->{error}=3;
257 $self->{errorString}='Failed to read the gallery config, "'.$configfile.'",';
258 $self->warn;
259 return undef;
260 }
261 }
262  
263 return 1;
264 }
265  
266 =head2 init
267  
268 This is initializes the config for a directory. This is automatically
269 called if it has not been done so for a directory.
270  
271 =cut
272  
273 sub init{
274 my $self=$_[0];
275  
276 if (!$self->errorblank){
277 return undef;
278 }
279
280 if ( defined( $self->{config} ) ){
281 $self->{error}=10;
282 $self->{errorString}='"'.$self->{dir}.'" has already been initialized';
283 $self->warn;
284 return undef;
285 }
286  
287 $self->{config}=Config::Tiny->new;
288 $self->writeConfig;
289 if ( $self->error ){
290 $self->warnString('Failed to write the config out');
291 return undef;
292 }
293  
294 return 1;
295 }
296  
297 =head2 outputPathGet
298  
299 This returns the output path.
300  
301 my $outputPath=$foo->outputPathGet;
302 if ( $foo->error ){
303 warn( 'error:'.$foo->error.': '.$foo->errorString );
304 }
305  
306 =cut
307  
308 sub outputPathGet{
309 my $self=$_[0];
310  
311 if (!$self->errorblank){
312 return undef;
313 }
314  
315 if ( ! defined( $self->{config} ) ){
316 $self->{error}=4;
317 $self->{errorString}='No config for the current directory';
318 $self->warn;
319 return undef;
320 }
321  
322 return $self->{config}->{'_'}->{'outputPath'};
323 }
324  
325 =head2 outputPathSet
326  
327 This returns the output path.
328  
329 $foo->outputPathSet( $outputPath );
330 if ( $foo->error ){
331 warn( 'error:'.$foo->error.': '.$foo->errorString );
332 }
333  
334 =cut
335  
336 sub outputPathSet{
337 my $self=$_[0];
338 my $outputPath=$_[1];
339  
340 if (!$self->errorblank){
341 return undef;
342 }
343  
344 if ( ! defined( $self->{config} ) ){
345 $self->init;
346 if ( $self->error ){
347 $self->warnString('Failed to initialize the gallery config');
348 return undef;
349 }
350 }
351  
352 if ( ! defined( $outputPath ) ){
353 $self->{error}=8;
354 $self->{errorString}='No output path specified';
355 }
356  
357 $self->{config}->{'_'}->{'outputPath'}=$outputPath;
358  
359 $self->writeConfig;
360 if ( $self->error ){
361 $self->warnString('Failed to write the config out');
362 return undef;
363 }
364  
365 return 1;
366 }
367  
368 =head2 outputURLget
369  
370 This returns the output path.
371  
372 my $outputURL=$foo->outputURLget;
373 if ( $foo->error ){
374 warn( 'error:'.$foo->error.': '.$foo->errorString );
375 }
376  
377 =cut
378  
379 sub outputURLget{
380 my $self=$_[0];
381  
382 if (!$self->errorblank){
383 return undef;
384 }
385  
386 if ( ! defined( $self->{config} ) ){
387 $self->{error}=4;
388 $self->{errorString}='No config for the current directory';
389 $self->warn;
390 return undef;
391 }
392  
393 return $self->{config}->{'_'}->{'outputURL'};
394 }
395  
396 =head2 outputURLset
397  
398 This sets the output URL.
399  
400 my $outputURL=$foo->outputURLget;
401 if ( $foo->error ){
402 warn( 'error:'.$foo->error.': '.$foo->errorString );
403 }
404  
405 =cut
406  
407 sub outputURLset{
408 my $self=$_[0];
409 my $outputURL=$_[1];
410  
411 if (!$self->errorblank){
412 return undef;
413 }
414  
415 if ( ! defined( $self->{config} ) ){
416 $self->init;
417 if ( $self->error ){
418 $self->warnString('Failed to initialize the gallery config');
419 return undef;
420 }
421 }
422  
423 if ( ! defined( $outputURL ) ){
424 $self->{error}=9;
425 $self->{errorString}='No output URL specified';
426 $self->warn;
427 return undef;
428 }
429  
430 $self->{config}->{'_'}->{'outputURL'}=$outputURL;
431  
432 $self->writeConfig;
433 if ( $self->error ){
434 $self->warnString('Failed to write the config out');
435 return undef;
436 }
437  
438 return 1;
439 }
440  
441 =head2 srcPathGet
442  
443 This returns the source path.
444  
445 my $srcPath=$foo->srcPath;
446 if ( $foo->error ){
447 warn('error:'.$foo->error.': '.$foo->errorString);
448 }
449  
450 =cut
451  
452 sub srcPathGet{
453 my $self=$_[0];
454  
455 if (!$self->errorblank){
456 return undef;
457 }
458  
459 if ( ! defined( $self->{config} ) ){
460 $self->{error}=4;
461 $self->{errorString}='No config for the current directory';
462 $self->warn;
463 return undef;
464 }
465  
466 return $self->{config}->{'_'}->{'srcPath'};
467 }
468  
469 =head2 srcPathSet
470  
471 This sets the that to search for images.
472  
473 One argument is required and it is a path.
474  
475 $foo->srcPathSet( $srcPath );
476 if ( $foo->error ){
477 warn( 'error:'.$foo->error.': '.$foo->errorString );
478 }
479  
480 =cut
481  
482 sub srcPathSet{
483 my $self=$_[0];
484 my $srcPath=$_[1];
485  
486 if (!$self->errorblank){
487 return undef;
488 }
489  
490 if ( ! defined( $self->{config} ) ){
491 $self->init;
492 if ( $self->error ){
493 $self->warnString('Failed to initialize the gallery config');
494 return undef;
495 }
496 }
497  
498 if ( ! defined( $srcPath ) ){
499 $self->{error}=6;
500 $self->{errorString}='No source path specified';
501 }
502  
503 $self->{config}->{'_'}->{'srcPath'}=$srcPath;
504  
505 $self->writeConfig;
506 if ( $self->error ){
507 $self->warnString('Failed to write the config out');
508 return undef;
509 }
510  
511 return 1;
512 }
513  
514 =head2 srcURLget
515  
516 This gets the URL to use for the images.
517  
518 my $srcURLget=$foo->srcURLget;
519 if ( $foo->error ){
520 warn('error:'.$foo->error.': '.$foo->errorString);
521 }
522  
523 =cut
524  
525 sub srcURLget{
526 my $self=$_[0];
527  
528 if (!$self->errorblank){
529 return undef;
530 }
531  
532 if ( ! defined( $self->{config} ) ){
533 $self->{error}=4;
534 $self->{errorString}='No config for the current directory';
535 $self->warn;
536 return undef;
537 }
538  
539 return $self->{config}->{'_'}->{'srcURL'};
540 }
541  
542 =head2 srcURLset
543  
544 This sets the URL that is used for linking to the source images.
545  
546 $foo->srcURLset( $url );
547 if ( $foo->error ){
548 warn( 'error:'.$foo->error.': '.$foo->errorString );
549 }
550  
551 =cut
552  
553 sub srcURLset{
554 my $self=$_[0];
555 my $srcURL=$_[1];
556  
557 if (!$self->errorblank){
558 return undef;
559 }
560  
561 if ( ! defined( $self->{config} ) ){
562 $self->init;
563 if ( $self->error ){
564 $self->warnString('Failed to initialize the gallery config');
565 return undef;
566 }
567 }
568  
569 if ( ! defined( $srcURL ) ){
570 $self->{error}=7;
571 $self->{errorString}='Nothing specified for the source URL';
572 $self->warn;
573 return undef;
574 }
575  
576 $self->{config}->{'_'}->{'srcURL'}=$srcURL;
577  
578 $self->writeConfig;
579 if ( $self->error ){
580 $self->warnString('Failed to write the config out');
581 return undef;
582 }
583  
584 return 1;
585 }
586  
587 =head2 renderUpdateDetailsGet
588  
589 Returns if upon rendering it should update image details or not.
590  
591 The return value is a Perl boolean.
592  
593 my $update=$foo->renderUpdateDetailsGet;
594 if ( $foo->error ){
595 warn('error:'.$foo->error.': '.$foo->errorString);
596 }
597  
598 =cut
599  
600 sub renderUpdateDetailsGet{
601 my $self=$_[0];
602  
603 if (!$self->errorblank){
604 return undef;
605 }
606  
607 if ( ! defined( $self->{config} ) ){
608 $self->{error}=4;
609 $self->{errorString}='No config for the current directory';
610 $self->warn;
611 return undef;
612 }
613  
614 if ( ! defined( $self->{config}->{'_'}->{'renderUpdateDetails'} ) ){
615 return 0;
616 }
617  
618 return $self->{config}->{'_'}->{'renderUpdateDetails'};
619 }
620  
621 =head2 renderUpdateDetailsSet
622  
623 This sets wether or note Toader::Render::Gallery->render should
624 update the details or not.
625  
626 This takes a Perl boolean.
627  
628 $foo->renderUpdateDetailsGet( $update );
629 if ( $foo->error ){
630 warn('error:'.$foo->error.': '.$foo->errorString);
631 }
632  
633 =cut
634  
635 sub renderUpdateDetailsSet{
636 my $self=$_[0];
637 my $update=$_[1];
638  
639 if (!$self->errorblank){
640 return undef;
641 }
642  
643 if ( ! defined( $update ) ){
644 $update=0;
645 }
646  
647 if ( $update ){
648 $update=1;
649 }
650  
651 if ( ! defined( $self->{config} ) ){
652 $self->{error}=4;
653 $self->{errorString}='No config for the current directory';
654 $self->warn;
655 return undef;
656 }
657  
658 $self->{config}->{'_'}->{'renderUpdateDetails'}=$update;
659  
660 return 1;
661 }
662  
663 =head2 renderUpdateIndexesGet
664  
665 Returns if upon rendering it should update the indexes or not.
666  
667 The return value is a Perl boolean.
668  
669 my $update=$foo->renderUpdateIndexesGet;
670 if ( $foo->error ){
671 warn('error:'.$foo->error.': '.$foo->errorString);
672 }
673  
674 =cut
675  
676 sub renderUpdateIndexesGet{
677 my $self=$_[0];
678  
679 if (!$self->errorblank){
680 return undef;
681 }
682  
683 if ( ! defined( $self->{config} ) ){
684 $self->{error}=4;
685 $self->{errorString}='No config for the current directory';
686 $self->warn;
687 return undef;
688 }
689  
690 if ( ! defined( $self->{config}->{'_'}->{'renderUpdateIndexes'} ) ){
691 return 0;
692 }
693  
694 return $self->{config}->{'_'}->{'renderUpdateIndexes'};
695 }
696  
697 =head2 renderUpdateIndexesSet
698  
699 This sets wether or note Toader::Render::Gallery->render should
700 update the indexes or not.
701  
702 This takes a Perl boolean.
703  
704 $foo->renderUpdateIndexesGet( $update );
705 if ( $foo->error ){
706 warn('error:'.$foo->error.': '.$foo->errorString);
707 }
708  
709 =cut
710  
711 sub renderUpdateIndexesSet{
712 my $self=$_[0];
713 my $update=$_[1];
714  
715 if (!$self->errorblank){
716 return undef;
717 }
718  
719 if ( ! defined( $update ) ){
720 $update=0;
721 }
722  
723 if ( $update ){
724 $update=1;
725 }
726  
727 if ( ! defined( $self->{config} ) ){
728 $self->{error}=4;
729 $self->{errorString}='No config for the current directory';
730 $self->warn;
731 return undef;
732 }
733  
734 $self->{config}->{'_'}->{'renderUpdateIndexes'}=$update;
735  
736 return 1;
737 }
738  
739 =head2 renderUpdateScaledGet
740  
741 Returns if upon rendering it should update the scaled images or not.
742  
743 The return value is a Perl boolean.
744  
745 my $update=$foo->renderUpdateIndexesGet;
746 if ( $foo->error ){
747 warn('error:'.$foo->error.': '.$foo->errorString);
748 }
749  
750 =cut
751  
752 sub renderUpdateScaledGet{
753 my $self=$_[0];
754  
755 if (!$self->errorblank){
756 return undef;
757 }
758  
759 if ( ! defined( $self->{config} ) ){
760 $self->{error}=4;
761 $self->{errorString}='No config for the current directory';
762 $self->warn;
763 return undef;
764 }
765  
766 if ( ! defined( $self->{config}->{'_'}->{'renderUpdateScaled'} ) ){
767 return 0;
768 }
769  
770 return $self->{config}->{'_'}->{'renderUpdateScaled'};
771 }
772  
773 =head2 renderUpdateScaledSet
774  
775 This sets wether or note Toader::Render::Gallery->render should
776 update the scaled images or not.
777  
778 This takes a Perl boolean.
779  
780 $foo->renderUpdateIndexesGet( $update );
781 if ( $foo->error ){
782 warn('error:'.$foo->error.': '.$foo->errorString);
783 }
784  
785 =cut
786  
787 sub renderUpdateScaledSet{
788 my $self=$_[0];
789 my $update=$_[1];
790  
791 if (!$self->errorblank){
792 return undef;
793 }
794  
795 if ( ! defined( $update ) ){
796 $update=0;
797 }
798  
799 if ( $update ){
800 $update=1;
801 }
802  
803 if ( ! defined( $self->{config} ) ){
804 $self->{error}=4;
805 $self->{errorString}='No config for the current directory';
806 $self->warn;
807 return undef;
808 }
809  
810 $self->{config}->{'_'}->{'renderUpdateScaled'}=$update;
811  
812 return 1;
813 }
814  
815 =head2 resolutionSmallGet
816  
817 Returns the small resolution.
818  
819 my $smallRes=$foo->resolutionSmallGet;
820 if ( $foo->error ){
821 warn('error:'.$foo->error.': '.$foo->errorString);
822 }
823  
824 =cut
825  
826 sub resolutionSmallGet{
827 my $self=$_[0];
828  
829 if (!$self->errorblank){
830 return undef;
831 }
832  
833 if ( ! defined( $self->{config} ) ){
834 $self->{error}=4;
835 $self->{errorString}='No config for the current directory';
836 $self->warn;
837 return undef;
838 }
839  
840 if ( ! defined( $self->{config}->{'_'}->{'smallResolution'} ) ){
841 return 200;
842 }
843  
844 if ( $self->{config}->{'_'}->{'smallResolution'} !~ /^[0123456789]*$/ ){
845 $self->{error}=5;
846 $self->{errorString}='"'.$self->{config}->{'_'}->{'smallResolution'}.'" is not numeric';
847 $self->warn;
848 return undef;
849 }
850  
851 return $self->{config}->{'_'}->{'smallResolution'};
852 }
853  
854 =head2 resolutionSmallSet
855  
856 Sets the small resolution.
857  
858 One argument is taken and that is the maximum resolution for a
859 image. If not specified, it resets it to 200.
860  
861 my $smallRes=$foo->resolutionSmallSet( $resolution );
862 if ( $foo->error ){
863 warn('error:'.$foo->error.': '.$foo->errorString);
864 }
865  
866 =cut
867  
868 sub resolutionSmallSet{
869 my $self=$_[0];
870 my $res=$_[1];
871  
872 if (!$self->errorblank){
873 return undef;
874 }
875  
876 if ( ! defined( $self->{config} ) ){
877 $self->init;
878 if ( $self->error ){
879 $self->warnString('Failed to initialize the gallery config');
880 return undef;
881 }
882 }
883  
884 if ( ! defined( $res ) ){
885 $res=200;
886 }
887  
888 if ( $self->{config}->{'_'}->{'smallResolution'} !~ /^[0123456789]*$/ ){
889 $self->{error}=5;
890 $self->{errorString}='"'.$self->{config}->{'_'}->{'smallResolution'}.'" is not numeric';
891 $self->warn;
892 return undef;
893 }
894  
895 $self->{config}->{'_'}->{'smallResolution'}=$res;
896  
897 $self->writeConfig;
898 if ( $self->error ){
899 $self->warnString('Failed to write the config out');
900 return undef;
901 }
902  
903 return 1;
904 }
905  
906 =head2 resolutionLargeGet
907  
908 Returns the larg resolution.
909  
910 my $largeRes=$foo->resolutionLargeGet;
911 if ( $foo->error ){
912 warn('error:'.$foo->error.': '.$foo->errorString);
913 }
914  
915 =cut
916  
917 sub resolutionLargeGet{
918 my $self=$_[0];
919  
920 if (!$self->errorblank){
921 return undef;
922 }
923  
924 if ( ! defined( $self->{config} ) ){
925 $self->{error}=4;
926 $self->{errorString}='No config for the current directory';
927 $self->warn;
928 return undef;
929 }
930  
931 if ( ! defined( $self->{config}->{'_'}->{'smallResolution'} ) ){
932 return 1024;
933 }
934  
935 if ( $self->{config}->{'_'}->{'smallResolution'} !~ /^[0123456789]*$/ ){
936 $self->{error}=5;
937 $self->{errorString}='"'.$self->{config}->{'_'}->{'smallResolution'}.'" is not numeric';
938 $self->warn;
939 return undef;
940 }
941  
942 return $self->{config}->{'_'}->{'smallResolution'};
943 }
944  
945 =head2 resolutionLargeSet
946  
947 Returns the larg resolution.
948  
949 One argument is taken is the maximum resolution to use.
950 If not specified, it resets it to the default, 1024.
951  
952 $foo->resolutionLargeSet( $res );
953 if ( $foo->error ){
954 warn('error:'.$foo->error.': '.$foo->errorString);
955 }
956  
957 =cut
958  
959 sub resolutionLargeSet{
960 my $self=$_[0];
961 my $res=$_[1];
962  
963 if (!$self->errorblank){
964 return undef;
965 }
966  
967 if ( ! defined( $self->{config} ) ){
968 $self->init;
969 if ( $self->error ){
970 $self->warnString('Failed to initialize the gallery config');
971 return undef;
972 }
973 }
974  
975 if ( ! defined( $res ) ){
976 $res=1024;
977 }
978  
979 if ( $self->{config}->{'_'}->{'smallResolution'} !~ /^[0123456789]*$/ ){
980 $self->{error}=5;
981 $self->{errorString}='"'.$self->{config}->{'_'}->{'smallResolution'}.'" is not numeric';
982 $self->warn;
983 return undef;
984 }
985  
986 $self->{config}->{'_'}->{'smallResolution'}=$res;
987  
988 $self->writeConfig;
989 if ( $self->error ){
990 $self->warnString('Failed to write the config out');
991 return undef;
992 }
993  
994 return 1;
995 }
996  
997 =head2 usable
998  
999 This checks if the this object is usable for rendering or not.
1000  
1001 It does not check if the directories exist, other than the settings are
1002 specified.
1003  
1004 if ( ! $foo->usable ){
1005 print "This is not a renderable object currently... something is missing...\n";
1006 }
1007  
1008 =cut
1009  
1010 sub usable{
1011 my $self=$_[0];
1012  
1013 if (!$self->errorblank){
1014 return undef;
1015 }
1016  
1017 if ( ! defined( $self->{config} ) ){
1018 return undef;
1019 }
1020  
1021 if ( ! defined( $self->{outputPath} ) ) {
1022 return undef;
1023 }
1024  
1025 if ( ! defined( $self->{outputURL} ) ) {
1026 return undef;
1027 }
1028  
1029 if ( ! defined( $self->{srcPath} ) ) {
1030 return undef;
1031 }
1032  
1033 if ( ! defined( $self->{srcURL} ) ) {
1034 return undef;
1035 }
1036  
1037 if ( defined( $self->{smallResolution} ) ) {
1038 if ( $self->{smallResolution} !~ /^[0123456789]*/ ){
1039 return undef;
1040 }
1041 }
1042  
1043 if ( defined( $self->{largeResolution} ) ) {
1044 if ( $self->{largeResolution} !~ /^[0123456789]*/ ){
1045 return undef;
1046 }
1047 }
1048  
1049 return 1;
1050 }
1051  
1052 =head2 writeConfig
1053  
1054 This writes the config out.
1055  
1056 =cut
1057  
1058 sub writeConfig{
1059 my $self=$_[0];
1060 my $res=$_[1];
1061  
1062 if (!$self->errorblank){
1063 return undef;
1064 }
1065  
1066 if ( ! defined( $self->{config} ) ){
1067 $self->{error}=4;
1068 $self->{errorString}='No config for the current directory';
1069 $self->warn;
1070 return undef;
1071 }
1072  
1073 my $file=$self->{dir}.'/.toader/gallery.ini';
1074 if ( ! $self->{config}->write( $file ) ){
1075 $self->{error}=11;
1076 $self->{errorString}='Failed to write the config out to "'.$file.'"';
1077 $self->warn;
1078 return undef;
1079 }
1080  
1081 #if VCS is not usable, stop here
1082 if ( ! $self->{VCSusable} ){
1083 return 1;
1084 }
1085  
1086 #if it is under VCS, we have nothing to do
1087 my $underVCS=$self->{vcs}->underVCS($file);
1088 if ( $self->{vcs}->error ){
1089 $self->{error}=15;
1090 $self->{errorString}='Toader::VCS->underVCS errored. error="'.
1091 $self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"';
1092 $self->warn;
1093 return undef;
1094 }
1095 if ( $underVCS ){
1096 return 1;
1097 }
1098  
1099 #add it as if we reach here it is not under VCS and VCS is being used
1100 $self->{vcs}->add( $file );
1101 if ( $self->{vcs}->error ){
1102 $self->{error}=16;
1103 $self->{errorString}='Toader::VCS->add errored. error="'.
1104 $self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"';
1105 $self->warn;
1106 return undef;
1107 }
1108  
1109 return 1;
1110 }
1111  
1112 =head1 REQUIRED RENDERING METHODS
1113  
1114 The ones listed below are useless and are just included for
1115 compatibility reasons.
1116  
1117 filesDir
1118 renderDir
1119 toDir
1120  
1121 =head2 filesDir
1122  
1123 This returns the file directory for the object.
1124  
1125 This is not a full path, but a partial path that should
1126 be appended the directory current directory being outputted to.
1127  
1128 This returns '' as it is not used by this module. As for rendering,
1129 fullURL is set for L<Toader::Render::General>.
1130  
1131 =cut
1132  
1133 sub filesDir{
1134 my $self=$_[0];
1135  
1136 if (!$self->errorblank){
1137 return undef;
1138 }
1139  
1140 return '';
1141 }
1142  
1143 =head2 locationID
1144  
1145 This returns the location ID.
1146  
1147 This one requires the object to be initialized.
1148  
1149 =cut
1150  
1151 sub locationID{
1152 my $self=$_[0];
1153  
1154 if (!$self->errorblank){
1155 return undef;
1156 }
1157  
1158 return 'Gallery';
1159 }
1160  
1161 =head2 renderDir
1162  
1163 This is the directory that it will be rendered to.
1164  
1165 The base directory that will be used for rendering.
1166  
1167 This returns '' as it is not used by this module. As for rendering,
1168 fullURL is set for L<Toader::Render::General>.
1169  
1170 =cut
1171  
1172 sub renderDir{
1173 return '';
1174 }
1175  
1176 =head2 renderUsing
1177  
1178 This returns the module to use for rendering.
1179  
1180 my $module=$foo->renderUsing;
1181  
1182 =cut
1183  
1184 sub renderUsing{
1185 return 'Toader::Render::Gallery';
1186 }
1187  
1188 =head2 toaderRenderable
1189  
1190 This method returns true and marks it as being L<Toader>
1191 renderable.
1192  
1193 =cut
1194  
1195 sub toaderRenderable{
1196 return 1;
1197 }
1198  
1199 =head2 toDir
1200  
1201 This returns the directory that will return the directory
1202 that contains where this object should be rendered to.
1203  
1204 This is not a full path, but a partial path that should
1205 be appended the directory current directory being outputted to.
1206  
1207 This returns '' as it is not used by this module. As for rendering,
1208 fullURL is set for L<Toader::Render::General>.
1209  
1210 =cut
1211  
1212 sub toDir{
1213 my $self=$_[0];
1214  
1215 if (!$self->errorblank){
1216 return undef;
1217 }
1218  
1219 return '';
1220 }
1221  
1222 =head1 ERROR CODES
1223  
1224 =head2 1, noDirSpecified
1225  
1226 No directory specified.
1227  
1228 =head2 2, notAtoaderDir
1229  
1230 The directory is not a Toader directory.
1231  
1232 =head2 3, readConfigFailed
1233  
1234 Failed to read the gallery config.
1235  
1236 =head2 4, noConfig
1237  
1238 No config for this directory.
1239  
1240 =head2 5, nonNumericResolution
1241  
1242 The specified resolution is non-numeric.
1243  
1244 =head2 6, noSrcPath
1245  
1246 No source path specified.
1247  
1248 =head2 7, noSrcURL
1249  
1250 No source URL specified.
1251  
1252 =head2 8, noOutputPath
1253  
1254 No output path specified.
1255  
1256 =head2 9, noOutputURL
1257  
1258 No output URL specified.
1259  
1260 =head2 10, dirAlreadyInit
1261  
1262 The directory has already been initialized.
1263  
1264 =head2 11, pathHelperErrored
1265  
1266 Failed to initialize Toader::pathHelper.
1267  
1268 =head2 12, notAtoaderObj
1269  
1270 Not a Toader object.
1271  
1272 =head2 13, getVCSerrored
1273  
1274 L<Toader>->getVCS errored.
1275  
1276 =head2 14, VCSusableErrored
1277  
1278 L<Toader::VCS>->usable errored.
1279  
1280 =head2 15, underVCSerrored
1281  
1282 L<Toader::VCS>->underVCS errored.
1283  
1284 =head2 16, VCSaddErrored
1285  
1286 L<Toader::VCS>->add errored.
1287  
1288 =head2 17, VCSdeleteErrored
1289  
1290 L<Toader::VCS>->delete errored.
1291  
1292 =head2 18, noToaderObj
1293  
1294 Nothing passed for a L<Toader> object.
1295  
1296 =head1 AUTHOR
1297  
1298 Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >>
1299  
1300 =head1 BUGS
1301  
1302 Please report any bugs or feature requests to C<bug-toader at rt.cpan.org>, or through
1303 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Toader>. I will be notified, and then you'll
1304 automatically be notified of progress on your bug as I make changes.
1305  
1306 =head1 SUPPORT
1307  
1308 You can find documentation for this module with the perldoc command.
1309  
1310 perldoc Toader::AutoDoc
1311  
1312  
1313 You can also look for information at:
1314  
1315 =over 4
1316  
1317 =item * RT: CPAN's request tracker
1318  
1319 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Toader>
1320  
1321 =item * AnnoCPAN: Annotated CPAN documentation
1322  
1323 L<http://annocpan.org/dist/Toader>
1324  
1325 =item * CPAN Ratings
1326  
1327 L<http://cpanratings.perl.org/d/Toader>
1328  
1329 =item * Search CPAN
1330  
1331 L<http://search.cpan.org/dist/Toader/>
1332  
1333 =back
1334  
1335  
1336 =head1 ACKNOWLEDGEMENTS
1337  
1338  
1339 =head1 LICENSE AND COPYRIGHT
1340  
1341 Copyright 2011 Zane C. Bowers-Hadley.
1342  
1343 This program is free software; you can redistribute it and/or modify it
1344 under the terms of either: the GNU General Public License as published
1345 by the Free Software Foundation; or the Artistic License.
1346  
1347 See http://dev.perl.org/licenses/ for more information.
1348  
1349  
1350 =cut
1351  
1352 1; # End of Toader::Gallery