line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSAN::Indexer::Creator; |
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use base 'Class::DBI'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1223
|
|
6
|
1
|
|
|
1
|
|
69814
|
use Class::DBI::DATA::Schema translate => [ 'MySQL', 'SQLite' ]; |
|
1
|
|
|
|
|
1006
|
|
|
1
|
|
|
|
|
9
|
|
7
|
1
|
|
|
1
|
|
321215
|
use LWP::Simple; |
|
1
|
|
|
|
|
129013
|
|
|
1
|
|
|
|
|
11
|
|
8
|
1
|
|
|
1
|
|
1762
|
use YAML; |
|
1
|
|
|
|
|
11882
|
|
|
1
|
|
|
|
|
795
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
11
|
|
|
|
|
|
|
our $MASTER_INDEX = 'http://openjsan.org/index.yaml'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub create_index_db { |
14
|
0
|
|
|
0
|
0
|
|
my ($class, $index, $dsn, $index_db, $location) = @_; |
15
|
0
|
0
|
|
|
|
|
if ($JSAN::Indexer::LOADER) { |
16
|
0
|
|
|
|
|
|
$_->db_Main->disconnect for $JSAN::Indexer::LOADER->classes; |
17
|
|
|
|
|
|
|
} |
18
|
0
|
|
|
|
|
|
unlink $index_db; |
19
|
0
|
|
|
|
|
|
$class->connection($dsn); |
20
|
0
|
|
0
|
|
|
|
$location ||= $MASTER_INDEX; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
my $yaml = get($location); |
23
|
0
|
0
|
|
|
|
|
die "Could not load YAML Index from $location" unless $yaml; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my $yaml_index = Load($yaml); |
26
|
0
|
0
|
|
|
|
|
die "Couldn't parse YAML stream" unless $yaml_index; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$class->run_data_sql; |
29
|
0
|
|
|
|
|
|
do { |
30
|
0
|
|
|
|
|
|
local $^W; |
31
|
0
|
|
|
|
|
|
$index = $index->new(); |
32
|
|
|
|
|
|
|
}; |
33
|
0
|
|
|
|
|
|
$class->_insert_data($index->loader, $yaml_index); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _insert_data { |
37
|
0
|
|
|
0
|
|
|
my ($self, $loader, $yaml) = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
foreach my $login ( keys %{$yaml->{authors}} ) { |
|
0
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $author = $yaml->{authors}->{$login}; |
41
|
0
|
|
|
|
|
|
$loader->find_class('author')->create({ |
42
|
|
|
|
|
|
|
login => $login, |
43
|
|
|
|
|
|
|
doc => $author->{doc}, |
44
|
|
|
|
|
|
|
email => $author->{email}, |
45
|
|
|
|
|
|
|
url => $author->{url}, |
46
|
|
|
|
|
|
|
name => $author->{name}, |
47
|
|
|
|
|
|
|
}); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
foreach my $name ( keys %{$yaml->{distributions}} ) { |
|
0
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $distribution = $yaml->{distributions}->{$name}; |
52
|
0
|
|
|
|
|
|
my $dist = $loader->find_class('distribution')->create({ |
53
|
|
|
|
|
|
|
name => $name, |
54
|
|
|
|
|
|
|
doc => $distribution->{doc}, |
55
|
|
|
|
|
|
|
}); |
56
|
0
|
|
|
|
|
|
my $releases = $distribution->{releases}; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
foreach my $rel ( @{$releases} ) { |
|
0
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$loader->find_class('release')->create({ |
60
|
|
|
|
|
|
|
distribution => $dist->name, |
61
|
|
|
|
|
|
|
author => $rel->{author}, |
62
|
|
|
|
|
|
|
checksum => $rel->{checksum}, |
63
|
|
|
|
|
|
|
created => $rel->{created}, |
64
|
|
|
|
|
|
|
doc => $rel->{doc}, |
65
|
|
|
|
|
|
|
meta => Dump($rel->{meta}), |
66
|
|
|
|
|
|
|
latest => $rel->{latest}, |
67
|
|
|
|
|
|
|
source => $rel->{source}, |
68
|
|
|
|
|
|
|
version => $rel->{version}, |
69
|
|
|
|
|
|
|
srcdir => $rel->{srcdir}, |
70
|
|
|
|
|
|
|
}); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
foreach my $name ( keys %{$yaml->{libraries}} ) { |
|
0
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $library = $yaml->{libraries}->{$name}; |
76
|
0
|
|
|
|
|
|
$loader->find_class('library')->create({ |
77
|
|
|
|
|
|
|
name => $name, |
78
|
|
|
|
|
|
|
version => $library->{version}, |
79
|
|
|
|
|
|
|
doc => $library->{doc}, |
80
|
|
|
|
|
|
|
distribution => $library->{distribution_name}, |
81
|
|
|
|
|
|
|
release => $loader->find_class('release')->search( |
82
|
|
|
|
|
|
|
distribution => $library->{distribution_name}, |
83
|
|
|
|
|
|
|
version => $library->{distribution_version}, |
84
|
|
|
|
|
|
|
)->first->id, |
85
|
|
|
|
|
|
|
}); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 NAME |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
JSAN::Indexer::Creator -- Convert the YAML Index to SQLite |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 AUTHOR |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Casey West >. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 COPYRIGHT |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Copyright (c) 2005 Casey West. All rights reserved. |
100
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it |
101
|
|
|
|
|
|
|
under the same terms as Perl itself. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__DATA__ |