| 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
| |||||||||||||||||||||||||||||
| 30 | 1 | ▶ | croak "$dir is not a maildir" unless (-d $dir); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 1 | ▶ | croak "$dir is not a maildir" unless (-e "$dir/cur" && -d "$dir/cur"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-e "$dir/cur" and -d "$dir/cur"
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"
| |||||||||||||||||||||||||||||
| 32 | 1 | ▶ | croak "$dir is not a maildir" unless (-e "$dir/new" && -d "$dir/new"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-e "$dir/new" and -d "$dir/new"
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"
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 39 | 2 | foreach my $file (readdir DIR) { | |||||||||||||||||||||||||||
| 40 | 14 | ▶ | next if $file =~ /^\./; # as suggested by DJB | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
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
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 11 | ▶ | my $file = shift @$what or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 10 | local *FILE; | |||||||||||||||||||||||||||
| 54 | 10 | ▶ | open FILE, $file or croak "couldn't open '$file' for reading"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 10 | join '', <FILE>; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 1 | 1; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | __END__ | ||||||||||||||||||||||||||||