line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
15
|
|
|
15
|
|
6177
|
use strict; |
|
15
|
|
|
|
|
31
|
|
|
15
|
|
|
|
|
399
|
|
2
|
15
|
|
|
15
|
|
74
|
use warnings; |
|
15
|
|
|
|
|
32
|
|
|
15
|
|
|
|
|
607
|
|
3
|
|
|
|
|
|
|
package MetaCPAN::API::File; |
4
|
|
|
|
|
|
|
# ABSTRACT: File information for MetaCPAN::API |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.51'; |
7
|
|
|
|
|
|
|
|
8
|
15
|
|
|
15
|
|
73
|
use Carp; |
|
15
|
|
|
|
|
25
|
|
|
15
|
|
|
|
|
623
|
|
9
|
15
|
|
|
15
|
|
190
|
use Moo::Role; |
|
15
|
|
|
|
|
30
|
|
|
15
|
|
|
|
|
158
|
|
10
|
15
|
|
|
15
|
|
4328
|
use namespace::autoclean; |
|
15
|
|
|
|
|
30
|
|
|
15
|
|
|
|
|
78
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# /module/{module} |
13
|
|
|
|
|
|
|
# /file/{author}/{release}/{path} |
14
|
|
|
|
|
|
|
# /file/{author}/{release} |
15
|
|
|
|
|
|
|
# /file/{id} |
16
|
|
|
|
|
|
|
sub file { |
17
|
6
|
|
|
6
|
1
|
5154
|
my $self = shift; |
18
|
6
|
|
|
|
|
14
|
my $url = ''; |
19
|
6
|
|
|
|
|
15
|
my $error = "Either provide a module name, 'id', or 'author and 'release' and an optional 'path'"; |
20
|
|
|
|
|
|
|
|
21
|
6
|
100
|
|
|
|
33
|
if ( @_ == 1 ) { |
|
|
100
|
|
|
|
|
|
22
|
1
|
|
|
|
|
4
|
$url = 'module/' . shift; |
23
|
|
|
|
|
|
|
} elsif ( @_ ) { |
24
|
4
|
|
|
|
|
23
|
my %opts = @_; |
25
|
|
|
|
|
|
|
|
26
|
4
|
100
|
66
|
|
|
64
|
if ( defined ( my $id = $opts{'id'} ) ) { |
|
|
100
|
|
|
|
|
|
27
|
1
|
|
|
|
|
7
|
$url = "file/$id"; |
28
|
|
|
|
|
|
|
} elsif ( |
29
|
|
|
|
|
|
|
defined ( my $author = $opts{'author'} ) && |
30
|
|
|
|
|
|
|
defined ( my $release = $opts{'release'} ) |
31
|
|
|
|
|
|
|
) { |
32
|
2
|
|
100
|
|
|
14
|
my $path = $opts{'path'} || ''; |
33
|
2
|
|
|
|
|
10
|
$url = "file/$author/$release/$path"; |
34
|
|
|
|
|
|
|
} else { |
35
|
1
|
|
|
|
|
60
|
croak $error; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} else { |
38
|
1
|
|
|
|
|
133
|
croak $error; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
4
|
|
|
|
|
22
|
return $self->fetch( $url ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |