line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::Summary; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$Mail::Summary::VERSION = "0.02"; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Mail::Summary - scan read your mail! |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $ms = Mail::Summary->new({ maildir => '/home/mwk/Maildir' }); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my @mail_summaries = $ms->summaries; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Too busy to read your mail? Subscribe to too many mailing lists? |
18
|
|
|
|
|
|
|
Take two folders into the shower? Well, for the busy on the go geek |
19
|
|
|
|
|
|
|
of today, here is the answer! Get all your messages summarised, to |
20
|
|
|
|
|
|
|
save you having to read them, or to read them by which summary looks |
21
|
|
|
|
|
|
|
better! |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
82291
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
26
|
1
|
|
|
1
|
|
1815
|
use Mail::Box::Manager; |
|
1
|
|
|
|
|
386987
|
|
|
1
|
|
|
|
|
43
|
|
27
|
1
|
|
|
1
|
|
1026
|
use Lingua::EN::Summarize; |
|
1
|
|
|
|
|
8288
|
|
|
1
|
|
|
|
|
331
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 new |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $ms = Mail::Summary->new({ maildir => '/home/mwk/Maildir' }); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
This will make a new Mail::Summary object. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new { |
38
|
4
|
|
|
4
|
1
|
1736
|
my $self = {}; |
39
|
4
|
|
|
|
|
9
|
bless $self, shift; |
40
|
4
|
|
|
|
|
340
|
return $self->_init(@_); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _init { |
44
|
4
|
|
|
4
|
|
9
|
my ($self, $ref) = @_; |
45
|
4
|
100
|
|
|
|
35
|
die "No args passed to new" unless $ref; |
46
|
3
|
100
|
|
|
|
20
|
die "Args to new not a hashref" unless ref $ref eq 'HASH'; |
47
|
2
|
100
|
|
|
|
18
|
die "No mail folder given" unless $ref->{maildir}; |
48
|
1
|
|
|
|
|
8
|
$self->{maildir} = $ref->{maildir}; |
49
|
1
|
|
|
|
|
20
|
$self->{mbm} = Mail::Box::Manager->new->open(folder => $ref->{maildir}); |
50
|
1
|
|
|
|
|
107615
|
return $self; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
0
|
|
0
|
sub _mbm { shift->{mbm} } |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 maildir |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $maildir = $ms->maildir; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This is the mail directory as defined by the user. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
1
|
1
|
479
|
sub maildir { shift->{maildir} } |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 summaries |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my @mail_summaries = $ms->summaries; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This will return a list, with every entry in the list being a summary of an |
70
|
|
|
|
|
|
|
individual message. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
0
|
|
|
sub _messages { shift->_mbm->messages } |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
0
|
1
|
|
sub summaries { map summarize($_->body), shift->_messages } |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 BUGS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
I have only tried this with my Maildir style mailbox. If you use something |
81
|
|
|
|
|
|
|
else, and this works, I would love to hear from you. If it doesn't, I want |
82
|
|
|
|
|
|
|
to hear as well! |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 TODO |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Oh....lots of things. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
o Make it look more than the script it originally was!! |
89
|
|
|
|
|
|
|
o SMS the results of the summary? |
90
|
|
|
|
|
|
|
o Get the five keywords and feed them into google? |
91
|
|
|
|
|
|
|
o ignore already read messages |
92
|
|
|
|
|
|
|
o show which folder the messages summarised are in |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SHOWING YOUR APPRECIATION |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
There was a thread on london.pm mailing list about working in a vacumn |
97
|
|
|
|
|
|
|
- that it was a bit depressing to keep writing modules but never get |
98
|
|
|
|
|
|
|
any feedback. So, if you use and like this module then please send me |
99
|
|
|
|
|
|
|
an email and make my day. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
All it takes is a few little bytes. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
(Leon wrote that, not me!) |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 AUTHOR |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Stray Toaster EFE |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 With Thanks |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
o Dennis Taylor for his Lingua::EN::Summarize which inspired this! |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 COPYRIGHT |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Copyright (C) 2002, mwk |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This module is free software; you can redistribute it or modify it |
118
|
|
|
|
|
|
|
under the same terms as Perl itself. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
return qw/This is the secret message/; |