File Coverage

blib/lib/App/Addex/Plugin/Nobody.pm
Criterion Covered Total %
statement 11 22 50.0
branch 0 2 0.0
condition 0 4 0.0
subroutine 4 6 66.6
pod n/a
total 15 34 44.1


line stmt bran cond sub pod time code
1 1     1   537 use strict;
  1         2  
  1         27  
2 1     1   4 use warnings;
  1         2  
  1         42  
3              
4             package App::Addex::Plugin::Nobody 0.006;
5 1     1   15 use 5.006; # our
  1         3  
6 1     1   404 use Sub::Install;
  1         1602  
  1         5  
7             # ABSTRACT: automatically add a recipient that goes nowhere
8              
9             #pod =head1 DESCRIPTION
10             #pod
11             #pod The only valid "To" header that doesn't imply delivery somewhere
12             #pod looks something like this:
13             #pod
14             #pod To: undisclosed-recipients: ;
15             #pod
16             #pod This plugin adds a virtual entry to your address book with that address.
17             #pod
18             #pod =head1 CONFIGURATION
19             #pod
20             #pod First, you have to add the plugin to your Addex configuration file's top
21             #pod section:
22             #pod
23             #pod plugin = App::Addex::Plugin::Nobody
24             #pod
25             #pod You can supply the following options for the plugin:
26             #pod
27             #pod name - the "full name" to use (default: "Undisclosed Recipients")
28             #pod nick - the nick (if any) to provide (default: nobody)
29             #pod group - the name of the address group (default: undisclosed-recipients)
30             #pod this option is not well-validated, so maybe you should leave it alone
31             #pod
32             #pod The entry will have a true C<skip_hiveminder> field, to avoid bizarre
33             #pod interactions with the Hiveminder plugin.
34             #pod
35             #pod =cut
36              
37             sub import {
38 0     0     my ($mixin, %arg) = @_;
39              
40              
41 0   0       my $group_name = $arg{group} || 'undisclosed-recipients';
42              
43 0           require App::Addex::Entry;
44              
45             my $nobody = App::Addex::Entry->new({
46             name => $arg{name} || 'Undisclosed Recipients',
47 0 0 0       nick => exists $arg{nick} ? $arg{nick} : 'nobody',
48             fields => { skip_hiveminder => 1 },
49             emails => [
50             App::Addex::Entry::EmailAddress->new({
51             address => "$group_name: ;",
52             sends => 0,
53             receives => 1,
54             }),
55             ],
56             });
57              
58 0           my $caller = caller;
59 0           my $original_sub = $caller->can('entries');
60              
61             my $new_entries = sub {
62 0     0     my ($self) = @_;
63              
64 0           my @entries = $self->$original_sub;
65              
66 0           return (@entries, $nobody);
67 0           };
68              
69 0           Sub::Install::reinstall_sub({
70             code => $new_entries,
71             into => $caller,
72             as => 'entries',
73             });
74             }
75              
76             1;
77              
78             __END__
79              
80             =pod
81              
82             =encoding UTF-8
83              
84             =head1 NAME
85              
86             App::Addex::Plugin::Nobody - automatically add a recipient that goes nowhere
87              
88             =head1 VERSION
89              
90             version 0.006
91              
92             =head1 DESCRIPTION
93              
94             The only valid "To" header that doesn't imply delivery somewhere
95             looks something like this:
96              
97             To: undisclosed-recipients: ;
98              
99             This plugin adds a virtual entry to your address book with that address.
100              
101             =head1 PERL VERSION SUPPORT
102              
103             This module has the same support period as perl itself: it supports the two
104             most recent versions of perl. (That is, if the most recently released version
105             is v5.40, then this module should work on both v5.40 and v5.38.)
106              
107             Although it may work on older versions of perl, no guarantee is made that the
108             minimum required version will not be increased. The version may be increased
109             for any reason, and there is no promise that patches will be accepted to lower
110             the minimum required perl.
111              
112             =head1 CONFIGURATION
113              
114             First, you have to add the plugin to your Addex configuration file's top
115             section:
116              
117             plugin = App::Addex::Plugin::Nobody
118              
119             You can supply the following options for the plugin:
120              
121             name - the "full name" to use (default: "Undisclosed Recipients")
122             nick - the nick (if any) to provide (default: nobody)
123             group - the name of the address group (default: undisclosed-recipients)
124             this option is not well-validated, so maybe you should leave it alone
125              
126             The entry will have a true C<skip_hiveminder> field, to avoid bizarre
127             interactions with the Hiveminder plugin.
128              
129             =head1 AUTHOR
130              
131             Ricardo SIGNES <rjbs@semiotic.systems>
132              
133             =head1 COPYRIGHT AND LICENSE
134              
135             This software is copyright (c) 2008 by Ricardo SIGNES.
136              
137             This is free software; you can redistribute it and/or modify it under
138             the same terms as the Perl 5 programming language system itself.
139              
140             =cut