File Coverage

blib/lib/Mail/ListDetector/Detector/AutoShare.pm
Criterion Covered Total %
statement 45 45 100.0
branch 6 10 60.0
condition 5 6 83.3
subroutine 11 11 100.0
pod 1 2 50.0
total 68 74 91.8


line stmt bran cond sub pod time code
1             package Mail::ListDetector::Detector::AutoShare;
2              
3 39     39   243 use strict;
  39         87  
  39         1284  
4 39     39   210 use warnings;
  39         74  
  39         1148  
5 39     39   200 use vars qw($VERSION);
  39         84  
  39         2251  
6             $VERSION = '0.01';
7              
8 39     39   241 use base qw(Mail::ListDetector::Detector::Base);
  39         84  
  39         3261  
9 39     39   234 use Mail::ListDetector::List;
  39         88  
  39         919  
10 39     39   214 use Mail::ListDetector::Detector::RFC2919;
  39         76  
  39         939  
11 39     39   210 use Mail::ListDetector::Detector::RFC2369;
  39         66  
  39         1614  
12 39     39   200 use Carp;
  39         67  
  39         5509  
13              
14 32     32 0 182 sub DEBUG { 0 }
15              
16             sub match {
17 32     32 1 76 my $self = shift;
18 32         79 my $message = shift;
19 32 50       128 print "Got message $message\n" if DEBUG;
20 32 50       172 carp ("Mail::ListDetector::Detector::AutoShare - no message supplied") unless defined($message);
21 39     39   219 use Email::Abstract;
  39         70  
  39         10486  
22              
23 32         156 my $list_software = Email::Abstract->get_header($message, 'List-Software');
24 32 100 100     2410 if (defined($list_software) && ($list_software =~ m/(AutoShare [\w\.]+)/)) {
25 2         7 $list_software = $1;
26              
27 2         9 my $list_post = Email::Abstract->get_header($message, 'List-Post');
28 2 50       165 return undef unless defined($list_post);
29 2 50       15 $list_post =~ m/<(.+)>/ or return undef;
30 2         6 my $posting_address = $1;
31              
32 2         24 my $rfc2919 = new Mail::ListDetector::Detector::RFC2919;
33 2         22 my $rfc2369 = new Mail::ListDetector::Detector::RFC2369;
34 2   66     14 my $list = ( $rfc2919->match($message) or $rfc2369->match($message) );
35              
36 2         10 $list->listsoftware($list_software);
37              
38 2         51 return $list;
39             } else {
40 30         378 return undef;
41             }
42             }
43              
44             1;
45              
46             __END__