Folder/Maildir.pm

filter: Statementstmt 100% 39 / 39 Branchbran 62.5% 10 / 16 Conditioncond 44.4% 4 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 78.4% 62 / 79 CC 14 SCAR 21.2
CC
14
Cov
83%
_what_is_there
14.0
next_message
4.1
BEGIN
1.0
CRAP 8.4
« Folder/Ezmlm.pm ↑ Summary Folder/MH.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Email::Folder::Maildir;
4 # ABSTRACT: reads raw RFC822 mails from a maildir
5 1 $Email::Folder::Maildir::VERSION = '0.859';
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Email::Folder::Reader;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use parent 'Email::Folder::Reader';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 #pod =head1 SYNOPSIS
12 #pod
13 #pod This isa Email::Folder::Reader - read about its API there.
14 #pod
15 #pod =head1 DESCRIPTION
16 #pod
17 #pod Does exactly what it says on the tin - fetches raw RFC822 mails from a
18 #pod maildir.
19 #pod
20 #pod The maildir format is described at
21 #pod L<http://www.qmail.org/man/man5/maildir.html>
22 #pod
23 #pod =cut
24  
25 sub _what_is_there {
26 1 ▶ my $self = shift;
Subroutine _what_is_there: called CC=11 SCAR=26.4
27 1 my $dir = $self->{_file};
28  
29 1 ▶ croak "$dir does not exist" unless (-e $dir);
Branch: 1 branch
BranchTrueFalseTotal
unless -e $dir 0 1 1
30 1 ▶ croak "$dir is not a maildir" unless (-d $dir);
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dir 0 1 1
31 1 ▶ croak "$dir is not a maildir" unless (-e "$dir/cur" && -d "$dir/cur");
Branch: 1 branch
BranchTrueFalseTotal
unless -e "$dir/cur" and -d "$dir/cur" 0 1 1
Condition33%1/3
-e "$dir/cur" and -d "$dir/cur"
!ll&&!rl&&r
001
MC/DC0%0/2
-e "$dir/cur" and -d "$dir/cur"
-e "$dir/cur" -d "$dir/cur"
Truth table33%1/3
A and B
A= -e "$dir/cur"B= -d "$dir/cur"
ABresult
0X0
100
111
32 1 ▶ croak "$dir is not a maildir" unless (-e "$dir/new" && -d "$dir/new");
Branch: 1 branch
BranchTrueFalseTotal
unless -e "$dir/new" and -d "$dir/new" 0 1 1
Condition33%1/3
-e "$dir/new" and -d "$dir/new"
!ll&&!rl&&r
001
MC/DC0%0/2
-e "$dir/new" and -d "$dir/new"
-e "$dir/new" -d "$dir/new"
Truth table33%1/3
A and B
A= -e "$dir/new"B= -d "$dir/new"
ABresult
0X0
100
111
33  
34 1 my @messages;
35 # ignore the tmp directory although the spec
36 # says to delete anything in tmp/ that is older than 36 hours
37 1 for my $sub (qw(new cur)) {
38 2 ▶ opendir(DIR,"$dir/$sub") or croak "Could not open '$dir/$sub'";
Branch: 1 branch
BranchTrueFalseTotal
opendir DIR, "$dir/$sub" or croak("Could not open '$dir/${sub}'") 0 2 2
39 2 foreach my $file (readdir DIR) {
40 14 ▶ next if $file =~ /^\./; # as suggested by DJB
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ /^\./ 4 10 14
41 10 push @messages, "$dir/$sub/$file";
42 }
43 }
44  
45 1 $self->{_messages} = \@messages;
46 }
47  
48 sub next_message {
49 11 ▶ my $self = shift;
Subroutine next_message: called CC=4 SCAR=14.0
Pod documented
50 11 ▶ my $what = $self->{_messages} || $self->_what_is_there;
Condition66%2/3
$self->{'_messages'} || $self->_what_is_there
l!l&&r!l&&!r
1010
MC/DC0%0/2
$self->{'_messages'} || $self->_what_is_there
$self->{'_messages'} $self->_what_is_there
Truth table66%2/3
A || B
A= $self->{'_messages'}B= $self->_what_is_there
ABresult
1X1
011
000
51  
52 11 ▶ my $file = shift @$what or return;
Branch: 1 branch
BranchTrueFalseTotal
my $file = shift @$what or return 1 10 11
53 10 local *FILE;
54 10 ▶ open FILE, $file or croak "couldn't open '$file' for reading";
Branch: 1 branch
BranchTrueFalseTotal
open FILE, $file or croak("couldn't open '${file}' for reading") 0 10 10
55 10 join '', <FILE>;
56 }
57  
58 1 1;
59  
60 __END__
« Folder/Ezmlm.pm ↑ Summary Folder/MH.pm »