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   5 use strict;
  1         2  
  1         183  
2 1     1   6 use warnings;
  1         2  
  1         53  
3              
4             package App::Addex::Output::Procmail;
5             # ABSTRACT: generate procmail recipes from an address book
6             $App::Addex::Output::Procmail::VERSION = '0.026';
7 1     1   5 use parent qw(App::Addex::Output::ToFile);
  1         2  
  1         8  
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       26 return unless my $folder = $entry->field('folder');
36              
37 3         166 $folder =~ tr{/}{.};
38              
39 3         16 my @emails = $entry->emails;
40              
41 3         10 for my $email (@emails) {
42 3 50       14 next unless $email->sends;
43 3         26 $self->output(":0");
44 3         19 $self->output("* From:.*$email");
45 3         18 $self->output(".$folder/");
46 3         14 $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.026
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 METHODS
77              
78             =head2 process_entry
79              
80             $procmail_outputter->process_entry($addex, $entry);
81              
82             This method does the actual writing of configuration to the file.
83              
84             =head1 CONFIGURATION
85              
86             The valid configuration parameters for this plugin are:
87              
88             filename - the filename to which to write the procmail recipes
89              
90             =head1 AUTHOR
91              
92             Ricardo SIGNES <rjbs@cpan.org>
93              
94             =head1 COPYRIGHT AND LICENSE
95              
96             This software is copyright (c) 2006 by Ricardo SIGNES.
97              
98             This is free software; you can redistribute it and/or modify it under
99             the same terms as the Perl 5 programming language system itself.
100              
101             =cut