| 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
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # read template file | ||||||||||||||||||||||||||||
| 20 | 0 | ▶ | if (my $tmpl_file = delete $hash->{templatefile}) { $hash->{template} = read_file($tmpl_file); } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # work with inline templates (and file above) | ||||||||||||||||||||||||||||
| 23 | 0 | ▶ | if (exists $hash->{template} && not ref $hash->{template}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $$hash{"template"} and not ref $$hash{"template"}
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"}
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||