File Coverage

blib/lib/Mail/ListDetector/Detector/Yahoogroups.pm
Criterion Covered Total %
statement 44 44 100.0
branch 15 24 62.5
condition 2 3 66.6
subroutine 8 8 100.0
pod 1 2 50.0
total 70 81 86.4


line stmt bran cond sub pod time code
1             package Mail::ListDetector::Detector::Yahoogroups;
2              
3 39     39   221 use strict;
  39         78  
  39         1356  
4 39     39   215 use warnings;
  39         79  
  39         1141  
5              
6 39     39   200 use base qw(Mail::ListDetector::Detector::Base);
  39         77  
  39         3018  
7 39     39   236 use Mail::ListDetector::List;
  39         90  
  39         868  
8 39     39   209 use Carp;
  39         76  
  39         6479  
9              
10 82     82 0 289 sub DEBUG { 0 }
11              
12             sub match {
13 38     38 1 114 my $self = shift;
14 38         91 my $message = shift;
15 38 50       154 print "Got message $message\n" if DEBUG;
16 38 50       162 carp ("Mail::ListDetector::Detector::Yahoogroups - no message supplied") unless defined($message);
17 39     39   265 use Email::Abstract;
  39         80  
  39         19732  
18 38         194 my $mailing_list = Email::Abstract->get_header($message, 'Mailing-List');
19 38 100       2807 chomp $mailing_list if defined $mailing_list;
20 38 100 66     279 if ((!defined $mailing_list) or $mailing_list =~ /^\s*$/) {
21 35 50       122 print "Returning undef - couldn't find Mailing-List header\n" if DEBUG;
22 35         515 return undef;
23             }
24 3 50       10 print "Yahoo! Groups: $mailing_list\n" if DEBUG
25             my $list;
26 3         29 $list = new Mail::ListDetector::List;
27 3         18 $list->listsoftware("Yahoo! Groups");
28 3         5 my $listname;
29             my $posting_address;
30 3 100       24 if ($mailing_list =~ /^\s*list\s+([^@\s]+)@((?:e|yahoo)groups\.(..|com));\s+contact\s+\1-owner@\2$/) {
31 1 50       3 print "Mailing-List matches pattern\n" if DEBUG;
32 1         9 $listname = $1;
33 1         6 $posting_address = "$1\@$2";
34 1 50       3 print "Got listname $listname\n" if DEBUG;
35 1         5 $list->listname($listname);
36 1 50       2 print "Got posting address $posting_address\n" if DEBUG;
37 1         4 $list->posting_address($posting_address);
38             } else {
39 2 50       12 print "Mailing-List doesn't match\n" if DEBUG;
40 2         54 return undef;
41             }
42              
43 1 50       4 print "Returning object $list\n" if DEBUG;
44 1         4 return $list;
45             }
46              
47             1;
48              
49             __END__