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