| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::AUR::RPC; |
|
2
|
|
|
|
|
|
|
|
|
3
|
12
|
|
|
12
|
|
931
|
use warnings 'FATAL' => 'all'; |
|
|
12
|
|
|
|
|
52
|
|
|
|
12
|
|
|
|
|
432
|
|
|
4
|
12
|
|
|
12
|
|
48
|
use strict; |
|
|
12
|
|
|
|
|
20
|
|
|
|
12
|
|
|
|
|
308
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
12
|
|
|
12
|
|
6885
|
use JSON qw(); |
|
|
12
|
|
|
|
|
120787
|
|
|
|
12
|
|
|
|
|
285
|
|
|
7
|
12
|
|
|
12
|
|
81
|
use Carp qw(); |
|
|
12
|
|
|
|
|
18
|
|
|
|
12
|
|
|
|
|
190
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
12
|
|
|
12
|
|
4301
|
use WWW::AUR::URI qw( rpc_uri ); |
|
|
12
|
|
|
|
|
26
|
|
|
|
12
|
|
|
|
|
825
|
|
|
10
|
12
|
|
|
12
|
|
50
|
use WWW::AUR qw( _category_name _useragent ); |
|
|
12
|
|
|
|
|
15
|
|
|
|
12
|
|
|
|
|
9638
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my %_RENAME_FOR = ( 'Description' => 'desc', |
|
13
|
|
|
|
|
|
|
'NumVotes' => 'votes', |
|
14
|
|
|
|
|
|
|
'CategoryID' => 'category', |
|
15
|
|
|
|
|
|
|
'OutOfDate' => 'outdated', |
|
16
|
|
|
|
|
|
|
'FirstSubmitted' => 'ctime', |
|
17
|
|
|
|
|
|
|
'LastModified' => 'mtime', |
|
18
|
|
|
|
|
|
|
); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#---HELPER FUNCTION--- |
|
21
|
|
|
|
|
|
|
# Purpose: Map JSON package info keys to their new names... |
|
22
|
|
|
|
|
|
|
sub _munge_result |
|
23
|
|
|
|
|
|
|
{ |
|
24
|
7039
|
|
|
7039
|
|
5730
|
my ($info_ref) = @_; |
|
25
|
|
|
|
|
|
|
|
|
26
|
7039
|
|
|
|
|
4870
|
my %result; |
|
27
|
7039
|
|
|
|
|
23044
|
for my $key ( keys %$info_ref ) { |
|
28
|
105585
|
|
66
|
|
|
201443
|
my $newkey = $_RENAME_FOR{ $key } || lc $key; |
|
29
|
105585
|
|
|
|
|
133405
|
$result{ $newkey } = $info_ref->{ $key }; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
7039
|
|
|
|
|
16360
|
$result{category} = _category_name( $result{category} ); |
|
33
|
|
|
|
|
|
|
|
|
34
|
7039
|
|
|
|
|
17803
|
return \%result; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#---CLASS/OBJECT METHOD--- |
|
38
|
|
|
|
|
|
|
sub info |
|
39
|
|
|
|
|
|
|
{ |
|
40
|
109
|
|
|
109
|
0
|
913
|
my ($name) = @_; |
|
41
|
|
|
|
|
|
|
|
|
42
|
109
|
|
|
|
|
567
|
my $uri = rpc_uri( "info", $name ); |
|
43
|
109
|
|
|
|
|
1040
|
my $ua = _useragent(); |
|
44
|
109
|
|
|
|
|
53111
|
$ua->InitTLS; |
|
45
|
109
|
|
|
|
|
413
|
my $resp = $ua->get( $uri ); |
|
46
|
|
|
|
|
|
|
|
|
47
|
109
|
50
|
|
|
|
18659848
|
Carp::croak 'Failed to call info AUR RPC: ' . $resp->status_line |
|
48
|
|
|
|
|
|
|
unless $resp->is_success; |
|
49
|
|
|
|
|
|
|
|
|
50
|
109
|
|
|
|
|
2740
|
my $json = JSON->new; |
|
51
|
109
|
|
|
|
|
721
|
my $data = $json->decode( $resp->content ); |
|
52
|
|
|
|
|
|
|
|
|
53
|
109
|
50
|
|
|
|
6772
|
if ( $data->{type} eq "error" ) { |
|
|
|
100
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
0
|
Carp::croak "Remote error: $data->{results}"; |
|
55
|
|
|
|
|
|
|
} elsif ( $data->{resultcount} == 0 ) { |
|
56
|
1
|
|
|
|
|
94
|
return undef; |
|
57
|
|
|
|
|
|
|
} else { |
|
58
|
108
|
|
|
|
|
487
|
return _munge_result( $data->{results} ); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub multiinfo |
|
63
|
|
|
|
|
|
|
{ |
|
64
|
1
|
|
|
1
|
0
|
383
|
my (@names) = @_; |
|
65
|
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
89
|
my $uri = rpc_uri( "multiinfo", @names ); |
|
67
|
1
|
|
|
|
|
8
|
my $ua = _useragent(); |
|
68
|
1
|
|
|
|
|
214
|
$ua->InitTLS; |
|
69
|
1
|
|
|
|
|
4
|
my $resp = $ua->get( $uri ); |
|
70
|
|
|
|
|
|
|
|
|
71
|
1
|
50
|
|
|
|
162121
|
Carp::croak 'Failed to call multiinfo AUR RPC: ' . $resp->status_line |
|
72
|
|
|
|
|
|
|
unless $resp->is_success; |
|
73
|
|
|
|
|
|
|
|
|
74
|
1
|
|
|
|
|
24
|
my $json = JSON->new; |
|
75
|
1
|
|
|
|
|
47
|
my $data = $json->decode( $resp->content ); |
|
76
|
|
|
|
|
|
|
|
|
77
|
1
|
50
|
|
|
|
155
|
if ( $data->{type} eq "error" ) { |
|
78
|
0
|
|
|
|
|
0
|
Carp::croak "Remote error: $data->{results}"; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
1
|
|
|
|
|
3
|
return map { _munge_result($_) } @{$data->{results}}; |
|
|
2
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
5
|
|
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub search |
|
85
|
|
|
|
|
|
|
{ |
|
86
|
3
|
|
|
3
|
0
|
1820
|
my ($query) = @_; |
|
87
|
|
|
|
|
|
|
|
|
88
|
3
|
|
|
|
|
7
|
my $regexp; |
|
89
|
3
|
100
|
66
|
|
|
33
|
if ( $query =~ /\A\^/ || $query =~ /\$\z/ ) { |
|
90
|
1
|
|
|
|
|
3
|
$regexp = eval { qr/$query/ }; |
|
|
1
|
|
|
|
|
22
|
|
|
91
|
1
|
50
|
|
|
|
3
|
if ( $@ ) { |
|
92
|
0
|
|
|
|
|
0
|
Carp::croak qq{Failed to compile "$query" into regexp:\n$@}; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
23
|
$query =~ s/\A\^//; |
|
96
|
1
|
|
|
|
|
2
|
$query =~ s/\$\z//; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
3
|
|
|
|
|
16
|
my $uri = rpc_uri( 'search', $query ); |
|
100
|
3
|
|
|
|
|
39
|
my $ua = _useragent(); |
|
101
|
3
|
|
|
|
|
2735
|
$ua->InitTLS; |
|
102
|
3
|
|
|
|
|
26
|
my $resp = $ua->get( $uri ); |
|
103
|
3
|
50
|
|
|
|
1710404
|
Carp::croak 'Failed to search AUR using RPC: ' . $resp->status_line |
|
104
|
|
|
|
|
|
|
unless $resp->is_success; |
|
105
|
|
|
|
|
|
|
|
|
106
|
3
|
|
|
|
|
69
|
my $json = JSON->new; |
|
107
|
3
|
|
|
|
|
17
|
my $data = $json->decode( $resp->content ); |
|
108
|
|
|
|
|
|
|
|
|
109
|
3
|
50
|
|
|
|
47542
|
if ( $data->{type} eq 'error' ) { |
|
110
|
0
|
|
|
|
|
0
|
Carp::croak "Remote error: $data->{results}"; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
3
|
|
|
|
|
10
|
my $results = [ map { _munge_result( $_ ) } @{ $data->{results} } ]; |
|
|
6921
|
|
|
|
|
7136
|
|
|
|
3
|
|
|
|
|
52
|
|
|
114
|
|
|
|
|
|
|
|
|
115
|
3
|
100
|
|
|
|
252
|
if ( $regexp ) { |
|
116
|
1
|
|
|
|
|
12
|
$results = [ grep { $_->{name} =~ /$regexp/ } @$results ]; |
|
|
2236
|
|
|
|
|
6190
|
|
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
3
|
|
|
|
|
10657
|
return $results; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub msearch |
|
123
|
|
|
|
|
|
|
{ |
|
124
|
2
|
|
|
2
|
0
|
3
|
my ($name) = @_; |
|
125
|
|
|
|
|
|
|
|
|
126
|
2
|
|
|
|
|
9
|
my $aururi = rpc_uri( 'msearch', $name ); |
|
127
|
2
|
|
|
|
|
26
|
my $ua = _useragent(); |
|
128
|
2
|
|
|
|
|
2408
|
$ua->InitTLS; |
|
129
|
2
|
|
|
|
|
19
|
my $resp = $ua->get( $aururi ); |
|
130
|
2
|
50
|
|
|
|
461818
|
Carp::croak qq{Failed to lookup maintainer using RPC:\n} |
|
131
|
|
|
|
|
|
|
. $resp->status_line unless $resp->is_success; |
|
132
|
|
|
|
|
|
|
|
|
133
|
2
|
|
|
|
|
64
|
my $json = JSON->new; |
|
134
|
2
|
|
|
|
|
18
|
my $json_ref = $json->decode( $resp->content ); |
|
135
|
|
|
|
|
|
|
|
|
136
|
2
|
50
|
|
|
|
596
|
if ( $json_ref->{type} eq 'error' ) { |
|
137
|
0
|
|
|
|
|
0
|
Carp::croak "Remote error: $json_ref->{results}"; |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
2
|
|
|
|
|
5
|
return [ map { _munge_result( $_ ) } @{ $json_ref->{results} } ]; |
|
|
8
|
|
|
|
|
18
|
|
|
|
2
|
|
|
|
|
9
|
|
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; |