line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::RaptureReady; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
54770
|
use 5.006001; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
88
|
|
5
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
80
|
|
6
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
66
|
|
7
|
2
|
|
|
2
|
|
11
|
use Carp (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
61
|
|
8
|
2
|
|
|
2
|
|
2396
|
use LWP::UserAgent (); |
|
2
|
|
|
|
|
118794
|
|
|
2
|
|
|
|
|
1451
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.2'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
1
|
|
|
1
|
1
|
791
|
my ($class, @args) = @_; |
16
|
1
|
|
33
|
|
|
10
|
my $self = bless {}, ref($class) || $class; |
17
|
|
|
|
|
|
|
# Default location of the Rapture Index |
18
|
1
|
|
|
|
|
6
|
$self->{url} = 'http://www.raptureready.com/rap2.html'; |
19
|
1
|
|
|
|
|
12
|
$self->{ua} = LWP::UserAgent->new; |
20
|
1
|
|
|
|
|
3848
|
$self->{ua}->agent('WWW::RaptureReady/' . $VERSION); |
21
|
1
|
|
|
|
|
61
|
$self->{ua}->from('blair.christensen@gmail.com'); |
22
|
1
|
|
|
|
|
40
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub url { |
26
|
7
|
|
|
7
|
1
|
975
|
my ($self, $url) = @_; |
27
|
7
|
100
|
|
|
|
21
|
if (defined $url) { |
28
|
3
|
100
|
|
|
|
15
|
if ( $url =~ m{^(?:file|https?):} ) { |
29
|
2
|
|
|
|
|
5
|
$self->{url} = $url; |
30
|
|
|
|
|
|
|
} else { |
31
|
1
|
|
|
|
|
4
|
$self->{url} = 'file:' . $url; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
7
|
|
|
|
|
36
|
return $self->{url}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub fetch { |
38
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
39
|
1
|
|
|
|
|
3
|
my $rv = undef; |
40
|
1
|
|
|
|
|
7
|
my $res = $self->{ua}->get($self->{url}); |
41
|
1
|
50
|
|
|
|
64274
|
if ($res->is_success) { |
42
|
|
|
|
|
|
|
# Fetch and cache the Rapture Index HTML |
43
|
1
|
|
|
|
|
27
|
$self->{content} = $res->content; |
44
|
1
|
|
|
|
|
61
|
$rv = 1; |
45
|
|
|
|
|
|
|
} else { |
46
|
0
|
|
|
|
|
0
|
Carp::carp($res->status_line); |
47
|
|
|
|
|
|
|
} |
48
|
1
|
|
|
|
|
36
|
return $rv; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub index { |
52
|
3
|
|
|
3
|
1
|
7
|
my $self = shift; |
53
|
3
|
|
|
|
|
6
|
my $rv = undef; |
54
|
3
|
50
|
33
|
|
|
18
|
if ($self->{content} or $self->fetch) { |
55
|
|
|
|
|
|
|
# TODO Make this less fragile |
56
|
3
|
50
|
|
|
|
47
|
if ( $self->{content} =~ /> Rapture Index (\d+) ) { |
57
|
3
|
|
|
|
|
7
|
$rv = $1; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
3
|
|
|
|
|
19
|
return $rv; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub change { |
64
|
2
|
|
|
2
|
1
|
6
|
my $self = shift; |
65
|
2
|
|
|
|
|
3
|
my $rv = undef; |
66
|
2
|
50
|
33
|
|
|
9
|
if ($self->{content} or $self->fetch) { |
67
|
|
|
|
|
|
|
# TODO Make this less fragile |
68
|
2
|
50
|
|
|
|
32
|
if ( $self->{content} =~ /Net Change.+?\s+(.+?) ) { |
69
|
2
|
50
|
|
|
|
28
|
$rv = ( $1 eq 'unch' ? 0 : $1 ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
2
|
|
|
|
|
12
|
return $rv; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub updated { |
76
|
2
|
|
|
2
|
1
|
4
|
my $self = shift; |
77
|
2
|
|
|
|
|
4
|
my $rv = undef; |
78
|
2
|
50
|
33
|
|
|
8
|
if ($self->{content} or $self->fetch) { |
79
|
|
|
|
|
|
|
# TODO Make this less fragile |
80
|
2
|
50
|
|
|
|
32
|
if ( $self->{content} =~ /Updated(.+)?<\/p>/ ) { |
81
|
2
|
|
|
|
|
4
|
$rv = $1; |
82
|
|
|
|
|
|
|
# Sigh... |
83
|
2
|
|
|
|
|
8
|
$rv =~ s/ //g; |
84
|
2
|
|
|
|
|
13
|
$rv =~ s/<.+?>//g; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
2
|
|
|
|
|
9
|
return $rv; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; # End of WWW::RaptureReady |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |