1package Toader::isaToaderDir; 2 3use warnings; 4use strict; 5use base 'Error::Helper'; 6 7=head1 NAME 8 9Toader::isaToaderDir - Checks if a directory has Toader support or not. 10 11=head1 VERSION 12 13Version 0.1.0 14 15=cut 16 17our $VERSION = '0.1.0'; 18 19 20=head1 SYNOPSIS 21 22 use Toader::isaToaderDir; 23 24 my $foo = Toader::isaToaderDir->new(); 25 26 my $returned=$foo->isaToaderDir($directory); 27 if(!$returned){ 28 if($foo->error){ 29 warn('Error '.$foo->error.': '.$foo->errorString); 30 } 31 }else{ 32 print "It is a Toader directory"; 33 } 34 35=head1 METHODS 36 37=head2 new 38 39This initiates the object. 40 41 my $foo = Toader::isaToaderDir->new(); 42 43=cut 44 45sub new{ 46 my $self={ 47 error=>undef, 48 errorString=>'', 49 perror=>undef, 50 errorExtra=>{ 51 flags=>{ 52 1=>'noDirSpecified', 53 2=>'notAdir', 54 }, 55 }, 56 }; 57 bless $self; 58 59 return $self; 60} 61 62=head2 isaToaderDir 63 64This checks if a directory is a L<Toader> directory. 65 66If it is it returns true, it is a L<Toader> directory. 67 68A error will only be generated if a directory is not specified 69or it does not exist. 70 71 my $returned=$foo->isaToaderDir($directory); 72 if(!$returned){ 73 if($foo->error){ 74 warn('Error '.$foo->error.': '.$foo->errorString); 75 } 76 }else{ 77 print "It is a Toader directory"; 78 } 79 80=cut 81 82sub isaToaderDir{ 83 my $self=$_[0]; 84 my $dir=$_[1]; 85 86 #blank any previous errors 87 if(!$self->errorblank){ 88 return undef; 89 } 90 91 # Makes sure a directory is specified. 92 if (!defined( $dir )) { 93 $self->{error}=1; 94 $self->{errorString}='No directory defined'; 95 return undef; 96 } 97 98 # Make sure the what is a directory. 99 if (! -d $dir ) { 100 $self->{error}=2; 101 $self->{errorString}='The specified item is not a directory'; 102 return undef; 103 } 104 105 #makes sure the required toader directory exists 106 if (! -d $dir.'/.toader') { 107 return undef; 108 } 109 110 return 1; 111} 112 113=head1 ERROR CODES 114 115=head2 1, noDirSpecified 116 117No directory specified. 118 119=head2 2, notAdir 120 121Not a directory. 122 123=head1 AUTHOR 124 125Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >> 126 127=head1 BUGS 128 129Please report any bugs or feature requests to C<bug-toader at rt.cpan.org>, or through 130the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Toader>. I will be notified, and then you'll 131automatically be notified of progress on your bug as I make changes. 132 133 134 135 136=head1 SUPPORT 137 138You can find documentation for this module with the perldoc command. 139 140 perldoc Toader::isaToaderDir 141 142 143You can also look for information at: 144 145=over 4 146 147=item * RT: CPAN's request tracker 148 149L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Toader> 150 151=item * AnnoCPAN: Annotated CPAN documentation 152 153L<http://annocpan.org/dist/Toader> 154 155=item * CPAN Ratings 156 157L<http://cpanratings.perl.org/d/Toader> 158 159=item * Search CPAN 160 161L<http://search.cpan.org/dist/Toader/> 162 163=back 164 165 166=head1 ACKNOWLEDGEMENTS 167 168 169=head1 LICENSE AND COPYRIGHT 170 171Copyright 2013 Zane C. Bowers-Hadley. 172 173This program is free software; you can redistribute it and/or modify it 174under the terms of either: the GNU General Public License as published 175by the Free Software Foundation; or the Artistic License. 176 177See http://dev.perl.org/licenses/ for more information. 178 179 180=cut 181 1821; # End of Toader::isaToaderDir 183