| 1 | package Mail::Summary; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | $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 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 1 | ▶ | use Mail::Box::Manager; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 1 | ▶ | use Lingua::EN::Summarize; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 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 | 4 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 38 | 4 | my $self = {}; | |||||||||
| 39 | 4 | bless $self, shift; | |||||||||
| 40 | 4 | return $self->_init(@_); | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 4 | ▶ | sub _init { | ||||||||
|
Subroutine
_init: called CC=4 SCAR=13.9
| |||||||||||
| 44 | 4 | my ($self, $ref) = @_; | |||||||||
| 45 | 4 | ▶ | die "No args passed to new" unless $ref; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 3 | ▶ | die "Args to new not a hashref" unless ref $ref eq 'HASH'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 2 | ▶ | die "No mail folder given" unless $ref->{maildir}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 1 | $self->{maildir} = $ref->{maildir}; | |||||||||
| 49 | 1 | $self->{mbm} = Mail::Box::Manager->new->open(folder => $ref->{maildir}); | |||||||||
| 50 | 0 | return $self; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 0 | ▶ | sub _mbm { shift->{mbm} } | ||||||||
|
Subroutine
_mbm: not called CC=1 SCAR=6.9
| |||||||||||
| 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 | 0 | ▶ | sub maildir { shift->{maildir} } | ||||||||
|
Subroutine
maildir: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 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 | ▶ | sub _messages { shift->_mbm->messages } | ||||||||
|
Subroutine
_messages: not called CC=1 SCAR=6.9
| |||||||||||
| 75 | |||||||||||
| 76 | 0 | ▶ | sub summaries { map summarize($_->body), shift->_messages } | ||||||||
|
Subroutine
summaries: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 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 E<lt>F<coder@stray-toaster.co.uk>E<gt> | ||||||||||
| 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 | 1 | return qw/This is the secret message/; | |||||||||