blib/lib/Giovanni/Plugins/Hipchat.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod n/a totaltotal 0.0% 0 / 22 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Giovanni::Plugins::Hipchat;
2  
3 use Mouse::Role;
4 use Data::Dumper;
5 use LWP::UserAgent;
6  
7 around 'send_notify' => sub {
8 my ( $orig, $self, $ssh ) = @_;
9  
10 print "notify via HipChat\n";
11 my @tos = split(/\s*,\s*/, $self->config->{hipchat_rooms});
12 my $msg = $ENV{USER}
13 . ' just ran a '
14 . $self->config->{command} . ' for '
15 . $self->config->{project} . ' on '
16 . $ssh->get_host;
17 my $ua = LWP::UserAgent->new();
18 my $url = 'https://api.hipchat.com/v1/rooms/message?format=json&auth_token='.$self->config->{hipchat_token};
19 foreach my $to (@tos){
20 $ua->post($url, {
21 room_id => $to,
22 from => 'Giovanni',
23 message => $msg,
24 message_format => 'text',
25 notify => 1,
26 color => 'green',
27 });
28 }
29 };
30  
31 1;
32  
33 __END__