blib/lib/Mail/Maildir/Is/A.pm

filter: Statementstmt 17.0% 8 / 47 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 2 / 6 Podpod 100% 4 / 4 totaltotal 19.7% 14 / 71 CC 8 SCAR 34.5
CC
8
Cov
13%
isAmaildir
56.0
new
6.0
error
2.0
CRAP 31.5
↑ Summary
1 package Mail::Maildir::Is::A;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 Mail::Maildir::Is::A - Checks if a directory is a mail directory or not.
9  
10 =head1 VERSION
11  
12 Version 0.0.0
13  
14 =cut
15  
16 2 our $VERSION = '0.0.0';
17  
18 =head1 METHODS
19  
20 =head2 new
21  
22 Initiates the object.
23  
24 my $foo=Mail::Maildir::Is::A->new;
25  
26 =cut
27  
28 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
29 0 my %args;
30 0 ▶ if(defined($_[1])){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[1]) 0 0 0
31 0 %args= %{$_[1]};
32 };
33 0 my $method='new';
34
35 0 my $self={
36 error=>undef,
37 errorString=>'',
38 module=>'Mail-Maildir-Is-a',
39 };
40 0 bless $self;
41  
42 0 return $self;
43 }
44  
45 =head2 isAmaildir
46  
47 This returns true or false based on if specified directory is a maildir
48 or not.
49  
50 my $returned=$foo->isAmaildir('/somedir');
51 if($foo->error){
52 warn('Error:'.$self->error.':'.$self->errorString);
53 }
54 if(! $returned){
55 print "It is a maildir."\n";
56 }
57  
58 =cut
59  
60 0 ▶sub isAmaildir{
Subroutine isAmaildir: not called CC=7 SCAR=40.3
Pod documented
61 0 my $self=$_[0];
62 0 my $dir=$_[1];
63 0 my $method='isAmaildir';
64  
65 0 $self->errorblank;
66  
67 0 ▶ if (!defined( $dir )) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $dir) 0 0 0
68 0 $self->{error}=3;
69 0 $self->{errorString}='No directory specified';
70 0 warn($self->{module}.' ',$method.':'.$self->error.': '.$self->{errorString});
71 0 return undef;
72 }
73  
74 0 ▶ if (! -e $dir) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $dir) 0 0 0
75 0 $self->{error}=1;
76 0 $self->{errorString}='The specified item does not exist';
77 0 warn($self->{module}.' ',$method.':'.$self->error.': '.$self->{errorString});
78 0 return undef;
79 }
80  
81 0 ▶ if (! -d $dir) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $dir) 0 0 0
82 0 $self->{error}=2;
83 0 $self->{errorString}='The specified item does not exist';
84 0 warn($self->{module}.' ',$method.':'.$self->error.': '.$self->{errorString});
85 0 return undef;
86 }
87  
88 #makes sure all the directories exist
89 0 ▶ if (! -d $dir.'/new/') {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $dir . '/new/') 0 0 0
90 0 return undef;
91 }
92 0 ▶ if (! -d $dir.'/cur/') {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $dir . '/cur/') 0 0 0
93 0 return undef;
94 }
95 0 ▶ if (! -d $dir.'/tmp/') {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $dir . '/tmp/') 0 0 0
96 0 return undef;
97 }
98  
99 0 return 1;
100 }
101  
102 =head1 ERROR HANDLING METHODS
103  
104 =head2 error
105  
106 Returns the current error code and true if there is an error.
107  
108 If there is no error, undef is returned.
109  
110 my $error=$foo->error;
111 if($error){
112 print 'error code: '.$error."\n";
113 }
114  
115 =cut
116  
117 0 ▶sub error{
Subroutine error: not called CC=1 SCAR=6.9
Pod documented
118 0 return $_[0]->{error};
119 }
120  
121 =head2 errorblank
122  
123 This blanks the error storage and is only meant for internal usage.
124  
125 It does the following.
126  
127 $zconf->{error}=undef;
128 $zconf->{errorString}="";
129  
130 =cut
131  
132 #blanks the error flags
133 0 ▶sub errorblank{
Subroutine errorblank: not called CC=1 SCAR=6.9
Pod documented
134 0 my $self=$_[0];
135
136 0 $self->{error}=undef;
137 0 $self->{errorString}="";
138
139 0 return 1;
140 };
141  
142 =head1 ERROR CODES
143  
144 =head2 1
145  
146 The item does not exist.
147  
148 =head2 2
149  
150 The item is not a directory.
151  
152 =head2 3
153  
154 No directory specified.
155  
156 =head1 AUTHOR
157  
158 Zane C. Bowers, C<< <vvelox at vvelox.net> >>
159  
160 =head1 BUGS
161  
162 Please report any bugs or feature requests to C<bug-mail-maildir-is-a at rt.cpan.org>, or through
163 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mail-Maildir-Is-A>. I will be notified, and then you'll
164 automatically be notified of progress on your bug as I make changes.
165  
166  
167  
168  
169 =head1 SUPPORT
170  
171 You can find documentation for this module with the perldoc command.
172  
173 perldoc Mail::Maildir::Is::A
174  
175  
176 You can also look for information at:
177  
178 =over 4
179  
180 =item * RT: CPAN's request tracker
181  
182 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Mail-Maildir-Is-A>
183  
184 =item * AnnoCPAN: Annotated CPAN documentation
185  
186 L<http://annocpan.org/dist/Mail-Maildir-Is-A>
187  
188 =item * CPAN Ratings
189  
190 L<http://cpanratings.perl.org/d/Mail-Maildir-Is-A>
191  
192 =item * Search CPAN
193  
194 L<http://search.cpan.org/dist/Mail-Maildir-Is-A/>
195  
196 =back
197  
198  
199 =head1 ACKNOWLEDGEMENTS
200  
201  
202 =head1 LICENSE AND COPYRIGHT
203  
204 Copyright 2010 Zane C. Bowers.
205  
206 This program is free software; you can redistribute it and/or modify it
207 under the terms of either: the GNU General Public License as published
208 by the Free Software Foundation; or the Artistic License.
209  
210 See http://dev.perl.org/licenses/ for more information.
211  
212  
213 =cut
214  
215 2 1; # End of Mail::Maildir::Is::A
↑ Summary