blib/lib/Log/Dispatch/Growl.pm

filter: Statementstmt 100% 41 / 41 Branchbran 50.0% 1 / 2 Conditioncond 62.5% 5 / 8 MC/DCmcdc 20.0% 1 / 5 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 2 totaltotal 85.2% 58 / 68 CC 5 SCAR 7.0
CC
5
Cov
92%
_init
4.0
new
2.0
BEGIN
1.0
CRAP 2.0
↑ Summary
1 package Log::Dispatch::Growl;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 our $VERSION = '1.0';
5  
6 2 ▶use base qw(Log::Dispatch::Output);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use File::Basename qw(basename);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Params::Validate qw(validate SCALAR BOOLEAN);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 Params::Validate::validation_options( allow_extra => 1 );
10 2 ▶use Growl::Any;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
13 2 my $param = shift;
14 2 ▶ my $class = ref $param || $param;
Condition33%1/3
ref $param || $param
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $param || $param
ref $param $param
Truth table33%1/3
A || B
A= ref $paramB= $param
ABresult
1X1
011
000
15  
16 2 my $self = bless {}, $class;
17  
18 2 $self->_basic_init(@_);
19 2 $self->_init(@_);
20  
21 2 return $self;
22 }
23  
24 2 ▶sub _init {
Subroutine _init: called CC=4 SCAR=13.9
25 2 my $self = shift;
26  
27 2 my $check = {
28 app_name => {
29 type => SCALAR,
30 default => __PACKAGE__,
31 },
32 title => {
33 type => SCALAR,
34 default => basename( $0 ),
35 },
36 priority => {
37 type => SCALAR,
38 default => 0,
39 regex => qr{^\-*[0-2]$}o,
40 },
41 icon_file => {
42 type => SCALAR,
43 default => undef,
44 },
45 };
46  
47 2 my %p = validate( @_, $check );
48  
49 2 $self->{app_name} = $p{app_name};
50 2 $self->{title} = $p{title};
51 2 ▶ $self->{priority} = $p{priority} || 0;
Condition100%2/2
$p{'priority'} || 0
l!l
11
MC/DC100%1/1
$p{'priority'} || 0
$p{'priority'}
Truth table100%2/2
A
A= $p{'priority'}
Aresult
11
00
52 2 ▶ $self->{sticky} = defined $p{sticky} && $p{sticky} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $p{'sticky'} && $p{'sticky'} ? : 0 2 2
Condition66%2/3
defined $p{"sticky"} and $p{"sticky"}
!ll&&!rl&&r
110
MC/DC0%0/2
defined $p{"sticky"} and $p{"sticky"}
defined $p{"sticky"} $p{"sticky"}
Truth table66%2/3
A and B
A= defined $p{"sticky"}B= $p{"sticky"}
ABresult
0X0
100
111
53 2 $self->{icon_file} = $p{icon_file};
54  
55 2 $self->{growl} = Growl::Any->new( appname => $self->{app_name}, events => [ $self->_notification_name] );
56 2 return $self;
57 }
58  
59 4 ▶sub _notification_name { "New Message" }
Subroutine _notification_name: called CC=1 SCAR=0.0
60  
61 2 ▶sub log_message {
Subroutine log_message: called CC=1 SCAR=0.0
Pod undocumented
62 2 my $self = shift;
63 2 my %p = @_;
64  
65 $self->{growl}->notify(
66 $self->_notification_name,
67 $self->{title},
68 $p{message},
69 $self->{icon_file},
70 2 );
71 }
72  
73 2 1;
74  
75 __END__
↑ Summary