line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
2552
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
113
|
|
2
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
196
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: read all the messages from a folder as Email::Simple objects |
4
|
|
|
|
|
|
|
package Email::Folder; |
5
|
|
|
|
|
|
|
{ |
6
|
|
|
|
|
|
|
$Email::Folder::VERSION = '0.858'; |
7
|
|
|
|
|
|
|
} |
8
|
3
|
|
|
3
|
|
17
|
use Carp; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
239
|
|
9
|
3
|
|
|
3
|
|
2562
|
use Email::Simple; |
|
3
|
|
|
|
|
18138
|
|
|
3
|
|
|
|
|
116
|
|
10
|
3
|
|
|
3
|
|
2577
|
use Email::FolderType 0.6 qw/folder_type/; |
|
3
|
|
|
|
|
38249
|
|
|
3
|
|
|
|
|
1174
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
11
|
|
|
11
|
1
|
13422
|
my $class = shift; |
15
|
11
|
|
33
|
|
|
45
|
my $folder = shift || carp "Must provide a folder name\n"; |
16
|
11
|
|
|
|
|
36
|
my %self = @_; |
17
|
|
|
|
|
|
|
|
18
|
11
|
|
|
|
|
18
|
my $reader; |
19
|
|
|
|
|
|
|
|
20
|
11
|
50
|
|
|
|
36
|
if ($self{reader}) { |
21
|
0
|
|
|
|
|
0
|
$reader = $self{reader}; |
22
|
|
|
|
|
|
|
} else { |
23
|
11
|
|
|
|
|
39
|
$reader = "Email::Folder::".folder_type($folder); |
24
|
|
|
|
|
|
|
} |
25
|
11
|
50
|
|
|
|
48410
|
eval "require $reader" or die $@; |
26
|
|
|
|
|
|
|
|
27
|
11
|
|
|
|
|
118
|
$self{_folder} = $reader->new($folder, @_); |
28
|
|
|
|
|
|
|
|
29
|
11
|
|
|
|
|
140
|
return bless \%self, $class; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub messages { |
34
|
9
|
|
|
9
|
1
|
22
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
9
|
|
|
|
|
68
|
my @messages = $self->{_folder}->messages; |
37
|
9
|
|
|
|
|
17
|
my @ret; |
38
|
9
|
|
|
|
|
37
|
while (my $body = shift @messages) { |
39
|
52
|
|
|
|
|
43720
|
push @ret, $self->bless_message( $body ); |
40
|
|
|
|
|
|
|
} |
41
|
9
|
|
|
|
|
4691
|
return @ret; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub next_message { |
47
|
2
|
|
|
2
|
1
|
8
|
my $self = shift; |
48
|
|
|
|
|
|
|
|
49
|
2
|
50
|
|
|
|
11
|
my $body = $self->{_folder}->next_message or return; |
50
|
2
|
|
|
|
|
7
|
$self->bless_message( $body ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub bless_message { |
56
|
54
|
|
|
54
|
1
|
72
|
my $self = shift; |
57
|
54
|
|
50
|
|
|
137
|
my $message = shift || die "You must pass a message\n"; |
58
|
|
|
|
|
|
|
|
59
|
54
|
|
|
|
|
209
|
return Email::Simple->new($message); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub reader { |
65
|
1
|
|
|
1
|
1
|
1563
|
my $self = shift; |
66
|
1
|
|
|
|
|
7
|
return $self->{_folder}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |