File Coverage

blib/lib/App/Addex/Output/Procmail.pm
Criterion Covered Total %
statement 19 19 100.0
branch 3 4 75.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 27 28 96.4


line stmt bran cond sub pod time code
1 1     1   8 use strict;
  1         2  
  1         34  
2 1     1   5 use warnings;
  1         2  
  1         69  
3              
4             package App::Addex::Output::Procmail 0.027;
5             # ABSTRACT: generate procmail recipes from an address book
6              
7 1     1   18 use parent qw(App::Addex::Output::ToFile);
  1         3  
  1         9  
8              
9             #pod =head1 DESCRIPTION
10             #pod
11             #pod This plugin produces a file that contains a list of procmail recipes. For
12             #pod any entry with a "folder" field, recipes are produced to deliver all mail from
13             #pod its addresses to the given folder.
14             #pod
15             #pod Forward slashes in the folder name are converted to dots, showing my bias
16             #pod toward Courier IMAP.
17             #pod
18             #pod =head1 CONFIGURATION
19             #pod
20             #pod The valid configuration parameters for this plugin are:
21             #pod
22             #pod filename - the filename to which to write the procmail recipes
23             #pod
24             #pod =method process_entry
25             #pod
26             #pod $procmail_outputter->process_entry($addex, $entry);
27             #pod
28             #pod This method does the actual writing of configuration to the file.
29             #pod
30             #pod =cut
31              
32             sub process_entry {
33 6     6 1 13 my ($self, $addex, $entry) = @_;
34              
35 6 100       16 return unless my $folder = $entry->field('folder');
36              
37 3         120 $folder =~ tr{/}{.};
38              
39 3         11 my @emails = $entry->emails;
40              
41 3         7 for my $email (@emails) {
42 3 50       9 next unless $email->sends;
43 3         15 $self->output(":0");
44 3         11 $self->output("* From:.*$email");
45 3         31 $self->output(".$folder/");
46 3         9 $self->output(q{});
47             }
48              
49             }
50              
51             1;
52              
53             __END__
54              
55             =pod
56              
57             =encoding UTF-8
58              
59             =head1 NAME
60              
61             App::Addex::Output::Procmail - generate procmail recipes from an address book
62              
63             =head1 VERSION
64              
65             version 0.027
66              
67             =head1 DESCRIPTION
68              
69             This plugin produces a file that contains a list of procmail recipes. For
70             any entry with a "folder" field, recipes are produced to deliver all mail from
71             its addresses to the given folder.
72              
73             Forward slashes in the folder name are converted to dots, showing my bias
74             toward Courier IMAP.
75              
76             =head1 PERL VERSION SUPPORT
77              
78             This module has the same support period as perl itself: it supports the two
79             most recent versions of perl. (That is, if the most recently released version
80             is v5.40, then this module should work on both v5.40 and v5.38.)
81              
82             Although it may work on older versions of perl, no guarantee is made that the
83             minimum required version will not be increased. The version may be increased
84             for any reason, and there is no promise that patches will be accepted to lower
85             the minimum required perl.
86              
87             =head1 METHODS
88              
89             =head2 process_entry
90              
91             $procmail_outputter->process_entry($addex, $entry);
92              
93             This method does the actual writing of configuration to the file.
94              
95             =head1 CONFIGURATION
96              
97             The valid configuration parameters for this plugin are:
98              
99             filename - the filename to which to write the procmail recipes
100              
101             =head1 AUTHOR
102              
103             Ricardo SIGNES <rjbs@semiotic.systems>
104              
105             =head1 COPYRIGHT AND LICENSE
106              
107             This software is copyright (c) 2006 by Ricardo SIGNES.
108              
109             This is free software; you can redistribute it and/or modify it under
110             the same terms as the Perl 5 programming language system itself.
111              
112             =cut