line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hubot::Scripts::uptime; |
2
|
|
|
|
|
|
|
$Hubot::Scripts::uptime::VERSION = '0.1.9'; |
3
|
1
|
|
|
1
|
|
1530
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
5
|
1
|
|
|
1
|
|
1616
|
use DateTime; |
|
1
|
|
|
|
|
213804
|
|
|
1
|
|
|
|
|
38
|
|
6
|
1
|
|
|
1
|
|
4409
|
use DateTime::Format::Duration; |
|
1
|
|
|
|
|
9530
|
|
|
1
|
|
|
|
|
501
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub load { |
9
|
0
|
|
|
0
|
0
|
|
my ( $class, $robot ) = @_; |
10
|
0
|
|
|
|
|
|
my $start = DateTime->now; |
11
|
|
|
|
|
|
|
$robot->respond( |
12
|
|
|
|
|
|
|
qr/uptime/i, |
13
|
|
|
|
|
|
|
sub { |
14
|
0
|
|
|
0
|
|
|
my $msg = shift; |
15
|
0
|
|
|
|
|
|
uptimeMe( $msg, $start, sub { $msg->send(shift) } ); |
|
0
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
} |
17
|
0
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub uptimeMe { |
21
|
0
|
|
|
0
|
0
|
|
my ( $msg, $start, $cb ) = @_; |
22
|
0
|
|
|
|
|
|
my $now = DateTime->now; |
23
|
0
|
|
|
|
|
|
my $duration = $now - $start; |
24
|
0
|
|
|
|
|
|
my $d |
25
|
|
|
|
|
|
|
= DateTime::Format::Duration->new( |
26
|
|
|
|
|
|
|
pattern => '%Y years, %m months, %e days, ' |
27
|
|
|
|
|
|
|
. '%H hours, %M minutes, %S seconds' ); |
28
|
0
|
|
|
|
|
|
$d->set_normalizing(1); |
29
|
0
|
|
|
|
|
|
$cb->( "I've been sentient for " . $d->format_duration($duration) ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 NAME |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Hubot::Scripts::uptime |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 VERSION |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
version 0.1.9 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SYNOPSIS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
hubot uptime - display robot's uptime |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 AUTHOR |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Hyungsuk Hong <hshong@perl.kr> |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |