File Coverage

blib/lib/Email/FolderType.pm
Criterion Covered Total %
statement 28 29 96.5
branch 5 6 83.3
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 40 42 95.2


line stmt bran cond sub pod time code
1 8     8   27276 use strict;
  8         21  
  8         342  
2 8     8   45 use warnings;
  8         16  
  8         660  
3             package Email::FolderType;
4             {
5             $Email::FolderType::VERSION = '0.814';
6             }
7             # ABSTRACT: Email::FolderType - determine the type of a mail folder
8 8         71 use Module::Pluggable search_path => "Email::FolderType",
9             require => 1,
10 8     8   7224 sub_name => 'matchers';
  8         94204  
11              
12 8     8   709 use Exporter 5.57 'import';
  8         258  
  8         775  
13              
14             our @EXPORT_OK = qw(folder_type);
15              
16             our $DEFAULT = 'Mbox';
17              
18              
19             sub folder_type ($) {
20 12     12 1 4949 my $folder = shift;
21 12         27 my $package = __PACKAGE__;
22              
23 8     8   44 no strict 'refs';
  8         619  
  8         1398  
24              
25              
26 12         76 foreach my $class ($package->matchers) {
27 35         43570 my $type = $class;
28              
29 35         246 $type =~ s!^$package\:\:!!;
30              
31 35 100       116 next if $type eq $DEFAULT; # delay till later since it's the default
32              
33 32         39 my $return;
34 32         47 eval {
35 32         38 $return = &{"$class\::match"}($folder);
  32         165  
36             };
37 32 100       250 return $type if $return;
38              
39             }
40              
41             # default
42 2 50       6 return $DEFAULT if &{"$package\::$DEFAULT\::match"}($folder);
  2         14  
43              
44 0           return undef;
45             }
46              
47              
48              
49             1;
50              
51             __END__