line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
use 5.006; use strict; use warnings; our $VERSION = '0.02'; |
2
|
1
|
|
|
1
|
|
55315
|
use MetaCPAN::Client; use HTTP::Tiny::Mech; use WWW::Mechanize::Cached; use CHI; |
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
3
|
1
|
|
|
1
|
|
437
|
use base 'Catalyst::Model'; |
|
1
|
|
|
1
|
|
300452
|
|
|
1
|
|
|
1
|
|
26
|
|
|
1
|
|
|
1
|
|
366
|
|
|
1
|
|
|
|
|
593
|
|
|
1
|
|
|
|
|
24
|
|
|
1
|
|
|
|
|
398
|
|
|
1
|
|
|
|
|
156175
|
|
|
1
|
|
|
|
|
42
|
|
|
1
|
|
|
|
|
721
|
|
|
1
|
|
|
|
|
39493
|
|
|
1
|
|
|
|
|
93
|
|
4
|
1
|
|
|
1
|
|
10
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
551
|
|
5
|
|
|
|
|
|
|
my $self = shift->next::method(@_); |
6
|
|
|
|
|
|
|
my $c = shift; |
7
|
0
|
|
|
0
|
1
|
|
$self->{client} = MetaCPAN::Client->new( |
8
|
0
|
|
|
|
|
|
ua => HTTP::Tiny::Mech->new( |
9
|
0
|
|
|
|
|
|
mechua => WWW::Mechanize::Cached->new( |
10
|
|
|
|
|
|
|
cache => CHI->new( |
11
|
|
|
|
|
|
|
driver => 'File', |
12
|
|
|
|
|
|
|
root_dir => '/tmp/metacpan-cache', |
13
|
|
|
|
|
|
|
), |
14
|
|
|
|
|
|
|
), |
15
|
|
|
|
|
|
|
), |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
return $self; |
18
|
|
|
|
|
|
|
} |
19
|
0
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
shift->{client}; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
0
|
1
|
|
my ($self, $client, $data, $method, @params) = @_; |
24
|
|
|
|
|
|
|
$client ||= $self->client; |
25
|
|
|
|
|
|
|
my $res = eval { |
26
|
|
|
|
|
|
|
$client->$method(@params) |
27
|
0
|
|
|
0
|
1
|
|
}; |
28
|
0
|
|
0
|
|
|
|
if ($@) { |
29
|
0
|
|
|
|
|
|
return { |
30
|
0
|
|
|
|
|
|
error => $@ |
31
|
|
|
|
|
|
|
}; |
32
|
0
|
0
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
return $data ? $res->{data} : $res; |
34
|
0
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my ($self, $resultset) = @_; |
37
|
0
|
0
|
|
|
|
|
my @results; |
38
|
|
|
|
|
|
|
my $total = $resultset->total; |
39
|
|
|
|
|
|
|
while ($total) { |
40
|
|
|
|
|
|
|
my $result = $resultset->next; |
41
|
0
|
|
|
0
|
1
|
|
push @results, $result->{data}; |
42
|
0
|
|
|
|
|
|
$total--; |
43
|
0
|
|
|
|
|
|
} |
44
|
0
|
|
|
|
|
|
return \@results; |
45
|
0
|
|
|
|
|
|
} |
46
|
0
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $self = shift; |
49
|
0
|
|
|
|
|
|
my $author = $self->request(undef, 0, 'author', @_); |
50
|
|
|
|
|
|
|
return $author if $author->{error}; |
51
|
|
|
|
|
|
|
my $releases = $self->request($author, 0, 'releases'); |
52
|
0
|
|
|
0
|
1
|
|
return $releases if $releases->{error}; |
53
|
|
|
|
|
|
|
return $self->resultset_to_array($releases); |
54
|
|
|
|
|
|
|
} |
55
|
0
|
|
|
0
|
1
|
|
|
56
|
0
|
|
|
|
|
|
my $self = shift; |
57
|
0
|
0
|
|
|
|
|
my $author = $self->request(undef, 0, 'author', @_); |
58
|
0
|
|
|
|
|
|
return $author if $author->{error}; |
59
|
0
|
0
|
|
|
|
|
my $releases = $self->request($author, 0, 'releases'); |
60
|
0
|
|
|
|
|
|
return $releases if $releases->{error}; |
61
|
|
|
|
|
|
|
return $releases->total; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
0
|
1
|
|
|
65
|
0
|
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $self = shift; |
68
|
0
|
0
|
|
|
|
|
my $favorite = $self->request(undef, 0, 'favorite', @_); |
69
|
0
|
|
|
|
|
|
return $favorite if $favorite->{error}; |
70
|
|
|
|
|
|
|
return $self->resultset_to_array($favorite); |
71
|
|
|
|
|
|
|
} |
72
|
0
|
|
|
0
|
1
|
|
|
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
0
|
1
|
|
my $module = shift->request(undef, 0, 'module', @_); |
75
|
|
|
|
|
|
|
return $module if $module->{error}; |
76
|
0
|
|
|
0
|
1
|
|
return $module->pod(); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
0
|
1
|
|
my $module = shift->request(undef, 0, 'module', @_); |
80
|
0
|
|
|
|
|
|
return $module if $module->{error}; |
81
|
0
|
0
|
|
|
|
|
return $module->source(); |
82
|
0
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
0
|
1
|
|
|
86
|
|
|
|
|
|
|
my $pod = shift->request(undef, 0, 'pod', @_); |
87
|
|
|
|
|
|
|
return $pod->plain(); |
88
|
0
|
|
|
0
|
1
|
|
} |
89
|
0
|
0
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
my $self = shift; |
91
|
|
|
|
|
|
|
my $rating = $self->request(undef, 0, 'rating', @_); |
92
|
|
|
|
|
|
|
return $rating if $rating->{error}; |
93
|
|
|
|
|
|
|
return $self->resultset_to_array($rating); |
94
|
0
|
|
|
0
|
1
|
|
} |
95
|
0
|
0
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
my $release = shift->request(undef, 0, 'release', @_); |
98
|
|
|
|
|
|
|
return $release->changes(); |
99
|
0
|
|
|
0
|
1
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
0
|
1
|
|
1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
0
|
1
|
|
=head1 NAME |
105
|
0
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Catalyst::Model::MetaCPAN::Client - Catalyst Model for MetaCPAN |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 VERSION |
109
|
0
|
|
|
0
|
1
|
|
|
110
|
0
|
|
|
|
|
|
Version 0.02 |
111
|
0
|
0
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
=cut |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SYNOPSIS |
115
|
0
|
|
|
0
|
1
|
|
|
116
|
|
|
|
|
|
|
package TestApp::Model::MetaCPAN; |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
0
|
1
|
|
use parent "Catalyst::Model::MetaCPAN::Client"; |
119
|
0
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
... |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
package TestApp::Controller::MetaCPAN; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
use Moose; |
126
|
|
|
|
|
|
|
use namespace::autoclean; |
127
|
|
|
|
|
|
|
use JSON; |
128
|
|
|
|
|
|
|
BEGIN { |
129
|
|
|
|
|
|
|
extends 'Catalyst::Controller'; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub author :Chained('/') :PathPart('author') :Args(1) { |
133
|
|
|
|
|
|
|
my ($self, $c, $arg) = @_; |
134
|
|
|
|
|
|
|
my $author = $c->model('MetaCPAN')->author($arg); |
135
|
|
|
|
|
|
|
$c->res->body(encode_json($author)); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Beta. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 new |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 client |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 request |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 resultset_to_array |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 author |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=cut |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 author_releases |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head2 total_author_releases |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head2 cover |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 distribution |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=cut |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head2 download_url |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=cut |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head2 favorites |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=cut |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head2 module |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=cut |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head2 module_pod |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=cut |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head2 module_source |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=cut |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head2 package |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=cut |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head2 permission |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=cut |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head2 pod |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=cut |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head2 ratings |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=cut |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head2 release |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=cut |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head2 release_changes |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=cut |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head1 AUTHOR |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
LNATION, C<< <email at lnation.org> >> |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=head1 BUGS |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-catalyst-model-metacpan-client at rt.cpan.org>, or through |
233
|
|
|
|
|
|
|
the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Model-MetaCPAN-Client>. I will be notified, and then you'll |
234
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head1 SUPPORT |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
perldoc Catalyst::Model::MetaCPAN::Client |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
You can also look for information at: |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=over 4 |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-Model-MetaCPAN-Client> |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=item * CPAN Ratings |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
L<https://cpanratings.perl.org/d/Catalyst-Model-MetaCPAN-Client> |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=item * Search CPAN |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
L<https://metacpan.org/release/Catalyst-Model-MetaCPAN-Client> |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=back |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
This software is Copyright (c) 2022 by LNATION. |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
This is free software, licensed under: |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=cut |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
1; # End of Catalyst::Model::MetaCPAN::Client |