line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::MirrorMerger::Mirror; |
2
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
50
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
39
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
914
|
use URI; |
|
2
|
|
|
|
|
7655
|
|
|
2
|
|
|
|
|
47
|
|
6
|
2
|
|
|
2
|
|
11
|
use URI::Escape (); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
38
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
8
|
use Class::Accessor::Lite ro => [qw/name base_url/]; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
4
|
|
|
4
|
0
|
820
|
my ($class, $url) = @_; |
12
|
4
|
|
|
|
|
19
|
my $base_url = URI->new($url)->canonical(); |
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
|
|
5195
|
my $scheme = $base_url->scheme; |
15
|
4
|
|
|
|
|
43
|
my $name; |
16
|
4
|
50
|
33
|
|
|
31
|
if ($scheme eq 'http' || $scheme eq 'https' || $scheme eq 'ftp') { |
|
|
50
|
33
|
|
|
|
|
17
|
0
|
|
|
|
|
0
|
$name = $base_url->host; |
18
|
|
|
|
|
|
|
} elsif ($scheme eq 'file') { |
19
|
4
|
|
|
|
|
9
|
$name = URI::Escape::uri_escape_utf8($base_url->file); |
20
|
|
|
|
|
|
|
} else { |
21
|
0
|
|
|
|
|
0
|
die "Unknown mirror scheme: $url"; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
|
|
2485
|
bless { |
25
|
|
|
|
|
|
|
name => $name, |
26
|
|
|
|
|
|
|
base_url => $base_url, |
27
|
|
|
|
|
|
|
} => $class; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub index_url { |
31
|
3
|
|
|
3
|
0
|
8
|
my $self = shift; |
32
|
3
|
|
|
|
|
9
|
my $index_url = $self->base_url->clone(); |
33
|
3
|
|
|
|
|
64
|
$index_url->path(_join_path($index_url->path, 'modules/02packages.details.txt.gz')); |
34
|
3
|
|
|
|
|
106
|
return $index_url; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub package_url { |
38
|
3
|
|
|
3
|
0
|
7
|
my ($self, $path) = @_; |
39
|
|
|
|
|
|
|
|
40
|
3
|
|
|
|
|
8
|
my $package_url = $self->base_url->clone(); |
41
|
3
|
|
|
|
|
39
|
$package_url->path(_join_path($package_url->path, $self->package_path($path))); |
42
|
3
|
|
|
|
|
80
|
return $package_url; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub package_path { |
46
|
6
|
|
|
6
|
0
|
45
|
my ($self, $path) = @_; |
47
|
6
|
|
|
|
|
18
|
return "authors/id/$path"; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _join_path { |
51
|
6
|
|
|
6
|
|
59
|
my $path = join '/', @_; |
52
|
6
|
|
|
|
|
52
|
$path =~ s!/+!/!g; # canonicalize |
53
|
6
|
|
|
|
|
20
|
return $path; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
__END__ |