line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
925
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
70
|
|
2
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
61
|
|
3
|
2
|
|
|
2
|
|
10
|
use utf8; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
13
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Ukigumo::Client::Notify::Ikachan; |
6
|
2
|
|
|
2
|
|
56
|
use Mouse; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
12
|
|
7
|
2
|
|
|
2
|
|
559
|
use Ukigumo::Constants; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
155
|
|
8
|
2
|
|
|
2
|
|
10
|
use Ukigumo::Helper qw(status_str); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
94
|
|
9
|
2
|
|
|
2
|
|
1678
|
use String::IRC; |
|
2
|
|
|
|
|
1842
|
|
|
2
|
|
|
|
|
210
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has 'url' => ( |
12
|
|
|
|
|
|
|
is => 'ro', |
13
|
|
|
|
|
|
|
isa => 'Str', |
14
|
|
|
|
|
|
|
required => 1, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has 'channel' => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => 'Str', |
20
|
|
|
|
|
|
|
required => 1, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has 'ignore_success' => ( |
24
|
|
|
|
|
|
|
is => 'ro', |
25
|
|
|
|
|
|
|
isa => 'Bool', |
26
|
|
|
|
|
|
|
required => 0, |
27
|
|
|
|
|
|
|
default => 1, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has ignore_skip => ( |
31
|
|
|
|
|
|
|
is => 'ro', |
32
|
|
|
|
|
|
|
isa => 'Bool', |
33
|
|
|
|
|
|
|
default => 1, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has 'method' => ( |
37
|
|
|
|
|
|
|
is => 'ro', |
38
|
|
|
|
|
|
|
isa => 'Str', |
39
|
|
|
|
|
|
|
default => 'notice', # you can specify 'privmsg' |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
2
|
|
|
2
|
|
13
|
no Mouse; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
49
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub send { |
45
|
0
|
|
|
0
|
0
|
|
my ($self, $c, $status, $last_status, $report_url, $current_revision) = @_; |
46
|
|
|
|
|
|
|
|
47
|
0
|
0
|
0
|
|
|
|
if ( $self->ignore_success && $status eq STATUS_SUCCESS && defined($last_status) && ($last_status eq STATUS_SUCCESS || $last_status eq STATUS_SKIP) ) { |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$c->logger->infof( |
49
|
|
|
|
|
|
|
"The test was succeeded. There is no reason to notify($status, $last_status)."); |
50
|
0
|
|
|
|
|
|
return; |
51
|
|
|
|
|
|
|
} |
52
|
0
|
0
|
0
|
|
|
|
if ( $self->ignore_skip && $status eq STATUS_SKIP ) { |
53
|
0
|
|
|
|
|
|
$c->logger->infof( "The test was skiped. There is no reason to notify."); |
54
|
0
|
|
|
|
|
|
return; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $ua = $c->user_agent(); |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $url = $self->url; |
60
|
0
|
|
|
|
|
|
$url =~ s!/$!!; # remove trailing slash |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my $message = sprintf( "%s %s [%s] %s %s", |
63
|
|
|
|
|
|
|
$report_url, $c->project, $c->branch, _status_color_message($status), |
64
|
|
|
|
|
|
|
substr($current_revision, 0, 10) ); |
65
|
0
|
|
|
|
|
|
$c->logger->infof("Sending message to irc server: $message"); |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $res = |
68
|
|
|
|
|
|
|
$ua->post( "$url/$self->{method}", |
69
|
|
|
|
|
|
|
{ channel => $self->channel, message => $message } ); |
70
|
0
|
0
|
|
|
|
|
if ( $res->is_success ) { |
71
|
0
|
|
|
|
|
|
$c->logger->infof("Sent notification for $self->{url} $self->{channel}"); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
else { |
74
|
0
|
|
|
|
|
|
die "Cannot send ikachan notification: " |
75
|
|
|
|
|
|
|
. join( ' ', |
76
|
|
|
|
|
|
|
'notice', $self->url, $self->channel, $res->status_line ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _status_color_message { |
81
|
0
|
|
|
0
|
|
|
my $status = shift; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my $color; |
84
|
0
|
0
|
0
|
|
|
|
if ($status eq STATUS_SUCCESS) { |
|
|
0
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
$color = 'green'; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
elsif ($status eq STATUS_FAIL || $status eq STATUS_TIMEOUT) { |
88
|
0
|
|
|
|
|
|
$color = 'red'; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
else { |
91
|
0
|
|
|
|
|
|
$color = 'brown'; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
String::IRC->new(status_str($status))->$color('white'); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
__END__ |