| 1 | package Sietima; | ||||||||||||||||||||||||||||
| 2 | 19 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 19 | ▶ | use Sietima::Policy; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 19 | ▶ | use Types::Standard qw(ArrayRef Object); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 19 | ▶ | use Type::Params -sigs; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 19 | ▶ | use Sietima::Types qw(Address AddressFromStr | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | EmailMIME Message | ||||||||||||||||||||||||||||
| 8 | Subscriber SubscriberFromAddress SubscriberFromStr SubscriberFromHashRef | ||||||||||||||||||||||||||||
| 9 | 19 | Transport); | |||||||||||||||||||||||||||
| 10 | 19 | ▶ | use Sietima::Message; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 19 | ▶ | use Sietima::Subscriber; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 19 | ▶ | use Email::Sender::Simple qw(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 19 | ▶ | use Email::Address; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 19 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 19 | with 'MooX::Traits'; | |||||||||||||||||||||||||||
| 17 | 19 | our $VERSION = '1.1.5'; # VERSION | |||||||||||||||||||||||||||
| 18 | # ABSTRACT: minimal mailing list manager | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 19 | has return_path => ( | |||||||||||||||||||||||||||
| 22 | isa => Address, | ||||||||||||||||||||||||||||
| 23 | is => 'ro', | ||||||||||||||||||||||||||||
| 24 | required => 1, | ||||||||||||||||||||||||||||
| 25 | coerce => AddressFromStr, | ||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 19 | my $subscribers_array = ArrayRef[ | |||||||||||||||||||||||||||
| 30 | Subscriber->plus_coercions( | ||||||||||||||||||||||||||||
| 31 | SubscriberFromAddress, | ||||||||||||||||||||||||||||
| 32 | SubscriberFromStr, | ||||||||||||||||||||||||||||
| 33 | SubscriberFromHashRef, | ||||||||||||||||||||||||||||
| 34 | ) | ||||||||||||||||||||||||||||
| 35 | ]; | ||||||||||||||||||||||||||||
| 36 | 19 | has subscribers => ( | |||||||||||||||||||||||||||
| 37 | isa => $subscribers_array, | ||||||||||||||||||||||||||||
| 38 | is => 'lazy', | ||||||||||||||||||||||||||||
| 39 | coerce => $subscribers_array->coercion, | ||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||
| 41 | 1 | ▶ | sub _build_subscribers { +[] } | ||||||||||||||||||||||||||
|
Subroutine
_build_subscribers: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 19 | has transport => ( | |||||||||||||||||||||||||||
| 45 | isa => Transport, | ||||||||||||||||||||||||||||
| 46 | is => 'lazy', | ||||||||||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub _build_transport { Email::Sender::Simple->default_transport } | ||||||||||||||||||||||||||
|
Subroutine
_build_transport: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub handle_mail_from_stdin($self,@) { | ||||||||||||||||||||||||||
|
Subroutine
handle_mail_from_stdin: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 52 | 0 | my $mail_text = do { local $/; <> }; | |||||||||||||||||||||||||||
| 53 | # we're hoping that, since we probably got called from an MTA/MDA, | ||||||||||||||||||||||||||||
| 54 | # STDIN contains a well-formed email message, addressed to us | ||||||||||||||||||||||||||||
| 55 | 0 | my $incoming_mail = Email::MIME->new(\$mail_text); | |||||||||||||||||||||||||||
| 56 | 0 | return $self->handle_mail($incoming_mail); | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 19 | signature_for handle_mail => ( | |||||||||||||||||||||||||||
| 61 | method => Object, | ||||||||||||||||||||||||||||
| 62 | positional => [ EmailMIME ], | ||||||||||||||||||||||||||||
| 63 | ); | ||||||||||||||||||||||||||||
| 64 | 41 | ▶ | sub handle_mail($self,$incoming_mail) { | ||||||||||||||||||||||||||
|
Subroutine
handle_mail: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 65 | 41 | my (@outgoing_messages) = $self->munge_mail($incoming_mail); | |||||||||||||||||||||||||||
| 66 | 41 | for my $outgoing_message (@outgoing_messages) { | |||||||||||||||||||||||||||
| 67 | 40 | $self->send_message($outgoing_message); | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | 41 | return; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 19 | signature_for subscribers_to_send_to => ( | |||||||||||||||||||||||||||
| 74 | method => Object, | ||||||||||||||||||||||||||||
| 75 | positional => [ EmailMIME ], | ||||||||||||||||||||||||||||
| 76 | ); | ||||||||||||||||||||||||||||
| 77 | 34 | ▶ | sub subscribers_to_send_to($self,$incoming_mail) { | ||||||||||||||||||||||||||
|
Subroutine
subscribers_to_send_to: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 78 | 34 | return $self->subscribers; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 19 | signature_for munge_mail => ( | |||||||||||||||||||||||||||
| 83 | method => Object, | ||||||||||||||||||||||||||||
| 84 | positional => [ EmailMIME ], | ||||||||||||||||||||||||||||
| 85 | ); | ||||||||||||||||||||||||||||
| 86 | 34 | ▶ | sub munge_mail($self,$incoming_mail) { | ||||||||||||||||||||||||||
|
Subroutine
munge_mail: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 87 | 34 | return Sietima::Message->new({ | |||||||||||||||||||||||||||
| 88 | mail => $incoming_mail, | ||||||||||||||||||||||||||||
| 89 | from => $self->return_path, | ||||||||||||||||||||||||||||
| 90 | to => $self->subscribers_to_send_to($incoming_mail), | ||||||||||||||||||||||||||||
| 91 | }); | ||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 19 | signature_for send_message => ( | |||||||||||||||||||||||||||
| 96 | method => Object, | ||||||||||||||||||||||||||||
| 97 | positional => [ Message ], | ||||||||||||||||||||||||||||
| 98 | ); | ||||||||||||||||||||||||||||
| 99 | 40 | ▶ | sub send_message($self,$outgoing_message) { | ||||||||||||||||||||||||||
|
Subroutine
send_message: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 100 | 40 | my $envelope = $outgoing_message->envelope; | |||||||||||||||||||||||||||
| 101 | 40 | ▶ | if ($envelope->{to} && $envelope->{to}->@*) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$envelope->{"to"} and @{$envelope->{"to"}}
MC/DC50%1/2
$envelope->{"to"} and @{$envelope->{"to"}}
$envelope->{"to"}
@{$envelope->{"to"}}
Truth table66%2/3
A and B
A= $envelope->{"to"}B= @{$envelope->{"to"}}
| |||||||||||||||||||||||||||||
| 102 | 39 | $self->transport->send( | |||||||||||||||||||||||||||
| 103 | $outgoing_message->mail, | ||||||||||||||||||||||||||||
| 104 | $envelope, | ||||||||||||||||||||||||||||
| 105 | ); | ||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 40 | return; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 22 | ▶ | sub _trait_namespace { 'Sietima::Role' } ## no critic(ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||
|
Subroutine
_trait_namespace: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 4 | ▶ | sub list_addresses($self) { | ||||||||||||||||||||||||||
|
Subroutine
list_addresses: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 115 | return +{ | ||||||||||||||||||||||||||||
| 116 | 4 | return_path => $self->return_path, | |||||||||||||||||||||||||||
| 117 | }; | ||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 2 | ▶ | sub command_line_spec($self) { | ||||||||||||||||||||||||||
|
Subroutine
command_line_spec: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 122 | return { | ||||||||||||||||||||||||||||
| 123 | 2 | name => 'sietima', | |||||||||||||||||||||||||||
| 124 | title => 'a simple mailing list manager', | ||||||||||||||||||||||||||||
| 125 | subcommands => { | ||||||||||||||||||||||||||||
| 126 | send => { | ||||||||||||||||||||||||||||
| 127 | op => 'handle_mail_from_stdin', | ||||||||||||||||||||||||||||
| 128 | summary => 'send email from STDIN', | ||||||||||||||||||||||||||||
| 129 | }, | ||||||||||||||||||||||||||||
| 130 | }, | ||||||||||||||||||||||||||||
| 131 | }; | ||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 19 | 1; | |||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | __END__ | ||||||||||||||||||||||||||||