line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
15
|
|
|
15
|
|
6234
|
use strict; |
|
15
|
|
|
|
|
116
|
|
|
15
|
|
|
|
|
365
|
|
2
|
15
|
|
|
15
|
|
69
|
use warnings; |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
575
|
|
3
|
|
|
|
|
|
|
package MetaCPAN::API::Rating; |
4
|
|
|
|
|
|
|
# ABSTRACT: Rating information for MetaCPAN::API |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.51'; |
7
|
|
|
|
|
|
|
|
8
|
15
|
|
|
15
|
|
70
|
use Carp; |
|
15
|
|
|
|
|
26
|
|
|
15
|
|
|
|
|
663
|
|
9
|
15
|
|
|
15
|
|
71
|
use Moo::Role; |
|
15
|
|
|
|
|
27
|
|
|
15
|
|
|
|
|
84
|
|
10
|
15
|
|
|
15
|
|
4366
|
use namespace::autoclean; |
|
15
|
|
|
|
|
44
|
|
|
15
|
|
|
|
|
99
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# /rating/{id} |
13
|
|
|
|
|
|
|
# /rating/_search |
14
|
|
|
|
|
|
|
sub rating { |
15
|
2
|
|
|
2
|
1
|
2054
|
my $self = shift; |
16
|
2
|
|
|
|
|
4
|
my $url = ''; |
17
|
2
|
|
|
|
|
5
|
my $error = "Either provide 'id' or 'search'"; |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
|
|
3
|
my %extra_opts = (); |
20
|
|
|
|
|
|
|
|
21
|
2
|
50
|
|
|
|
26
|
if ( @_ == 1 ) { |
|
|
100
|
|
|
|
|
|
22
|
0
|
|
|
|
|
0
|
$url = 'rating/' . shift; |
23
|
|
|
|
|
|
|
} elsif ( @_ ) { |
24
|
1
|
|
|
|
|
4
|
my %opts = @_; |
25
|
|
|
|
|
|
|
|
26
|
1
|
50
|
|
|
|
7
|
if ( defined ( my $id = $opts{'id'} ) ) { |
|
|
50
|
|
|
|
|
|
27
|
0
|
|
|
|
|
0
|
$url = "rating/$id"; |
28
|
|
|
|
|
|
|
} elsif ( defined ( my $search_opts = $opts{'search'} ) ) { |
29
|
0
|
0
|
0
|
|
|
0
|
ref $search_opts && ref $search_opts eq 'HASH' |
30
|
|
|
|
|
|
|
or croak $error; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
0
|
%extra_opts = %{$search_opts}; |
|
0
|
|
|
|
|
0
|
|
33
|
0
|
|
|
|
|
0
|
$url = 'rating/_search'; |
34
|
|
|
|
|
|
|
} else { |
35
|
1
|
|
|
|
|
60
|
croak $error; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} else { |
38
|
1
|
|
|
|
|
141
|
croak $error; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
return $self->fetch( $url, %extra_opts ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |