Postfix.pm

filter: Statementstmt 73.5% 39 / 53 Branchbran 62.5% 5 / 8 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 73.6% 14 / 19 Podpod 100% 13 / 13 totaltotal 65.7% 71 / 108 CC 10 SCAR 10.8
CC
10
Cov
63%
get_pending
6.0
attribute_separator
5.4
attribute_terminator
5.4
CRAP 2.9
↑ Summary Postfix/Base64.pm »
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 POE::Filter::Postfix;
5 1 our $VERSION = '0.003';
6  
7  
8 # ABSTRACT: Postfix (MTA) text attribute communication
9 1 ▶use base qw(POE::Filter);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 ▶sub _abstract {
Subroutine _abstract: called CC=1 SCAR=5.5
12 3 my $name = shift;
13 0 ▶ eval sprintf <<'', ($name) x 2;
Subroutine attribute_separator: not called CC=2 SCAR=16.9
Subroutine attribute_terminator: not called CC=2 SCAR=16.9
Subroutine request_terminator: not called CC=2 SCAR=16.9
Pod documented
Pod documented
Pod documented
Condition0%0/9
ref $_[0] || $_[0]
l!l&&r!l&&!r
000
ref $_[0] || $_[0]
l!l&&r!l&&!r
000
ref $_[0] || $_[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
14 sub %s {
15 my $class = ref($_[0]) || $_[0];
16 require Carp;
17 Carp::croak("$class must override %s()");
18 }
19  
20 }
21  
22 1 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=6.9
23 1 _abstract($_) for qw(
24 attribute_separator
25 attribute_terminator
26 request_terminator
27 )
28 }
29  
30  
31 3 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
32 3 my $class = shift;
33 3 bless {
34 @_,
35 buffer => '',
36 } => $class;
37 }
38  
39  
40 0 ▶sub clone {
Subroutine clone: not called CC=1 SCAR=6.9
Pod documented
41 0 my $self = shift;
42 0 $self->new(%$self);
43 }
44  
45  
46 3 ▶sub get_one_start {
Subroutine get_one_start: called CC=2 SCAR=6.9
Pod documented
47 3 my ($self, $buf) = @_;
48 3 $self->{buffer} .= $_ for @$buf;
49 }
50  
51  
52 6 ▶sub get_one {
Subroutine get_one: called CC=4 SCAR=13.9
Pod documented
53 6 my ($self) = @_;
54 6 my %attr;
55 6 my $buf = $self->{buffer};
56 6 my ($a_s, $a_t, $r_t) = (
57 $self->attribute_separator,
58 $self->attribute_terminator,
59 $self->request_terminator,
60 );
61 6 ▶ while ($buf =~ s/^([^$r_t]+?)\Q$a_s\E//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buf =~ s/^([^$r_t]+?)\Q$a_s\E//) 12 6 18
62 12 my $key = $self->decode_key("$1");
63 12 ▶ $buf =~ s/^([^$r_t]*)?\Q$a_t\E// or return [];
Branch: 1 branch
BranchTrueFalseTotal
$buf =~ s/^([^$r_t]*)?\Q$a_t\E// or return [] 12 0 12
64 12 $attr{$key} = $self->decode_value("$1");
65 }
66 6 ▶ return [] unless $buf =~ s/^\Q$r_t\E//;
Branch: 1 branch
BranchTrueFalseTotal
unless $buf =~ s/^\Q$r_t\E// 3 3 6
67 3 $self->{buffer} = $buf;
68 3 return [ \%attr ];
69 }
70  
71  
72 0 ▶sub get_pending {
Subroutine get_pending: not called CC=2 SCAR=17.9
Pod documented
73 0 my ($self) = @_;
74 0 ▶ return [ $self->{buffer} ] if length $self->{buffer};
Branch: 1 branch
BranchTrueFalseTotal
if length $self->{"buffer"} 0 0 0
75 0 return undef;
76 }
77  
78  
79 8 ▶sub decode_key { $_[1] }
Subroutine decode_key: called CC=1 SCAR=0.0
Pod documented
80 8 ▶sub decode_value { $_[1] }
Subroutine decode_value: called CC=1 SCAR=0.0
Pod documented
81  
82  
83 3 ▶sub put {
Subroutine put: called CC=1 SCAR=0.0
Pod documented
84 3 my ($self, $chunks) = @_;
85  
86 3 return [ map { $self->_encode($_) } @$chunks ];
87 }
88  
89 3 ▶sub _encode {
Subroutine _encode: called CC=1 SCAR=0.0
90 3 my ($self, $attr) = @_;
91 return join $self->attribute_terminator,
92 (map {
93 3 join $self->attribute_separator,
94 $self->encode_key($_),
95 12 $self->encode_value($attr->{$_})
96 } keys %$attr),
97 $self->request_terminator;
98 }
99  
100  
101 8 ▶sub encode_key { $_[1] }
Subroutine encode_key: called CC=1 SCAR=0.0
Pod documented
102 8 ▶sub encode_value { $_[1] }
Subroutine encode_value: called CC=1 SCAR=0.0
Pod documented
103  
104  
105 1 1;
106  
107  
108 __END__
↑ Summary Postfix/Base64.pm »