line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
15
|
|
|
15
|
|
8907
|
use strict; |
|
15
|
|
|
|
|
29
|
|
|
15
|
|
|
|
|
583
|
|
2
|
15
|
|
|
15
|
|
80
|
use warnings; |
|
15
|
|
|
|
|
30
|
|
|
15
|
|
|
|
|
721
|
|
3
|
|
|
|
|
|
|
package MetaCPAN::API::Rating; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$MetaCPAN::API::Rating::VERSION = '0.44'; |
6
|
15
|
|
|
15
|
|
98
|
use Carp; |
|
15
|
|
|
|
|
30
|
|
|
15
|
|
|
|
|
1002
|
|
7
|
15
|
|
|
15
|
|
219
|
use Any::Moose 'Role'; |
|
15
|
|
|
|
|
35
|
|
|
15
|
|
|
|
|
123
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub rating { |
12
|
2
|
|
|
2
|
1
|
1619
|
my $self = shift; |
13
|
2
|
|
|
|
|
4
|
my $url = ''; |
14
|
2
|
|
|
|
|
4
|
my $error = "Either provide 'id' or 'search'"; |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
|
|
3
|
my %extra_opts = (); |
17
|
|
|
|
|
|
|
|
18
|
2
|
50
|
|
|
|
10
|
if ( @_ == 1 ) { |
|
|
100
|
|
|
|
|
|
19
|
0
|
|
|
|
|
0
|
$url = 'rating/' . shift; |
20
|
|
|
|
|
|
|
} elsif ( @_ ) { |
21
|
1
|
|
|
|
|
5
|
my %opts = @_; |
22
|
|
|
|
|
|
|
|
23
|
1
|
50
|
|
|
|
7
|
if ( defined ( my $id = $opts{'id'} ) ) { |
|
|
50
|
|
|
|
|
|
24
|
0
|
|
|
|
|
0
|
$url = "rating/$id"; |
25
|
|
|
|
|
|
|
} elsif ( defined ( my $search_opts = $opts{'search'} ) ) { |
26
|
0
|
0
|
0
|
|
|
0
|
ref $search_opts && ref $search_opts eq 'HASH' |
27
|
|
|
|
|
|
|
or croak $error; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
0
|
%extra_opts = %{$search_opts}; |
|
0
|
|
|
|
|
0
|
|
30
|
0
|
|
|
|
|
0
|
$url = 'rating/_search'; |
31
|
|
|
|
|
|
|
} else { |
32
|
1
|
|
|
|
|
95
|
croak $error; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} else { |
35
|
1
|
|
|
|
|
173
|
croak $error; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
return $self->fetch( $url, %extra_opts ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=pod |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
MetaCPAN::API::Rating - Rating information for MetaCPAN::API |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 VERSION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
version 0.44 |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 DESCRIPTION |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This role provides MetaCPAN::API with fetching information about CPAN |
58
|
|
|
|
|
|
|
ratings. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 METHODS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 rating |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $result = $mcpan->rating( id => 'UC6tqabqR-y3xxZk0tgVXQ' ); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Searches MetaCPAN for CPAN ratings. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
You can do complex searches using 'search' parameter: |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $result = $mcpan->rating( |
71
|
|
|
|
|
|
|
search => { |
72
|
|
|
|
|
|
|
filter => "distribution:Moose", |
73
|
|
|
|
|
|
|
fields => [ "date", "rating" ], |
74
|
|
|
|
|
|
|
}, |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
These searches will give you the right _id to use for more detailed |
78
|
|
|
|
|
|
|
information. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 AUTHOR |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Sawyer X <xsawyerx@cpan.org> |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Sawyer X. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
89
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|