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