blib/lib/Egg/View/Mail/Plugin/SaveBody.pm

filter: Statementstmt 28.0% 14 / 50 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 36.3% 4 / 11 Podpod 100% 2 / 2 totaltotal 23.5% 20 / 85 CC 10 SCAR 21.3
CC
10
Cov
20%
___send_lot
20.0
send
12.0
_setup
7.0
CRAP 8.4
« blib/lib/Egg/View/Mail/Plugin/Jfold.pm ↑ Summary lib/Egg/Helper/View/Mail.pm »
1 package Egg::View::Mail::Plugin::SaveBody;
2 #
3 # Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
4 #
5 # $Id: SaveBody.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  
10 2 our $VERSION= '0.01';
11  
12 0 ▶sub _setup {
Subroutine _setup: not called CC=3 SCAR=19.4
13 0 my($class, $e)= @_;
14 0 ▶ $e->is_model('fsavedate')
Branch: 1 branch
BranchTrueFalseTotal
$e->is_model("fsavedate") or die "Egg::View::Mail::Plugin::SaveBody - I want setup 'Egg::Model::FsaveDate'." 0 0 0
15 || die __PACKAGE__. q{ - I want setup 'Egg::Model::FsaveDate'.};
16 2 ▶ no strict 'refs'; ## no critic.
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
18 0 ▶ if ($class->isa('Egg::View::Mail::Plugin::Lot')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class->isa('Egg::View::Mail::Plugin::Lot')) { } 0 0 0
19 0 require Digest::SHA1;
20 0 $class->mk_accessors(qw/ lot_name savebodys /);
21 0 *{"${class}::__send"} = \&___send_lot;
22 0 *{"${class}::__save_body"}= \&___save_body_lot;
23 } else {
24 0 ▶ *{"${class}::__send"} = sub {};
Subroutine __ANON__: not called CC=1 SCAR=6.9
25 0 *{"${class}::__save_body"}= \&___save_body_proc;
26 }
27 0 $class->mk_accessors('is_savebody');
28 0 $class->next::method($e);
29 }
30 0 ▶sub send {
Subroutine send: not called CC=3 SCAR=24.8
Pod documented
31 0 my $self= shift;
32 0 ▶ my $data= $_[0] ? ($_[1] ? {@_}: $_[0]): return $self->next::method(@_);
Branch: 2 branches
BranchTrueFalseTotal
$_[0] ? : 0 0 0
$_[1] ? : 0 0 0
33 0 $self->is_savebody(undef);
34 0 $self->__send($data);
35 0 $self->next::method($data);
36 }
37 0 ▶sub mail_send {
Subroutine mail_send: not called CC=1 SCAR=6.9
Pod documented
38 0 my($self, $data)= @_;
39 0 $self->__save_body($data);
40 0 $self->next::method($data);
41 }
42 0 ▶sub ___send_lot {
Subroutine ___send_lot: not called CC=4 SCAR=30.0
43 0 my($self, $data)= @_;
44 0 ▶ my $to= $data->{to} || $self->config->{to} || return 0;
Condition0%0/5
$data->{'to'} || $self->config->{'to'} || (return 0)
l!l
00
$data->{"to"} or $self->config->{"to"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$data->{'to'} || $self->config->{'to'} || (return 0)
$data->{"to"} $self->config->{"to"}
Truth table0%0/3
A or B
A= $data->{"to"}B= $self->config->{"to"}
ABresult
1X1
011
000
45 0 $self->lot_name( Digest::SHA1::sha1_hex($to. '-save') );
46 0 ▶ $self->savebodys({}) unless $self->savebodys;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->savebodys 0 0 0
47 0 1;
48 }
49 0 ▶sub ___save_body_lot {
Subroutine ___save_body_lot: not called CC=2 SCAR=17.9
50 0 my($self, $data)= @_;
51 0 ▶ return 0 if $self->savebodys->{$self->lot_name};
Branch: 1 branch
BranchTrueFalseTotal
if $self->savebodys->{$self->lot_name} 0 0 0
52 0 $self->___save_body_proc($data);
53 0 $self->savebodys->{$self->lot_name}= 1;
54 }
55 0 ▶sub ___save_body_proc {
Subroutine ___save_body_proc: not called CC=2 SCAR=17.9
56 0 my($self, $data)= @_;
57 my $output_path= $self->e->model('fsavedate')->save
58 0 ▶ ( ${$data->{body}}, ($data->{save_body_path} || undef) );
Condition0%0/2
$data->{'save_body_path'} || undef
l!l
00
MC/DC0%0/1
$data->{'save_body_path'} || undef
$data->{'save_body_path'}
Truth table0%0/2
A
A= $data->{'save_body_path'}
Aresult
11
00
59 0 $self->is_savebody($output_path);
60 }
61  
62 2 1;
63  
64 __END__
« blib/lib/Egg/View/Mail/Plugin/Jfold.pm ↑ Summary lib/Egg/Helper/View/Mail.pm »