File Coverage

blib/lib/Mail/ListDetector/Detector/Onelist.pm
Criterion Covered Total %
statement 42 44 95.4
branch 13 24 54.1
condition 2 3 66.6
subroutine 8 8 100.0
pod 1 2 50.0
total 66 81 81.4


line stmt bran cond sub pod time code
1             package Mail::ListDetector::Detector::Onelist;
2              
3 39     39   225 use strict;
  39         78  
  39         13151  
4 39     39   236 use warnings;
  39         82  
  39         1164  
5              
6 39     39   211 use base qw(Mail::ListDetector::Detector::Base);
  39         78  
  39         3246  
7 39     39   312 use Mail::ListDetector::List;
  39         83  
  39         967  
8 39     39   392 use Carp;
  39         96  
  39         5486  
9              
10 20     20 0 73 sub DEBUG { 0 }
11              
12             sub match {
13 8     8 1 19 my $self = shift;
14 8         20 my $message = shift;
15 8 50       35 print "Got message $message\n" if DEBUG;
16 8 50       47 carp ("Mail::ListDetector::Detector::Onelist - no message supplied") unless defined($message);
17 39     39   264 use Email::Abstract;
  39         420  
  39         22424  
18 8         42 my $mailing_list = Email::Abstract->get_header($message, 'Mailing-List');
19 8 100       542 chomp $mailing_list if defined $mailing_list;
20 8 100 66     53 if ((!defined $mailing_list) or $mailing_list =~ /^\s*$/) {
21 7 50       53 print "Returning undef - couldn't find Mailing-List header\n" if DEBUG;
22 7         95 return undef;
23             }
24 1 50       3 print "ONElist: $mailing_list\n" if DEBUG
25             my $list;
26 1         6 $list = new Mail::ListDetector::List;
27 1         5 $list->listsoftware("ONElist");
28 1         1 my $listname;
29             my $posting_address;
30 1 50       10 if ($mailing_list =~ /^\s*list\s+([^@\s]+)@(onelist\.(..|com));\s+contact\s+\1-owner@\2$/) {
31 1 50       2 print "Mailing-List matches pattern\n" if DEBUG;
32 1         3 $listname = $1;
33 1         3 $posting_address = "$1\@$2";
34 1 50       4 print "Got listname $listname\n" if DEBUG;
35 1         4 $list->listname($listname);
36 1 50       3 print "Got posting address $posting_address\n" if DEBUG;
37 1         5 $list->posting_address($posting_address);
38             } else {
39 0 0       0 print "Mailing-List doesn't match\n" if DEBUG;
40 0         0 return undef;
41             }
42              
43 1 50       3 print "Returning object $list\n" if DEBUG;
44 1         3 return $list;
45             }
46              
47             1;
48              
49             __END__