line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ShipIt::Step::Jaiku; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
5
|
1
|
|
|
1
|
|
571
|
use Net::Jaiku; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use YAML 'LoadFile'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use base qw(ShipIt::Step); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub init { |
16
|
|
|
|
|
|
|
my ($self, $conf) = @_; |
17
|
|
|
|
|
|
|
my $config_file = $conf->value('jaiku.config'); |
18
|
|
|
|
|
|
|
defined $config_file || die "jaiku.config not defined in config\n"; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$config_file =~ s/~/$ENV{HOME}/; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
-e $config_file || die "jaiku.config: $config_file does not exist\n"; |
23
|
|
|
|
|
|
|
-r $config_file || die "jaiku.config: $config_file is not readable\n"; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$self->{config} = LoadFile($config_file); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
defined $self->{config}{username} or |
28
|
|
|
|
|
|
|
die "$config_file: no username defined\n"; |
29
|
|
|
|
|
|
|
defined $self->{config}{userkey} or |
30
|
|
|
|
|
|
|
die "$config_file: no userkey defined\n"; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
for my $key (qw(distname message)) { |
33
|
|
|
|
|
|
|
my $value = $conf->value("jaiku.$key"); |
34
|
|
|
|
|
|
|
defined $value || die "jaiku.$key not defined in config\n"; |
35
|
|
|
|
|
|
|
$self->{$key} = $value; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub run { |
41
|
|
|
|
|
|
|
my ($self, $state) = @_; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my %vars = ( |
44
|
|
|
|
|
|
|
d => $self->{distname}, |
45
|
|
|
|
|
|
|
u => "http://search.cpan.org/dist/$self->{distname}", |
46
|
|
|
|
|
|
|
v => $state->version, |
47
|
|
|
|
|
|
|
'%' => '%' |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
(my $message = $self->{message}) =~ s/%(.)/ $vars{$1} || '%'.$1 /ge; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# warn(), don't die(), if we couldn't send the message, because this |
53
|
|
|
|
|
|
|
# step will presumably come after uploading to CPAN, so we don't want |
54
|
|
|
|
|
|
|
# to skip the rest of the shipit process just because of that. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
if ($state->dry_run) { |
57
|
|
|
|
|
|
|
warn "*** DRY RUN, not jaikuing!\n"; |
58
|
|
|
|
|
|
|
warn "message: $message\n"; |
59
|
|
|
|
|
|
|
return; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my $jaiku = Net::Jaiku->new( |
63
|
|
|
|
|
|
|
username => $self->{config}{username}, |
64
|
|
|
|
|
|
|
userkey => $self->{config}{userkey}, |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$jaiku->setPresence(message => $message) or |
68
|
|
|
|
|
|
|
warn "couldn't send message to jaiku\n"; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |