line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
15
|
|
|
15
|
|
7459
|
use strict; |
|
15
|
|
|
|
|
27
|
|
|
15
|
|
|
|
|
522
|
|
2
|
15
|
|
|
15
|
|
68
|
use warnings; |
|
15
|
|
|
|
|
16
|
|
|
15
|
|
|
|
|
765
|
|
3
|
|
|
|
|
|
|
package MetaCPAN::API::File; |
4
|
|
|
|
|
|
|
# ABSTRACT: File information for MetaCPAN::API |
5
|
|
|
|
|
|
|
$MetaCPAN::API::File::VERSION = '0.50'; |
6
|
15
|
|
|
15
|
|
66
|
use Carp; |
|
15
|
|
|
|
|
20
|
|
|
15
|
|
|
|
|
857
|
|
7
|
15
|
|
|
15
|
|
83
|
use Moo::Role; |
|
15
|
|
|
|
|
18
|
|
|
15
|
|
|
|
|
107
|
|
8
|
15
|
|
|
15
|
|
4147
|
use namespace::autoclean; |
|
15
|
|
|
|
|
32
|
|
|
15
|
|
|
|
|
101
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# /module/{module} |
11
|
|
|
|
|
|
|
# /file/{author}/{release}/{path} |
12
|
|
|
|
|
|
|
# /file/{author}/{release} |
13
|
|
|
|
|
|
|
# /file/{id} |
14
|
|
|
|
|
|
|
sub file { |
15
|
6
|
|
|
6
|
0
|
3760
|
my $self = shift; |
16
|
6
|
|
|
|
|
16
|
my $url = ''; |
17
|
6
|
|
|
|
|
12
|
my $error = "Either provide a module name, 'id', or 'author and 'release' and an optional 'path'"; |
18
|
|
|
|
|
|
|
|
19
|
6
|
100
|
|
|
|
30
|
if ( @_ == 1 ) { |
|
|
100
|
|
|
|
|
|
20
|
1
|
|
|
|
|
5
|
$url = 'module/' . shift; |
21
|
|
|
|
|
|
|
} elsif ( @_ ) { |
22
|
4
|
|
|
|
|
18
|
my %opts = @_; |
23
|
|
|
|
|
|
|
|
24
|
4
|
100
|
66
|
|
|
36
|
if ( defined ( my $id = $opts{'id'} ) ) { |
|
|
100
|
|
|
|
|
|
25
|
1
|
|
|
|
|
5
|
$url = "file/$id"; |
26
|
|
|
|
|
|
|
} elsif ( |
27
|
|
|
|
|
|
|
defined ( my $author = $opts{'author'} ) && |
28
|
|
|
|
|
|
|
defined ( my $release = $opts{'release'} ) |
29
|
|
|
|
|
|
|
) { |
30
|
2
|
|
100
|
|
|
11
|
my $path = $opts{'path'} || ''; |
31
|
2
|
|
|
|
|
12
|
$url = "file/$author/$release/$path"; |
32
|
|
|
|
|
|
|
} else { |
33
|
1
|
|
|
|
|
71
|
croak $error; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} else { |
36
|
1
|
|
|
|
|
172
|
croak $error; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
4
|
|
|
|
|
25
|
return $self->fetch( $url ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |