| 1 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | package App::Addex::Plugin::Nobody 0.006; | ||||||||||||||||||||
| 5 | 1 | ▶ | use 5.006; # our | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | ▶ | use Sub::Install; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 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 | 0 | ▶ | sub import { | ||||||||||||||||||
|
Subroutine
import: not called CC=4 SCAR=30.0
| |||||||||||||||||||||
| 38 | 0 | my ($mixin, %arg) = @_; | |||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 0 | ▶ | my $group_name = $arg{group} || 'undisclosed-recipients'; | ||||||||||||||||||
|
Condition0%0/2
$arg{'group'} || 'undisclosed-recipients'
MC/DC0%0/1
$arg{'group'} || 'undisclosed-recipients'
$arg{'group'}
Truth table0%0/2
A
A= $arg{'group'}
| |||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 0 | require App::Addex::Entry; | |||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | my $nobody = App::Addex::Entry->new({ | ||||||||||||||||||||
| 46 | name => $arg{name} || 'Undisclosed Recipients', | ||||||||||||||||||||
| 47 | 0 | ▶ | nick => exists $arg{nick} ? $arg{nick} : 'nobody', | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$arg{'name'} || 'Undisclosed Recipients'
MC/DC0%0/1
$arg{'name'} || 'Undisclosed Recipients'
$arg{'name'}
Truth table0%0/2
A
A= $arg{'name'}
| |||||||||||||||||||||
| 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 | 0 | ▶ | my $new_entries = sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 62 | 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 | 1; | |||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | __END__ | ||||||||||||||||||||