CPANIDX.pm

filter: Statementstmt 44.6% 42 / 94 Branchbran 16.6% 2 / 12 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 54.5% 12 / 22 Podpod n/a totaltotal 41.6% 57 / 137 CC 8 SCAR 17.3
CC
8
Cov
40%
_add_module_object
20.0
_add_author_object
12.0
_init_trees
6.0
CRAP 5.7
« CPANIDX/Tie.pm ↑ Summary
1 package CPANPLUS::Internals::Source::CPANIDX;
2 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 $CPANPLUS::Internals::Source::CPANIDX::VERSION = '0.04';
4 }
5  
6 #ABSTRACT: CPANIDX source implementation
7  
8 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use base 'CPANPLUS::Internals::Source';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use CPANPLUS::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use CPANPLUS::Internals::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use CPANPLUS::Internals::Source::CPANIDX::Tie;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 ▶use Params::Check qw[allow check];
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use Locale::Maketext::Simple Class => 'CPANPLUS', Style => 'gettext';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use Module::Load::Conditional qw[check_install];
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use constant CPANIDX => 'http://cpanidx.org/cpanidx/';
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 {
24 1 ▶ my $cpanidx = $ENV{PERL5_CPANIDX_URL} || CPANIDX;
Condition50%1/2
$ENV{'PERL5_CPANIDX_URL'} || 'http://cpanidx.org/cpanidx/'
l!l
01
MC/DC0%0/1
$ENV{'PERL5_CPANIDX_URL'} || 'http://cpanidx.org/cpanidx/'
$ENV{'PERL5_CPANIDX_URL'}
Truth table50%1/2
A
A= $ENV{'PERL5_CPANIDX_URL'}
Aresult
11
00
25  
26 0 ▶ sub _init_trees {
Subroutine _init_trees: not called CC=2 SCAR=17.9
27 0 my $self = shift;
28 0 my $conf = $self->configure_object;
29 0 my %hash = @_;
30
31 0 my($path,$uptodate,$verbose,$use_stored);
32 0 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 0 ▶ check( $tmpl, \%hash ) or return;
Branch: 1 branch
BranchTrueFalseTotal
check($tmpl, \%hash) or return 0 0 0
40  
41 ### set up the author tree
42 0 { my %at;
43 0 tie %at, 'CPANPLUS::Internals::Source::CPANIDX::Tie',
44 idx => $cpanidx, table => 'author',
45 key => 'cpanid', cb => $self;
46
47 0 $self->_atree( \%at );
48 }
49  
50 ### set up the module tree
51 0 { my %mt;
52 0 tie %mt, 'CPANPLUS::Internals::Source::CPANIDX::Tie',
53 idx => $cpanidx, table => 'module',
54 key => 'module', cb => $self;
55  
56 0 $self->_mtree( \%mt );
57 }
58
59 0 return 1;
60
61 }
62  
63 0 ▶ sub _standard_trees_completed { return 1 }
Subroutine _standard_trees_completed: not called CC=1 SCAR=6.9
64 0 ▶ sub _custom_trees_completed { return }
Subroutine _custom_trees_completed: not called CC=1 SCAR=6.9
65 ### finish transaction
66 0 ▶ sub _finalize_trees { return 1 }
Subroutine _finalize_trees: not called CC=1 SCAR=6.9
67  
68 ### no saving state in cpanidx
69 0 ▶ sub _save_state { return }
Subroutine _save_state: not called CC=1 SCAR=6.9
70 0 ▶ sub __check_uptodate { return 1 }
Subroutine __check_uptodate: not called CC=1 SCAR=6.9
71 0 ▶ sub _check_trees { return 1 }
Subroutine _check_trees: not called CC=1 SCAR=6.9
72  
73 0 ▶ sub _add_author_object {
Subroutine _add_author_object: not called CC=3 SCAR=24.8
74 0 my $self = shift;
75 0 my %hash = @_;
76 0 return 1;
77  
78 0 my $class;
79 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 ▶ check( $tmpl, \%hash ) or return;
Condition0%0/2
check($tmpl, \%hash) || (return)
l!l
00
MC/DC0%0/1
check($tmpl, \%hash) || (return)
check($tmpl, \%hash)
Truth table0%0/2
A
A= check($tmpl, \%hash)
Aresult
11
00
88 };
89
90 0 my $obj = $class->new( %$href, _id => $self->_id );
91
92 0 ▶ $self->author_tree->{ $href->{'cpanid'} } = $obj or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->author_tree->{$href->{"cpanid"}} = $obj or return 0 0 0
93  
94 0 return $obj;
95 }
96  
97 0 ▶ sub _add_module_object {
Subroutine _add_module_object: not called CC=4 SCAR=30.0
98 0 my $self = shift;
99 0 my %hash = @_;
100  
101 0 my $class;
102 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 ▶ check( $tmpl, \%hash ) or return;
Condition0%0/2
check($tmpl, \%hash) || (return)
l!l
00
MC/DC0%0/1
check($tmpl, \%hash) || (return)
check($tmpl, \%hash)
Truth table0%0/2
A
A= check($tmpl, \%hash)
Aresult
11
00
111 };
112  
113 0 ▶ return unless check_install( module => $href->{module} );
Branch: 1 branch
BranchTrueFalseTotal
unless check_install("module", $href->{"module"}) 0 0 0
114
115 0 my $obj = $class->new( %$href, _id => $self->_id );
116
117 ### Every module get's stored as a module object ###
118 0 ▶ $self->module_tree->{ $href->{module} } = $obj or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->module_tree->{$href->{"module"}} = $obj or return 0 0 0
119  
120 0 return $obj;
121 }
122  
123 }
124  
125 1 { 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 1 ▶ while( my($sub, $aref) = each %map ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %map) 2 1 3
133 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
134
135 2 my($table, $key, $class) = @$aref;
136 0 ▶ *$sub = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
137 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 ▶ check( $tmpl, \%hash ) or return;
Branch: 1 branch
BranchTrueFalseTotal
check($tmpl, \%hash) or return 0 0 0
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 2 }
163 }
164  
165 1 1;
166  
167  
168 __END__
« CPANIDX/Tie.pm ↑ Summary