line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bintray::API::Search; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
####################### |
4
|
|
|
|
|
|
|
# LOAD CORE MODULES |
5
|
|
|
|
|
|
|
####################### |
6
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
7
|
1
|
|
|
1
|
|
4
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
8
|
1
|
|
|
1
|
|
3
|
use Carp qw(croak carp); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
51
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
####################### |
11
|
|
|
|
|
|
|
# VERSION |
12
|
|
|
|
|
|
|
####################### |
13
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
####################### |
16
|
|
|
|
|
|
|
# LOAD CPAN MODULES |
17
|
|
|
|
|
|
|
####################### |
18
|
1
|
|
|
1
|
|
537
|
use Params::Validate qw(validate_with :types); |
|
1
|
|
|
|
|
7261
|
|
|
1
|
|
|
|
|
207
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
6
|
use Object::Tiny qw( |
21
|
|
|
|
|
|
|
session |
22
|
|
|
|
|
|
|
max_results |
23
|
1
|
|
|
1
|
|
7
|
); |
|
1
|
|
|
|
|
1
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
####################### |
26
|
|
|
|
|
|
|
# LOAD DIST MODULES |
27
|
|
|
|
|
|
|
####################### |
28
|
1
|
|
|
1
|
|
487
|
use Bintray::API::Session; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
####################### |
31
|
|
|
|
|
|
|
# PUBLIC METHODS |
32
|
|
|
|
|
|
|
####################### |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
## Constructor |
35
|
|
|
|
|
|
|
sub new { |
36
|
0
|
|
|
0
|
0
|
|
my ( $class, @args ) = @_; |
37
|
0
|
|
|
|
|
|
my %opts = validate_with( |
38
|
|
|
|
|
|
|
params => [@args], |
39
|
|
|
|
|
|
|
spec => { |
40
|
|
|
|
|
|
|
session => { |
41
|
|
|
|
|
|
|
type => OBJECT, |
42
|
|
|
|
|
|
|
isa => 'Bintray::API::Session', |
43
|
|
|
|
|
|
|
}, |
44
|
|
|
|
|
|
|
max_results => { |
45
|
|
|
|
|
|
|
type => SCALAR, |
46
|
|
|
|
|
|
|
regex => qr/^\d+$/x, |
47
|
|
|
|
|
|
|
default => '100', |
48
|
|
|
|
|
|
|
}, |
49
|
|
|
|
|
|
|
}, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return $class->SUPER::new(%opts); |
53
|
|
|
|
|
|
|
} ## end sub new |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
####################### |
56
|
|
|
|
|
|
|
# API METHODS |
57
|
|
|
|
|
|
|
####################### |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
## Search Repos |
60
|
|
|
|
|
|
|
sub repos { |
61
|
0
|
|
|
0
|
0
|
|
my ( $self, @args ) = @_; |
62
|
0
|
|
|
|
|
|
my %opts = validate_with( |
63
|
|
|
|
|
|
|
params => [@args], |
64
|
|
|
|
|
|
|
spec => { |
65
|
|
|
|
|
|
|
name => { |
66
|
|
|
|
|
|
|
type => SCALAR, |
67
|
|
|
|
|
|
|
default => '', |
68
|
|
|
|
|
|
|
}, |
69
|
|
|
|
|
|
|
desc => { |
70
|
|
|
|
|
|
|
type => SCALAR, |
71
|
|
|
|
|
|
|
default => '', |
72
|
|
|
|
|
|
|
}, |
73
|
|
|
|
|
|
|
}, |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Need either name or description |
77
|
0
|
0
|
0
|
|
|
|
$opts{name} |
78
|
|
|
|
|
|
|
or $opts{desc} |
79
|
|
|
|
|
|
|
or croak "ERROR: Please provide a name or desc to search for ..."; |
80
|
|
|
|
|
|
|
|
81
|
0
|
0
|
|
|
|
|
return $self->session()->paginate( |
|
|
0
|
|
|
|
|
|
82
|
|
|
|
|
|
|
path => '/search/repos', |
83
|
|
|
|
|
|
|
max => $self->max_results(), |
84
|
|
|
|
|
|
|
query => [ |
85
|
|
|
|
|
|
|
( $opts{name} ? { name => $opts{name} } : () ), |
86
|
|
|
|
|
|
|
( $opts{desc} ? { desc => $opts{desc} } : () ), |
87
|
|
|
|
|
|
|
], |
88
|
|
|
|
|
|
|
); |
89
|
|
|
|
|
|
|
} ## end sub repos |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
## Search Packages |
92
|
|
|
|
|
|
|
sub packages { |
93
|
0
|
|
|
0
|
0
|
|
my ( $self, @args ) = @_; |
94
|
0
|
|
|
|
|
|
my %opts = validate_with( |
95
|
|
|
|
|
|
|
params => [@args], |
96
|
|
|
|
|
|
|
spec => { |
97
|
|
|
|
|
|
|
name => { |
98
|
|
|
|
|
|
|
type => SCALAR, |
99
|
|
|
|
|
|
|
default => '', |
100
|
|
|
|
|
|
|
}, |
101
|
|
|
|
|
|
|
desc => { |
102
|
|
|
|
|
|
|
type => SCALAR, |
103
|
|
|
|
|
|
|
default => '', |
104
|
|
|
|
|
|
|
}, |
105
|
|
|
|
|
|
|
repo => { |
106
|
|
|
|
|
|
|
type => SCALAR, |
107
|
|
|
|
|
|
|
default => '', |
108
|
|
|
|
|
|
|
}, |
109
|
|
|
|
|
|
|
subject => { |
110
|
|
|
|
|
|
|
type => SCALAR, |
111
|
|
|
|
|
|
|
default => '', |
112
|
|
|
|
|
|
|
}, |
113
|
|
|
|
|
|
|
}, |
114
|
|
|
|
|
|
|
); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# Need either name or description |
117
|
0
|
0
|
0
|
|
|
|
$opts{name} |
118
|
|
|
|
|
|
|
or $opts{desc} |
119
|
|
|
|
|
|
|
or croak "ERROR: Please provide a name or desc to search for ..."; |
120
|
|
|
|
|
|
|
|
121
|
0
|
0
|
|
|
|
|
return $self->session()->paginate( |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
122
|
|
|
|
|
|
|
path => '/search/packages', |
123
|
|
|
|
|
|
|
max => $self->max_results(), |
124
|
|
|
|
|
|
|
query => [ |
125
|
|
|
|
|
|
|
( $opts{name} ? { name => $opts{name} } : () ), |
126
|
|
|
|
|
|
|
( $opts{desc} ? { desc => $opts{desc} } : () ), |
127
|
|
|
|
|
|
|
( $opts{repo} ? { repo => $opts{repo} } : () ), |
128
|
|
|
|
|
|
|
( $opts{subject} ? { subject => $opts{subject} } : () ), |
129
|
|
|
|
|
|
|
], |
130
|
|
|
|
|
|
|
); |
131
|
|
|
|
|
|
|
} ## end sub packages |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
## Search Users |
134
|
|
|
|
|
|
|
sub users { |
135
|
0
|
|
|
0
|
0
|
|
my ( $self, @args ) = @_; |
136
|
0
|
|
|
|
|
|
my %opts = validate_with( |
137
|
|
|
|
|
|
|
params => [@args], |
138
|
|
|
|
|
|
|
spec => { |
139
|
|
|
|
|
|
|
name => { |
140
|
|
|
|
|
|
|
type => SCALAR, |
141
|
|
|
|
|
|
|
}, |
142
|
|
|
|
|
|
|
}, |
143
|
|
|
|
|
|
|
); |
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
|
return $self->session()->paginate( |
146
|
|
|
|
|
|
|
path => '/search/users', |
147
|
|
|
|
|
|
|
max => $self->max_results(), |
148
|
|
|
|
|
|
|
query => [ { name => $opts{name} }, ], |
149
|
|
|
|
|
|
|
); |
150
|
|
|
|
|
|
|
} ## end sub users |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
## Search Files |
153
|
|
|
|
|
|
|
sub files { |
154
|
0
|
|
|
0
|
0
|
|
my ( $self, @args ) = @_; |
155
|
0
|
|
|
|
|
|
my %opts = validate_with( |
156
|
|
|
|
|
|
|
params => [@args], |
157
|
|
|
|
|
|
|
spec => { |
158
|
|
|
|
|
|
|
name => { |
159
|
|
|
|
|
|
|
type => SCALAR, |
160
|
|
|
|
|
|
|
default => '', |
161
|
|
|
|
|
|
|
}, |
162
|
|
|
|
|
|
|
sha1 => { |
163
|
|
|
|
|
|
|
type => SCALAR, |
164
|
|
|
|
|
|
|
regex => qr/^[\da-z]{40}$/x, |
165
|
|
|
|
|
|
|
default => '', |
166
|
|
|
|
|
|
|
}, |
167
|
|
|
|
|
|
|
repo => { |
168
|
|
|
|
|
|
|
type => SCALAR, |
169
|
|
|
|
|
|
|
default => '', |
170
|
|
|
|
|
|
|
}, |
171
|
|
|
|
|
|
|
}, |
172
|
|
|
|
|
|
|
); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
# Need either name or description |
175
|
0
|
0
|
0
|
|
|
|
$opts{name} |
176
|
|
|
|
|
|
|
or $opts{sha1} |
177
|
|
|
|
|
|
|
or croak "ERROR: Please provide a name or sha1 to search for ..."; |
178
|
|
|
|
|
|
|
|
179
|
0
|
0
|
|
|
|
|
if ( $opts{sha1} ) { |
180
|
0
|
0
|
|
|
|
|
return $self->session()->paginate( |
181
|
|
|
|
|
|
|
path => '/search/file', |
182
|
|
|
|
|
|
|
max => $self->max_results(), |
183
|
|
|
|
|
|
|
query => [ |
184
|
|
|
|
|
|
|
{ sha1 => $opts{sha1} }, |
185
|
|
|
|
|
|
|
( $opts{repo} ? { repo => $opts{repo} } : () ), |
186
|
|
|
|
|
|
|
], |
187
|
|
|
|
|
|
|
); |
188
|
|
|
|
|
|
|
} ## end if ( $opts{sha1} ) |
189
|
|
|
|
|
|
|
|
190
|
0
|
0
|
|
|
|
|
if ( $opts{name} ) { |
191
|
0
|
0
|
|
|
|
|
return $self->session()->paginate( |
192
|
|
|
|
|
|
|
path => '/search/file', |
193
|
|
|
|
|
|
|
max => $self->max_results(), |
194
|
|
|
|
|
|
|
query => [ |
195
|
|
|
|
|
|
|
{ name => $opts{name} }, |
196
|
|
|
|
|
|
|
( $opts{repo} ? { repo => $opts{repo} } : () ), |
197
|
|
|
|
|
|
|
], |
198
|
|
|
|
|
|
|
); |
199
|
|
|
|
|
|
|
} ## end if ( $opts{name} ) |
200
|
|
|
|
|
|
|
|
201
|
0
|
|
|
|
|
|
return; |
202
|
|
|
|
|
|
|
} ## end sub files |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
####################### |
205
|
|
|
|
|
|
|
1; |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
__END__ |