| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Acme::CPANAuthors::Utils::Kwalitee; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1011
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
55
|
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
57
|
|
|
5
|
2
|
|
|
2
|
|
17456
|
use HTTP::Tiny; |
|
|
2
|
|
|
|
|
126051
|
|
|
|
2
|
|
|
|
|
91
|
|
|
6
|
2
|
|
|
2
|
|
1589
|
use JSON::PP (); |
|
|
2
|
|
|
|
|
18145
|
|
|
|
2
|
|
|
|
|
599
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my $ua; |
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
55
|
sub _uri { "http://api.cpanauthors.org/kwalitee/" . shift } |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _ua { |
|
13
|
1
|
|
|
1
|
|
4
|
my $class = shift; |
|
14
|
1
|
50
|
|
|
|
6
|
$ua = $_[0] if @_; |
|
15
|
1
|
|
33
|
|
|
11
|
$ua ||= HTTP::Tiny->new(env_proxy => 1); |
|
16
|
1
|
|
|
|
|
110
|
$ua; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub fetch { |
|
20
|
1
|
|
|
1
|
1
|
3
|
my ($class, $id) = @_; |
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
50
|
|
|
|
6
|
return unless $id; |
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
3
|
my $res = $class->_ua->get(_uri(lc $id)); |
|
25
|
1
|
50
|
33
|
|
|
1709990
|
unless ($res->{success} && $res->{status} == 200) { |
|
26
|
0
|
|
|
|
|
0
|
$class->_error("$res->{status} $res->{reason}"); |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
5
|
my $json = eval { JSON::PP::decode_json($res->{content}) }; |
|
|
1
|
|
|
|
|
12
|
|
|
30
|
1
|
50
|
|
|
|
770181
|
if ($@) { |
|
31
|
0
|
|
|
|
|
0
|
$class->_error($@); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
1
|
|
|
|
|
19
|
return $json; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _error { |
|
37
|
0
|
|
|
0
|
|
|
my ($class, $error) = @_; |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
die "API SERVER ERROR\n" |
|
40
|
|
|
|
|
|
|
. "Couldn't parse kwalitee info from the api server\n" |
|
41
|
|
|
|
|
|
|
. " $error\n" |
|
42
|
|
|
|
|
|
|
. "Sorry for the inconvenience. If this lingers long,\n" |
|
43
|
|
|
|
|
|
|
. "please drop a line to .\n"; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |