line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mirror::YAML::URI; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
41
|
use 5.005; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
96
|
|
4
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
61
|
|
5
|
2
|
|
|
2
|
|
13
|
use URI (); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
44
|
|
6
|
2
|
|
|
2
|
|
11
|
use Params::Util qw{ _STRING _INSTANCE }; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
151
|
|
7
|
2
|
|
|
2
|
|
11
|
use LWP::Simple (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
44
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
11
|
use vars qw{$VERSION}; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
119
|
|
10
|
|
|
|
|
|
|
BEGIN { |
11
|
2
|
|
|
2
|
|
677
|
$VERSION = '0.03'; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
##################################################################### |
19
|
|
|
|
|
|
|
# Constructor |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
22
|
14
|
|
|
14
|
0
|
16
|
my $class = shift; |
23
|
14
|
|
|
|
|
37
|
my $self = bless { @_ }, $class; |
24
|
14
|
50
|
|
|
|
25
|
unless ( _INSTANCE($self->uri, 'URI') ) { |
25
|
0
|
|
|
|
|
0
|
return undef; |
26
|
|
|
|
|
|
|
} |
27
|
14
|
|
|
|
|
127
|
return $self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub uri { |
31
|
28
|
|
|
28
|
0
|
1219
|
$_[0]->{uri}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub yaml { |
35
|
0
|
|
|
0
|
0
|
0
|
$_[0]->{yaml}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub live { |
39
|
14
|
|
|
14
|
0
|
33
|
!! $_[0]->{live}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub lag { |
43
|
0
|
|
|
0
|
0
|
0
|
$_[0]->{lag}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
##################################################################### |
51
|
|
|
|
|
|
|
# Main Methods |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub get { |
54
|
14
|
|
|
14
|
0
|
25
|
my $self = shift; |
55
|
14
|
|
|
|
|
114
|
my $uri = URI->new('mirror.yml')->abs( $self->uri ); |
56
|
14
|
|
|
|
|
4460
|
my $before = Time::HiRes::time(); |
57
|
14
|
|
|
|
|
61
|
my $yaml = LWP::Simple::get($uri); |
58
|
14
|
50
|
66
|
|
|
4088386
|
unless ( $yaml and $yaml =~ /^---/ ) { |
59
|
|
|
|
|
|
|
# Site does not exist, or is broken |
60
|
14
|
|
|
|
|
122
|
return $self->{live} = 0; |
61
|
|
|
|
|
|
|
} |
62
|
0
|
|
|
|
|
|
$self->{lag} = Time::HiRes::time() - $before; |
63
|
0
|
|
|
|
|
|
$self->{yaml} = Mirror::YAML->read_string( $yaml ); |
64
|
0
|
|
|
|
|
|
return $self->{live} = 1; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |