line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSAN::Index; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
JSAN::Index - JavaScript Archive Network (JSAN) SQLite/ORLite Index |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
JSAN is the JavaScript Archive Network, a port of CPAN to JavaScript. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
You can find the JSAN at L. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
As well as a flat text file index like CPAN, the JSAN index is also |
16
|
|
|
|
|
|
|
distributed as a L database. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
C is a L wrapper built around the JSAN |
19
|
|
|
|
|
|
|
SQLite index. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
It allow you to easily do all sorts of nifty things with the index in a |
22
|
|
|
|
|
|
|
simple and straight forward way. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 Using The JSAN Index / Terminology |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Once loaded, most of the functionality of the index is accessed through |
27
|
|
|
|
|
|
|
the classes that implement the various objects in the index. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
These are: |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=over 4 |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=item L |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
An author is a single human (or under certain very special circumstances |
36
|
|
|
|
|
|
|
a company or mailing list) that creates distributions and uploads them |
37
|
|
|
|
|
|
|
to the JSAN. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item L |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
A distribution is a single software component that may go through a number |
42
|
|
|
|
|
|
|
of releases |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item L |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
A release is a compressed archive file containing a single version of a |
47
|
|
|
|
|
|
|
paricular distribution. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item L |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
A library is a single class, or rather a "pseudo-namespace", that |
52
|
|
|
|
|
|
|
defines an interface to provide some functionality. Distributions often |
53
|
|
|
|
|
|
|
contain a number of libraries, making up a complete "API". |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=back |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 METHODS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
There are only a very limited number of utility methods available |
60
|
|
|
|
|
|
|
directly from the C class itself. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
6
|
|
|
6
|
|
585094
|
use 5.008005; |
|
6
|
|
|
|
|
24
|
|
|
6
|
|
|
|
|
241
|
|
65
|
6
|
|
|
6
|
|
42
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
221
|
|
66
|
6
|
|
|
6
|
|
34
|
use warnings; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
208
|
|
67
|
6
|
|
|
6
|
|
2101
|
use Params::Util 1.00 (); |
|
6
|
|
|
|
|
7712
|
|
|
6
|
|
|
|
|
126
|
|
68
|
6
|
|
|
6
|
|
40
|
use Carp (); |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
93
|
|
69
|
6
|
|
|
6
|
|
69601
|
use DBI (); |
|
6
|
|
|
|
|
107860
|
|
|
6
|
|
|
|
|
255
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
6
|
|
|
6
|
|
3535
|
use JSAN::Transport; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
196
|
|
73
|
6
|
|
|
6
|
|
4837
|
use JSAN::Index::Author (); |
|
6
|
|
|
|
|
25
|
|
|
6
|
|
|
|
|
158
|
|
74
|
6
|
|
|
6
|
|
4361
|
use JSAN::Index::Library (); |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
144
|
|
75
|
6
|
|
|
6
|
|
43
|
use JSAN::Index::Release (); |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
100
|
|
76
|
6
|
|
|
6
|
|
3948
|
use JSAN::Index::Release::Dependency (); |
|
6
|
|
|
|
|
20
|
|
|
6
|
|
|
|
|
128
|
|
77
|
6
|
|
|
6
|
|
3671
|
use JSAN::Index::Release::Source (); |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
126
|
|
78
|
6
|
|
|
6
|
|
39
|
use JSAN::Index::Distribution (); |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
4715
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
our $VERSION = '0.29'; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $SINGLETON = undef; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
##################################################################### |
85
|
|
|
|
|
|
|
# Constructor |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=pod |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 init param => $value, ... |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
The C method initializes the JSAN index adapter. It takes a set of |
92
|
|
|
|
|
|
|
parameters and initializes the C class. JSAN::Index is a |
93
|
|
|
|
|
|
|
singleton, so only it can initialized only once. Any further attempts |
94
|
|
|
|
|
|
|
to do so will result in an exception being thrown. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub init { |
100
|
5
|
50
|
|
5
|
1
|
354001
|
Carp::croak("JSAN::Index already initialized") if $SINGLETON; |
101
|
|
|
|
|
|
|
|
102
|
5
|
|
|
|
|
12
|
my $class = shift; |
103
|
5
|
|
50
|
|
|
33
|
my $params = Params::Util::_HASH(shift) || {}; |
104
|
|
|
|
|
|
|
|
105
|
5
|
|
|
|
|
69
|
my $transport = JSAN::Transport->new( |
106
|
|
|
|
|
|
|
mirror_remote => delete $params->{mirror_remote}, |
107
|
|
|
|
|
|
|
mirror_local => delete $params->{mirror_local}, |
108
|
|
|
|
|
|
|
verbose => $params->{verbose}, |
109
|
|
|
|
|
|
|
); |
110
|
|
|
|
|
|
|
|
111
|
5
|
|
|
|
|
45
|
$SINGLETON = bless { |
112
|
|
|
|
|
|
|
transport => $transport, |
113
|
|
|
|
|
|
|
file => $transport->index_file, |
114
|
|
|
|
|
|
|
verbose => delete $params->{verbose} |
115
|
|
|
|
|
|
|
}, $class; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
##################################################################### |
122
|
|
|
|
|
|
|
# Top-level Methods |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=pod |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 dependency param => $value |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
The C method creates and returns an dependency resolution |
129
|
|
|
|
|
|
|
object that is used by L to schedule which releases to |
130
|
|
|
|
|
|
|
install. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
If the optional parameter 'build' is true, creates a build-time |
133
|
|
|
|
|
|
|
dependency resolve, which will additionally install releases only needed |
134
|
|
|
|
|
|
|
for testing. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Returns an L object. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub dependency { |
141
|
4
|
|
|
4
|
1
|
5988
|
my $class = shift; |
142
|
4
|
|
|
|
|
65
|
JSAN::Index::Release::Dependency->new( @_ ); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=pod |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 transport |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This accessor return an instance of JSAN::Transport, which can be used |
151
|
|
|
|
|
|
|
for managing files of current mirror. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub transport { |
156
|
22
|
50
|
|
22
|
1
|
166
|
Carp::croak("JSAN::Index is not initialized") unless $SINGLETON; |
157
|
22
|
|
|
|
|
116
|
$SINGLETON->{transport} |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=pod |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 self |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
This accessor return a singleton instance of JSAN::Index, or undef is its |
166
|
|
|
|
|
|
|
not initialized yet. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub self { |
171
|
4
|
|
|
4
|
1
|
30
|
$SINGLETON |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
##################################################################### |
175
|
|
|
|
|
|
|
# Database connectivity |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub sqlite { |
179
|
1394
|
50
|
|
1394
|
0
|
4493
|
$SINGLETON || Carp::croak('JSAN::Index is not initialized yet'); |
180
|
|
|
|
|
|
|
|
181
|
1394
|
|
|
|
|
14558
|
$SINGLETON->{file} |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub dsn { |
185
|
1394
|
|
|
1394
|
1
|
4657
|
"dbi:SQLite:" . shift->sqlite |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub dbh { |
190
|
1394
|
|
|
1394
|
1
|
4737
|
$_[0]->connect; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub connect { |
194
|
1394
|
|
|
1394
|
0
|
4454
|
DBI->connect( $_[0]->dsn, undef, undef, { |
195
|
|
|
|
|
|
|
PrintError => 0, |
196
|
|
|
|
|
|
|
RaiseError => 1, |
197
|
|
|
|
|
|
|
} ); |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub prepare { |
201
|
0
|
|
|
0
|
1
|
0
|
shift->dbh->prepare(@_); |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub do { |
205
|
0
|
|
|
0
|
0
|
0
|
shift->dbh->do(@_); |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub selectall_arrayref { |
209
|
1394
|
|
|
1394
|
1
|
4878
|
shift->dbh->selectall_arrayref(@_); |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub selectall_hashref { |
213
|
0
|
|
|
0
|
1
|
|
shift->dbh->selectall_hashref(@_); |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
sub selectcol_arrayref { |
217
|
0
|
|
|
0
|
1
|
|
shift->dbh->selectcol_arrayref(@_); |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub selectrow_array { |
221
|
0
|
|
|
0
|
1
|
|
shift->dbh->selectrow_array(@_); |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
sub selectrow_arrayref { |
225
|
0
|
|
|
0
|
1
|
|
shift->dbh->selectrow_arrayref(@_); |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub selectrow_hashref { |
229
|
0
|
|
|
0
|
1
|
|
shift->dbh->selectrow_hashref(@_); |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
sub pragma { |
233
|
0
|
0
|
|
0
|
1
|
|
$_[0]->do("pragma $_[1] = $_[2]") if @_ > 2; |
234
|
0
|
|
|
|
|
|
$_[0]->selectrow_arrayref("pragma $_[1]")->[0]; |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
sub iterate { |
238
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
239
|
0
|
|
|
|
|
|
my $call = pop; |
240
|
0
|
|
|
|
|
|
my $sth = $class->prepare( shift ); |
241
|
0
|
|
|
|
|
|
$sth->execute( @_ ); |
242
|
0
|
|
|
|
|
|
while ( $_ = $sth->fetchrow_arrayref ) { |
243
|
0
|
0
|
|
|
|
|
$call->() or last; |
244
|
|
|
|
|
|
|
} |
245
|
0
|
|
|
|
|
|
$sth->finish; |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
1; |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
__END__ |