line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPANPLUS::Internals::Source::MetaCPAN; |
2
|
|
|
|
|
|
|
$CPANPLUS::Internals::Source::MetaCPAN::VERSION = '0.10'; |
3
|
|
|
|
|
|
|
#ABSTRACT: MetaCPAN source implementation |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
39143
|
use strict; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
45
|
|
6
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
51
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
9
|
use base 'CPANPLUS::Internals::Source'; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
764
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
10508
|
use CPANPLUS::Error; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
80
|
|
11
|
1
|
|
|
1
|
|
9
|
use CPANPLUS::Internals::Constants; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
395
|
|
12
|
1
|
|
|
1
|
|
511
|
use CPANPLUS::Internals::Source::MetaCPAN::Tie; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
7
|
use Params::Check qw[allow check]; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
15
|
1
|
|
|
1
|
|
6
|
use Locale::Maketext::Simple Class => 'CPANPLUS', Style => 'gettext'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
16
|
1
|
|
|
1
|
|
268
|
use Module::Load::Conditional qw[check_install]; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
6
|
use constant METACPAN => 'http://fastapi.metacpan.org/'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
513
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
{ |
21
|
|
|
|
|
|
|
my $metacpan = METACPAN; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _init_trees { |
24
|
1
|
|
|
1
|
|
1380
|
my $self = shift; |
25
|
1
|
|
|
|
|
6
|
my $conf = $self->configure_object; |
26
|
1
|
|
|
|
|
16
|
my %hash = @_; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
4
|
my($path,$uptodate,$verbose,$use_stored); |
29
|
1
|
|
|
|
|
8
|
my $tmpl = { |
30
|
|
|
|
|
|
|
path => { default => $conf->get_conf('base'), store => \$path }, |
31
|
|
|
|
|
|
|
verbose => { default => $conf->get_conf('verbose'), store => \$verbose }, |
32
|
|
|
|
|
|
|
uptodate => { required => 1, store => \$uptodate }, |
33
|
|
|
|
|
|
|
use_stored => { default => 1, store => \$use_stored }, |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
|
36
|
1
|
50
|
|
|
|
766
|
check( $tmpl, \%hash ) or return; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
### set up the author tree |
39
|
1
|
|
|
|
|
4
|
{ my %at; |
40
|
1
|
|
|
|
|
10
|
tie %at, 'CPANPLUS::Internals::Source::MetaCPAN::Tie', |
41
|
|
|
|
|
|
|
idx => $metacpan, table => 'author', |
42
|
|
|
|
|
|
|
key => 'cpanid', cb => $self; |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
11
|
$self->_atree( \%at ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
### set up the module tree |
48
|
1
|
|
|
|
|
263
|
{ my %mt; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
3
|
|
49
|
1
|
|
|
|
|
7
|
tie %mt, 'CPANPLUS::Internals::Source::MetaCPAN::Tie', |
50
|
|
|
|
|
|
|
idx => $metacpan, table => 'module', |
51
|
|
|
|
|
|
|
key => 'module', cb => $self; |
52
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
6
|
$self->_mtree( \%mt ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
16
|
return 1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
1
|
|
30
|
sub _standard_trees_completed { return 1 } |
61
|
1
|
|
|
1
|
|
12
|
sub _custom_trees_completed { return } |
62
|
|
|
|
|
|
|
### finish transaction |
63
|
1
|
|
|
1
|
|
843
|
sub _finalize_trees { return 1 } |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
### no saving state in metacpan |
66
|
0
|
|
|
0
|
|
0
|
sub _save_state { return } |
67
|
0
|
|
|
0
|
|
0
|
sub __check_uptodate { return 1 } |
68
|
1
|
|
|
1
|
|
409
|
sub _check_trees { return 1 } |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _add_author_object { |
71
|
0
|
|
|
0
|
|
|
my $self = shift; |
72
|
0
|
|
|
|
|
|
my %hash = @_; |
73
|
0
|
|
|
|
|
|
return 1; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $class; |
76
|
|
|
|
|
|
|
my $tmpl = { |
77
|
|
|
|
|
|
|
class => { default => 'CPANPLUS::Module::Author', store => \$class }, |
78
|
0
|
|
|
|
|
|
map { $_ => { required => 1 } } |
|
0
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
qw[ author cpanid email ] |
80
|
|
|
|
|
|
|
}; |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
my $href = do { |
83
|
0
|
|
|
|
|
|
local $Params::Check::NO_DUPLICATES = 1; |
84
|
0
|
0
|
|
|
|
|
check( $tmpl, \%hash ) or return; |
85
|
|
|
|
|
|
|
}; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my $obj = $class->new( %$href, _id => $self->_id ); |
88
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
$self->author_tree->{ $href->{'cpanid'} } = $obj or return; |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
return $obj; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub _add_module_object { |
95
|
0
|
|
|
0
|
|
|
my $self = shift; |
96
|
0
|
|
|
|
|
|
my %hash = @_; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
my $class; |
99
|
|
|
|
|
|
|
my $tmpl = { |
100
|
|
|
|
|
|
|
class => { default => 'CPANPLUS::Module', store => \$class }, |
101
|
0
|
|
|
|
|
|
map { $_ => { required => 1 } } |
|
0
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
qw[ module version path comment author package description dslip mtime ] |
103
|
|
|
|
|
|
|
}; |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
my $href = do { |
106
|
0
|
|
|
|
|
|
local $Params::Check::NO_DUPLICATES = 1; |
107
|
0
|
0
|
|
|
|
|
check( $tmpl, \%hash ) or return; |
108
|
|
|
|
|
|
|
}; |
109
|
|
|
|
|
|
|
|
110
|
0
|
0
|
|
|
|
|
return unless check_install( module => $href->{module} ); |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
my $obj = $class->new( %$href, _id => $self->_id ); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
### Every module get's stored as a module object ### |
115
|
0
|
0
|
|
|
|
|
$self->module_tree->{ $href->{module} } = $obj or return; |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
return $obj; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
{ my %map = ( |
123
|
|
|
|
|
|
|
_source_search_module_tree |
124
|
|
|
|
|
|
|
=> [ module => module => 'CPANPLUS::Module' ], |
125
|
|
|
|
|
|
|
_source_search_author_tree |
126
|
|
|
|
|
|
|
=> [ author => cpanid => 'CPANPLUS::Module::Author' ], |
127
|
|
|
|
|
|
|
); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
while( my($sub, $aref) = each %map ) { |
130
|
1
|
|
|
1
|
|
9
|
no strict 'refs'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
116
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
my($table, $key, $class) = @$aref; |
133
|
|
|
|
|
|
|
*$sub = sub { |
134
|
0
|
|
|
0
|
|
|
my $self = shift; |
135
|
0
|
|
|
|
|
|
my %hash = @_; |
136
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
my($list,$type); |
138
|
0
|
|
|
|
|
|
my $tmpl = { |
139
|
|
|
|
|
|
|
allow => { required => 1, default => [ ], strict_type => 1, |
140
|
|
|
|
|
|
|
store => \$list }, |
141
|
|
|
|
|
|
|
type => { required => 1, allow => [$class->accessors()], |
142
|
|
|
|
|
|
|
store => \$type }, |
143
|
|
|
|
|
|
|
}; |
144
|
|
|
|
|
|
|
|
145
|
0
|
0
|
|
|
|
|
check( $tmpl, \%hash ) or return; |
146
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
my @rv; |
148
|
|
|
|
|
|
|
### we aliased 'module' to 'name', so change that here too |
149
|
|
|
|
|
|
|
#$type = 'module' if $type eq 'name'; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
#my $res = $dbh->query( "SELECT * from $table" ); |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
#my $meth = $table .'_tree'; |
154
|
|
|
|
|
|
|
#my @rv = map { $self->$meth( $_->{$key} ) } |
155
|
|
|
|
|
|
|
# grep { allow( $_->{$type} => $list ) } $res->hashes; |
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
return @rv; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
__END__ |