App/lcpan/Cmd/dist2author.pm

filter: Statementstmt 43.2% 16 / 37 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 40.0% 20 / 50 CC 5 SCAR 29.5
CC
5
Cov
36%
handle_cmd
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 19.1
« App/lcpan/Cmd/mentions_for_all_mods.pm ↑ Summary App/lcpan/Cmd/dists_by_mod_count.pm »
1 package App::lcpan::Cmd::dist2author;
2  
3 1 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 require App::lcpan;
8  
9 1 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
10 1 our $DATE = '2023-09-26'; # DATE
11 1 our $DIST = 'App-lcpan'; # DIST
12 1 our $VERSION = '1.074'; # VERSION
13  
14 1 our %SPEC;
15  
16 1 $SPEC{'handle_cmd'} = {
17 v => 1.1,
18 summary => 'Get author of distribution(s)',
19 args => {
20 %App::lcpan::common_args,
21 %App::lcpan::dists_args,
22 },
23 };
24 0 ▶sub handle_cmd {
Subroutine handle_cmd: not called CC=5 SCAR=34.0
Pod documented
25 0 my %args = @_;
26  
27 0 my $state = App::lcpan::_init(\%args, 'ro');
28 0 my $dbh = $state->{dbh};
29  
30 0 my $dists = $args{dists};
31  
32 my $dists_s = join(",", map {
33 0 my $d=$_; $d =~ s/::/-/g; $dbh->quote($d);
34 } @$dists);
35  
36 0 my $sth = $dbh->prepare("SELECT
37 f.dist_name dist,
38 f.cpanid author
39 FROM file f
40 WHERE f.dist_name IN ($dists_s)");
41  
42 0 my @res;
43 0 $sth->execute;
44 0 ▶ while (my $row = $sth->fetchrow_hashref) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $sth->fetchrow_hashref) 0 0 0
45 0 push @res, $row;
46 }
47  
48 0 ▶ if (@$dists == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$dists == 1) 0 0 0
49 0 @res = map { $_->{author} } @res;
50 0 ▶ if (!@res) {
Branch: 2 branches
BranchTrueFalseTotal
if (not @res) { } 0 0 0
elsif (@res == 1) { } 0 0 0
51 0 return [404, "No such dist"];
52 } elsif (@res == 1) {
53 0 return [200, "OK", $res[0]];
54 } else {
55 0 return [200, "OK", \@res];
56 }
57 }
58  
59 0 [200, "OK", \@res, {'table.fields'=>[qw/dist author/]}];
60 }
61  
62 1 1;
63 # ABSTRACT: Get author of distribution(s)
64  
65 __END__
« App/lcpan/Cmd/mentions_for_all_mods.pm ↑ Summary App/lcpan/Cmd/dists_by_mod_count.pm »