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