line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
15
|
|
|
15
|
|
7325
|
use strict; |
|
15
|
|
|
|
|
26
|
|
|
15
|
|
|
|
|
541
|
|
2
|
15
|
|
|
15
|
|
73
|
use warnings; |
|
15
|
|
|
|
|
21
|
|
|
15
|
|
|
|
|
665
|
|
3
|
|
|
|
|
|
|
package MetaCPAN::API::Distribution; |
4
|
|
|
|
|
|
|
# ABSTRACT: Distribution information for MetaCPAN::API |
5
|
|
|
|
|
|
|
$MetaCPAN::API::Distribution::VERSION = '0.50'; |
6
|
15
|
|
|
15
|
|
66
|
use Carp; |
|
15
|
|
|
|
|
20
|
|
|
15
|
|
|
|
|
785
|
|
7
|
15
|
|
|
15
|
|
116
|
use Moo::Role; |
|
15
|
|
|
|
|
23
|
|
|
15
|
|
|
|
|
80
|
|
8
|
15
|
|
|
15
|
|
4295
|
use namespace::autoclean; |
|
15
|
|
|
|
|
26
|
|
|
15
|
|
|
|
|
114
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# /distribution/{distribution} |
11
|
|
|
|
|
|
|
sub distribution { |
12
|
5
|
|
|
5
|
0
|
5035
|
my $self = shift; |
13
|
5
|
|
|
|
|
12
|
my $url = ''; |
14
|
5
|
|
|
|
|
11
|
my $error = "Either provide a distribution or 'search'"; |
15
|
|
|
|
|
|
|
|
16
|
5
|
|
|
|
|
126
|
my %extra_opts = (); |
17
|
|
|
|
|
|
|
|
18
|
5
|
100
|
|
|
|
26
|
if ( @_ == 1 ) { |
|
|
100
|
|
|
|
|
|
19
|
1
|
|
|
|
|
5
|
$url = 'distribution/' . shift; |
20
|
|
|
|
|
|
|
} elsif ( @_ ) { |
21
|
3
|
|
|
|
|
15
|
my %opts = @_; |
22
|
|
|
|
|
|
|
|
23
|
3
|
100
|
|
|
|
19
|
if ( defined ( my $dist = $opts{'distribution'} ) ) { |
|
|
100
|
|
|
|
|
|
24
|
1
|
|
|
|
|
6
|
$url = "distribution/$dist"; |
25
|
|
|
|
|
|
|
} elsif ( defined ( my $search_opts = $opts{'search'} ) ) { |
26
|
1
|
50
|
33
|
|
|
14
|
ref $search_opts && ref $search_opts eq 'HASH' |
27
|
|
|
|
|
|
|
or croak $error; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
3
|
%extra_opts = %{$search_opts}; |
|
1
|
|
|
|
|
6
|
|
30
|
1
|
|
|
|
|
5
|
$url = 'distribution/_search'; |
31
|
|
|
|
|
|
|
} else { |
32
|
1
|
|
|
|
|
99
|
croak $error; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} else { |
35
|
1
|
|
|
|
|
190
|
croak $error; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
3
|
|
|
|
|
21
|
return $self->fetch( $url, %extra_opts ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |