blib/lib/Egg/View/Mail/Mailer/CMD.pm

filter: Statementstmt 41.4% 17 / 41 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 62.5% 5 / 8 Podpod 100% 1 / 1 totaltotal 29.1% 23 / 79 CC 13 SCAR 32.5
CC
13
Cov
26%
_setup
43.7
mail_send
30.0
__ANON__
6.0
CRAP 25.8
« blib/lib/Egg/View/Mail/Base.pm ↑ Summary blib/lib/Egg/View/Mail/Plugin/Signature.pm »
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."))) }
l!l&&r!l&&!r
000
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."))) }
ABresult
1X1
011
000
17 0 ▶ -e '/usr/sbin/sendmail' ? '/usr/sbin/sendmail'
Branch: 3 branches
BranchTrueFalseTotal
-e '/usr/sbin/sendmail' ? : 0 0 0
-e '/usr/local/sbin/sendmail' ? : 0 0 0
-e '/usr/bin/sendmail' ? : 0 0 0
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"
l!l
00
MC/DC0%0/1
$c->{"cmd_option"} ||= "-t -i"
$c->{"cmd_option"}
Truth table0%0/2
A
A= $c->{"cmd_option"}
Aresult
11
00
23 0 ▶ unless ($class->can('valid_to_address')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($class->can("valid_to_address")) 0 0 0
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\.\-_]+$/
l!l
00
MC/DC0%0/1
$c->{'email_regexp'} || qr/^[\w\d\-_]+\@[\w\d\.\-_]+$/
$c->{'email_regexp'}
Truth table0%0/2
A
A= $c->{'email_regexp'}
Aresult
11
00
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
BranchTrueFalseTotal
$_[1] =~ /$regexp/ or croak("'$_[1]' is bad address.") 0 0 0
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
BranchTrueFalseTotal
$_[0] ? : 0 0 0
$_[1] ? : 0 0 0
35 0 my $c= $self->config;
36 0 ▶ $self->valid_to_address($data->{to}) || return 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->valid_to_address($data->{"to"}) or return 0 0 0 0
37 0 my $cmd_line= "$c->{cmd_path} $c->{cmd_option} $data->{to}";
38 0 ▶ if ($data->{debug}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data->{'debug'}) { } 0 0 0
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__
« blib/lib/Egg/View/Mail/Base.pm ↑ Summary blib/lib/Egg/View/Mail/Plugin/Signature.pm »