Labyrinth/Plugin/CPAN/Authors.pm

filter: Statementstmt 43.2% 35 / 81 Branchbran 0.0% 0 / 22 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 73.3% 11 / 15 Podpod 100% 4 / 4 totaltotal 39.3% 50 / 127 CC 14 SCAR 35.1
CC
14
Cov
33%
Reports
90.0
Status
20.0
List
12.0
CRAP 33.5
« Labyrinth/Plugin/CPAN/Distros.pm ↑ Summary Labyrinth/Plugin/Metabase/Parser.pm »
1 package Labyrinth::Plugin::CPAN::Authors;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 $VERSION = '3.59';
8  
9 =head1 NAME
10  
11 Labyrinth::Plugin::CPAN::Authors - Plugin to handle Author pages.
12  
13 =cut
14  
15 #----------------------------------------------------------------------------
16 # Libraries
17  
18 4 ▶use base qw(Labyrinth::Plugin::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 4 ▶use Labyrinth::Audit;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 4 ▶use Labyrinth::DBUtils;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 4 ▶use Labyrinth::DTUtils;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 4 ▶use Labyrinth::Plugin::CPAN;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 4 ▶use Labyrinth::Variables;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 4 ▶use Labyrinth::Writer;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 4 ▶use JSON::XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 #----------------------------------------------------------------------------
30 # Public Interface Functions
31  
32 =head1 METHODS
33  
34 =head2 Public Interface Methods
35  
36 =over 4
37  
38 =item Status
39  
40 Generate the status report
41  
42 =item Basic
43  
44 Provides basic components for pages.
45  
46 Currently creates a list of all known perl versions and operating systems.
47  
48 =item List
49  
50 List authors for a given letter.
51  
52 =item Reports
53  
54 List reports for authors dists.
55  
56 =back
57  
58 =cut
59  
60 sub Status {
61 0 ▶ my @rows = $dbi->GetQuery('hash','StatusRequest');
Subroutine Status: not called CC=4 SCAR=30.0
Pod documented
62 0 ▶ $tvars{status} = $rows[0] if(@rows);
Branch: 1 branch
BranchTrueFalseTotal
if @rows 0 0 0
63  
64 0 my @max = $dbi->GetQuery('array','MaxStatReport');
65 0 ▶ if(@max) {
Branch: 1 branch
BranchTrueFalseTotal
if (@max) 0 0 0
66 0 my @rep = $dbi->GetQuery('hash','GetStatReport',$max[0]->[0]);
67 0 ▶ if(@rep) {
Branch: 1 branch
BranchTrueFalseTotal
if (@rep) 0 0 0
68 0 my @date = $rep[0]->{fulldate} =~ /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/;
69 0 $rep[0]->{date} = sprintf "%04d-%02d-%02d %02d:%02d:00", @date;
70 0 $tvars{report} = $rep[0];
71 }
72 }
73 }
74  
75 sub Basic {
76 0 ▶ my $cpan = Labyrinth::Plugin::CPAN->new();
Subroutine Basic: not called CC=1 SCAR=6.9
Pod documented
77 0 $cpan->Configure();
78  
79 0 $tvars{perlvers} = $cpan->mklist_perls;
80 0 $tvars{osnames} = $cpan->osnames;
81 }
82  
83 sub List {
84 0 ▶ ($tvars{letter}) = ($cgiparams{name} =~ /^([A-Z])/i);
Subroutine List: not called CC=3 SCAR=24.8
Pod documented
85 0 $tvars{letter} = uc $tvars{letter};
86 0 ▶ return unless($tvars{letter});
Branch: 1 branch
BranchTrueFalseTotal
unless $Labyrinth::Plugin::CPAN::Authors::tvars{"letter"} 0 0 0
87  
88 0 my @rows = $dbi->GetQuery('hash','GetAuthors',"$tvars{letter}%");
89 0 my @authors = map {$_->{author}} @rows;
90 0 ▶ $tvars{list} = \@authors if(@authors);
Branch: 1 branch
BranchTrueFalseTotal
if @authors 0 0 0
91 }
92  
93 sub Reports {
94 0 ▶ my $cpan = Labyrinth::Plugin::CPAN->new();
Subroutine Reports: not called CC=9 SCAR=45.0
Pod documented
95 0 $cpan->Configure();
96  
97 0 $tvars{author} = $cgiparams{name};
98 0 $tvars{letter} = substr($cgiparams{name},0,1);
99  
100 # does author exist?
101 0 my @rows = $dbi->GetQuery('hash','FindAuthor',$cgiparams{name});
102 0 ▶ unless(@rows) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@rows) 0 0 0
103 0 $tvars{errcode} = 'NEXT';
104 0 $tvars{command} = 'cpan-authunk';
105 0 return;
106 }
107  
108 # get author summary
109 0 my @summary = $dbi->GetQuery('hash','GetAuthorSummary',$cgiparams{name});
110 0 ▶ unless(@summary) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@summary) 0 0 0
111 0 ▶ unless($settings{crawler}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Labyrinth::Plugin::CPAN::Authors::settings{"crawler"}) 0 0 0
112 0 $dbi->DoQuery('PushAuthor',$cgiparams{name});
113 0 $tvars{update} = 1;
114 }
115 0 $tvars{perlvers} = $cpan->mklist_perls;
116 0 $tvars{osnames} = $cpan->osnames;
117 0 return;
118 }
119  
120 # if existing page requests, add another to improve rebuild time
121 0 @rows = $dbi->GetQuery('array','GetAuthorRequests',$cgiparams{name});
122 0 ▶ if(@rows && $rows[0]->[0] > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@rows and $rows[0][0] > 0) 0 0 0
Condition0%0/3
@rows and $rows[0][0] > 0
!ll&&!rl&&r
000
MC/DC0%0/2
@rows and $rows[0][0] > 0
@rows $rows[0][0] > 0
Truth table0%0/3
A and B
A= @rowsB= $rows[0][0] > 0
ABresult
0X0
100
111
123 0 ▶ unless($settings{crawler}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Labyrinth::Plugin::CPAN::Authors::settings{"crawler"}) 0 0 0
124 0 $dbi->DoQuery('PushAuthor',$cgiparams{name});
125 0 $tvars{update} = 1;
126 }
127 }
128  
129 # decode from JSON string
130 0 my $parms = decode_json($summary[0]->{dataset});
131 0 for my $key (keys %$parms) { $tvars{$key} = $parms->{$key}; }
132 0 ▶ $tvars{processed} = formatDate(8,$parms->{processed}) if($parms->{processed});
Branch: 1 branch
BranchTrueFalseTotal
if $parms->{"processed"} 0 0 0
133 }
134  
135 4 1;
136  
137 __END__
138  
139 =head1 SEE ALSO
140  
141 Labyrinth
142  
143 =head1 AUTHOR
144  
145 Barbie, <barbie@missbarbell.co.uk> for
146 Miss Barbell Productions, L<http://www.missbarbell.co.uk/>
147  
148 =head1 COPYRIGHT & LICENSE
149  
150 Copyright (C) 2008-2017 Barbie for Miss Barbell Productions
151 All Rights Reserved.
152  
153 This module is free software; you can redistribute it and/or
154 modify it under the Artistic License 2.0.
155  
156 =cut
« Labyrinth/Plugin/CPAN/Distros.pm ↑ Summary Labyrinth/Plugin/Metabase/Parser.pm »