File Coverage

blib/lib/Mail/ListDetector/Detector/Ezmlm.pm
Criterion Covered Total %
statement 48 48 100.0
branch 16 28 57.1
condition 2 3 66.6
subroutine 8 8 100.0
pod 1 2 50.0
total 75 89 84.2


line stmt bran cond sub pod time code
1             package Mail::ListDetector::Detector::Ezmlm;
2              
3 39     39   1101 use strict;
  39         80  
  39         1541  
4 39     39   241 use warnings;
  39         86  
  39         1618  
5              
6 39     39   226 use base qw(Mail::ListDetector::Detector::Base);
  39         153  
  39         4109  
7 39     39   239 use Mail::ListDetector::List;
  39         72  
  39         1247  
8 39     39   322 use Carp;
  39         364  
  39         6617  
9              
10 107     107 0 384 sub DEBUG { 0 }
11              
12             sub match {
13 42     42 1 110 my $self = shift;
14 42         107 my $message = shift;
15 42 50       175 print "Got message $message\n" if DEBUG;
16 42 50       181 carp ("Mail::ListDetector::Detector::Ezmlm - no message supplied") unless defined($message);
17 39     39   279 use Email::Abstract;
  39         71  
  39         20360  
18              
19 42 50       138 print "Getting mailing list header\n" if DEBUG;
20 42         217 my $mailing_list = Email::Abstract->get_header($message, 'Mailing-List');
21 42 100       3233 return undef unless defined $mailing_list;
22 4 50       13 print "Got header, and isn't null\n" if DEBUG;
23 4         11 chomp $mailing_list;
24 4 50       14 print "Mailing-List is [$mailing_list]\n" if DEBUG;
25 4         9 my ($help, $listsoftware);
26 4 50       12 print "Matching for information\n" if DEBUG;
27 4         22 ($help, $listsoftware) = ($mailing_list =~ /^contact (\S+?)\; run by (\w+)$/);
28 4 50       13 print "Help was [$help], listsoftware was [$listsoftware]\n" if DEBUG;
29 4 100 66     28 if ((defined $listsoftware) and ($listsoftware eq 'ezmlm')) {
30 1 50       3 print "List software matched\n" if DEBUG;
31 1         10 my $list = new Mail::ListDetector::List;
32 1 50       3 print "Set listsoftware = [$listsoftware]\n" if DEBUG;
33 1         4 $list->listsoftware($listsoftware);
34 1         2 my $posting = $help;
35 1         4 $posting =~ s/-help\@/\@/;
36 1 50       2 DEBUG && print "posting is [$posting]\n";
37 1         4 $list->posting_address($posting);
38             # FIXME: dodgy for unusual addresses.
39 1         6 my ($listname) = ($posting =~ /^([^@]+)@/);
40 1         5 $list->listname($listname);
41 1 50       3 print "Returning list object\n" if DEBUG;
42 1         6 return $list;
43             } else {
44 3 50       10 print "Didn't match, returning\n" if DEBUG;
45 3         46 return undef;
46             }
47             }
48              
49             1;
50              
51             __END__