| 1 | package Egg::View::Mail::Mailer::CMD; | ||||||||||||||||||||
| 2 | # | ||||||||||||||||||||
| 3 | # Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> | ||||||||||||||||||||
| 4 | # | ||||||||||||||||||||
| 5 | # $Id: CMD.pm 285 2008-02-28 04:20:55Z lushe $ | ||||||||||||||||||||
| 6 | # | ||||||||||||||||||||
| 7 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 2 | ▶ | use Carp qw/ croak /; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 2 | our $VERSION = '0.01'; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 0 | ▶ | sub _setup { | ||||||||||||||||||
|
Subroutine
_setup: not called CC=8 SCAR=37.8
| |||||||||||||||||||||
| 14 | 0 | my($class, $e)= @_; | |||||||||||||||||||
| 15 | 0 | my $c= $class->config; | |||||||||||||||||||
| 16 | 0 | ▶ | $c->{cmd_path} ||= do { | ||||||||||||||||||
|
Condition0%0/3
$c->{"cmd_path"} ||= do {
-e "/usr/sbin/sendmail" ? "/usr/sbin/sendmail" : (-e "/usr/local/sbin/sendmail" ? "/usr/local/sbin/sendmail" : (-e "/usr/bin/sendmail" ? "/usr/bin/sendmail" : die("'sendmail' command is not found.")))
}
MC/DC0%0/2
$c->{"cmd_path"} ||= do {
-e "/usr/sbin/sendmail" ? "/usr/sbin/sendmail" : (-e "/usr/local/sbin/sendmail" ? "/usr/local/sbin/sendmail" : (-e "/usr/bin/sendmail" ? "/usr/bin/sendmail" : die("'sendmail' command is not found.")))
}
$c->{"cmd_path"}
do {
-e "/usr/sbin/sendmail" ? "/usr/sbin/sendmail" : (-e "/usr/local/sbin/sendmail" ? "/usr/local/sbin/sendmail" : (-e "/usr/bin/sendmail" ? "/usr/bin/sendmail" : die("'sendmail' command is not found.")))
}
Truth table0%0/3
A ||= B
A= $c->{"cmd_path"}B= do {
-e "/usr/sbin/sendmail" ? "/usr/sbin/sendmail" : (-e "/usr/local/sbin/sendmail" ? "/usr/local/sbin/sendmail" : (-e "/usr/bin/sendmail" ? "/usr/bin/sendmail" : die("'sendmail' command is not found.")))
}
| |||||||||||||||||||||
| 17 | 0 | ▶ | -e '/usr/sbin/sendmail' ? '/usr/sbin/sendmail' | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 18 | : -e '/usr/local/sbin/sendmail' ? '/usr/local/sbin/sendmail' | ||||||||||||||||||||
| 19 | : -e '/usr/bin/sendmail' ? '/usr/bin/sendmail' | ||||||||||||||||||||
| 20 | : die q{'sendmail' command is not found.}; | ||||||||||||||||||||
| 21 | }; | ||||||||||||||||||||
| 22 | 0 | ▶ | $c->{cmd_option} ||= '-t -i'; | ||||||||||||||||||
|
Condition0%0/2
$c->{"cmd_option"} ||= "-t -i"
MC/DC0%0/1
$c->{"cmd_option"} ||= "-t -i"
$c->{"cmd_option"}
Truth table0%0/2
A
A= $c->{"cmd_option"}
| |||||||||||||||||||||
| 23 | 0 | ▶ | unless ($class->can('valid_to_address')) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 24 | 2 | ▶ | no strict 'refs'; ## no critic. | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 25 | 2 | ▶ | no warnings 'redefine'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 26 | 0 | ▶ | my $regexp= $c->{email_regexp} || qr{^[\w\d\-_]+@[\w\d\.\-_]+$}; | ||||||||||||||||||
|
Condition0%0/2
$c->{'email_regexp'} || qr/^[\w\d\-_]+\@[\w\d\.\-_]+$/
MC/DC0%0/1
$c->{'email_regexp'} || qr/^[\w\d\-_]+\@[\w\d\.\-_]+$/
$c->{'email_regexp'}
Truth table0%0/2
A
A= $c->{'email_regexp'}
| |||||||||||||||||||||
| 27 | 0 | *{"${class}::valid_to_address"}= | |||||||||||||||||||
| 28 | 0 | ▶ | sub { $_[1]=~m{$regexp} || croak qq"'$_[1]' is bad address." }; | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | 0 | $class->next::method($e); | |||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | 0 | ▶ | sub mail_send { | ||||||||||||||||||
|
Subroutine
mail_send: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||
| 33 | 0 | my $self= shift; | |||||||||||||||||||
| 34 | 0 | ▶ | my $data= $_[0] ? ($_[1] ? {@_}: $_[0]) : croak q{I want mail data.}; | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 35 | 0 | my $c= $self->config; | |||||||||||||||||||
| 36 | 0 | ▶ | $self->valid_to_address($data->{to}) || return 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 37 | 0 | my $cmd_line= "$c->{cmd_path} $c->{cmd_option} $data->{to}"; | |||||||||||||||||||
| 38 | 0 | ▶ | if ($data->{debug}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 39 | 0 | $self->e->debug_out("# + mailsend : $cmd_line\n${$data->{body}}"); | |||||||||||||||||||
| 40 | } else { | ||||||||||||||||||||
| 41 | 0 | open MSEND, "| $cmd_line"; ## no critic | |||||||||||||||||||
| 42 | 0 | print MSEND ${$data->{body}}; | |||||||||||||||||||
| 43 | 0 | close MSEND; | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | 0 | 1; | |||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 2 | 1; | |||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | __END__ | ||||||||||||||||||||