Alert/Output.pm

filter: Statementstmt 65.5% 19 / 29 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 80.0% 4 / 5 Podpod n/a totaltotal 51.1% 23 / 45 CC 5 SCAR 28.4
CC
5
Cov
50%
__ANON__
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 17.1
« Alert/InputGrp.pm ↑ Summary Alert/Input/POP3.pm »
1 package Transform::Alert::Output;
2  
3 9 our $VERSION = '1.00'; # VERSION
4 # ABSTRACT: Base role for Transform::Alert output types
5  
6 9 ▶use sanity;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 9 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 9 ▶use MooX::Types::MooseLike::Base qw(Str ScalarRef HashRef Object);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 9 ▶use File::Slurp 'read_file';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 9 requires qw(open opened send close);
13  
14 0 ▶around BUILDARGS => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
15 0 my ($orig, $self) = (shift, shift);
16 0 my $hash = shift;
17 0 ▶ $hash = { $hash, @_ } unless ref $hash;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $hash 0 0 0
18  
19 # read template file
20 0 ▶ if (my $tmpl_file = delete $hash->{templatefile}) { $hash->{template} = read_file($tmpl_file); }
Branch: 1 branch
BranchTrueFalseTotal
if (my $tmpl_file = delete $$hash{"templatefile"}) 0 0 0
21  
22 # work with inline templates (and file above)
23 0 ▶ if (exists $hash->{template} && not ref $hash->{template}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$hash{"template"} and not ref $$hash{"template"}) 0 0 0
Condition0%0/3
exists $$hash{"template"} and not ref $$hash{"template"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $$hash{"template"} and not ref $$hash{"template"}
exists $$hash{"template"} not ref $$hash{"template"}
Truth table0%0/3
A and not(B)
A= exists $$hash{"template"}B= not ref $$hash{"template"}
ABresult
0X0
100
111
24 0 my $tmpl_text = $hash->{template};
25 0 $tmpl_text =~ s/^\s+|\s+$//g; # remove leading/trailing spaces
26 0 $hash->{template} = \$tmpl_text;
27 }
28  
29 0 $orig->($self, $hash);
30 9 };
31  
32 9 has daemon => (
33 is => 'rwp',
34 isa => Object,
35 weak_ref => 1,
36 handles => [ 'log' ],
37 );
38 9 has connopts => (
39 is => 'ro',
40 isa => HashRef,
41 required => 1,
42 );
43 9 has template => (
44 is => 'ro',
45 isa => ScalarRef[Str],
46 required => 1,
47 );
48  
49 9 42;
50  
51 __END__
« Alert/InputGrp.pm ↑ Summary Alert/Input/POP3.pm »