lib/App/MadEye/Plugin/Notify/Ikachan.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran n/a Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 45 CC 1 SCAR 6.9
CC
1
Cov
0%
notify
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package App::MadEye::Plugin::Notify::Ikachan;
2 use strict;
3 use warnings;
4 use utf8;
5 use base qw/App::MadEye::Plugin::Base/;
6  
7 use Furl;
8  
9 sub notify : Hook {
10 my ($self, $context, $args) = @_;
11  
12 my $conf = $self->{config}->{config};
13 my $url = $conf->{url} or die "missing url";
14 $url =~ s!/$!!g;
15  
16 my $channel = $conf->{channel} or die "missing channel";
17  
18 while (my ($plugin, $results) = each %$args) {
19 $plugin =~ s/.+::Agent:://;
20 for my $result (@$results) {
21 my $msg = "$plugin: ($result->{target}): $result->{message} ";
22  
23 my $ua = Furl->new(
24 timeout => 5,
25 agent => "MadEye/$App::MadEye::VERSION"
26 );
27 my $res = $ua->post("$url/notice", [], [
28 channel => $channel,
29 message => $msg,
30 ]);
31 $res->is_success or die $res->status_line;
32 $context->log( info => "posted to $channel." );
33 }
34 }
35 }
36  
37 1;
38