blib/lib/App/MadEye/Plugin/Notify/HipChat.pm

filter: Statementstmt 52.3% 22 / 42 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 14 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 87.5% 7 / 8 Podpod 0.0% 0 / 1 totaltotal 36.2% 29 / 80 CC 13 SCAR 47.8
CC
13
Cov
34%
notify
182.0
BEGIN
1.0
BEGIN
1.0
CRAP 118.7
↑ Summary
1 package App::MadEye::Plugin::Notify::HipChat;
2 1 ▶use 5.008005;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use base qw/App::MadEye::Plugin::Base/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = "0.02";
9  
10 1 ▶use Furl;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 0 ▶sub notify : Hook {
Subroutine notify: not called CC=13 SCAR=52.0
Pod undocumented
13 0 my ( $self, $context, $args ) = @_;
14  
15 0 my $conf = $self->{config}->{config};
16 0 ▶ my $url = $conf->{url} // "https://api.hipchat.com/v1/rooms/message";
Condition0%0/2
$conf->{"url"} // "https://api.hipchat.com/v1/rooms/message"
l!l
00
MC/DC0%0/1
$conf->{"url"} // "https://api.hipchat.com/v1/rooms/message"
$conf->{"url"}
Truth table0%0/2
A
A= $conf->{"url"}
Aresult
11
00
17 0 $url =~ s!/$!!g;
18  
19 0 ▶ my $auth_token = $conf->{auth_token} or die "missing auth_token";
Branch: 1 branch
BranchTrueFalseTotal
my $auth_token = $conf->{"auth_token"} or die "missing auth_token" 0 0 0
20 0 ▶ my $room_id = $conf->{room_id} or die "missing room_id";
Branch: 1 branch
BranchTrueFalseTotal
my $room_id = $conf->{"room_id"} or die "missing room_id" 0 0 0
21 0 ▶ my $from = $conf->{from} // "ikachan";
Condition0%0/2
$conf->{"from"} // "ikachan"
l!l
00
MC/DC0%0/1
$conf->{"from"} // "ikachan"
$conf->{"from"}
Truth table0%0/2
A
A= $conf->{"from"}
Aresult
11
00
22 0 ▶ my $notify = $conf->{notify} // 0;
Condition0%0/2
$conf->{"notify"} // 0
l!l
00
MC/DC0%0/1
$conf->{"notify"} // 0
$conf->{"notify"}
Truth table0%0/2
A
A= $conf->{"notify"}
Aresult
11
00
23 0 ▶ my $msg = $conf->{message} // "";
Condition0%0/2
$conf->{"message"} // ""
l!l
00
MC/DC0%0/1
$conf->{"message"} // ""
$conf->{"message"}
Truth table0%0/2
A
A= $conf->{"message"}
Aresult
11
00
24 0 ▶ my $message_format = $conf->{message_format} // "html";
Condition0%0/2
$conf->{"message_format"} // "html"
l!l
00
MC/DC0%0/1
$conf->{"message_format"} // "html"
$conf->{"message_format"}
Truth table0%0/2
A
A= $conf->{"message_format"}
Aresult
11
00
25 0 ▶ my $color = $conf->{color} // "yellow";
Condition0%0/2
$conf->{"color"} // "yellow"
l!l
00
MC/DC0%0/1
$conf->{"color"} // "yellow"
$conf->{"color"}
Truth table0%0/2
A
A= $conf->{"color"}
Aresult
11
00
26 0 ▶ my $format = $conf->{format} // "json";
Condition0%0/2
$conf->{"format"} // "json"
l!l
00
MC/DC0%0/1
$conf->{"format"} // "json"
$conf->{"format"}
Truth table0%0/2
A
A= $conf->{"format"}
Aresult
11
00
27  
28 0 ▶ while ( my ( $plugin, $results ) = each %$args ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$args) 0 0 0
29 0 $plugin =~ s/.+::Agent:://;
30 0 for my $result (@$results) {
31 0 $msg .= "$plugin: ($result->{target}): $result->{message} ";
32  
33 0 my $ua = Furl->new(
34 timeout => 5,
35 agent => "MadEye/$App::MadEye::VERSION"
36 );
37 0 my $res = $ua->post(
38 $url,
39 [],
40 [
41 auth_token => $auth_token,
42 room_id => $room_id,
43 from => $from,
44 message => $msg,
45 message_format => $message_format,
46 notify => $notify,
47 color => $color,
48 format => $format,
49 ]
50 );
51 0 ▶ $res->is_success or die $res->status_line;
Branch: 1 branch
BranchTrueFalseTotal
$res->is_success or die $res->status_line 0 0 0
52 0 $context->log( info => "posted to $room_id." );
53 }
54 }
55 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
56  
57 1 1;
58 __END__
↑ Summary