App/lcpan/Cmd/mod2author.pm

filter: Statementstmt 45.7% 16 / 35 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 41.6% 20 / 48 CC 5 SCAR 29.5
CC
5
Cov
37%
handle_cmd
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 19.1
« App/lcpan/Cmd/dists_by_script_count.pm ↑ Summary App/lcpan/Cmd/dist_scripts.pm »
1 package App::lcpan::Cmd::mod2author;
2  
3 1 ▶use 5.010;
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 module(s)',
19 args => {
20 %App::lcpan::common_args,
21 %App::lcpan::mods_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 $mods = $args{modules};
31  
32 0 my $mods_s = join(",", map {$dbh->quote($_)} @$mods);
33  
34 0 my $sth = $dbh->prepare("
35 SELECT
36 module.name module,
37 module.cpanid author
38 FROM module
39 WHERE module.name IN ($mods_s)");
40  
41 0 my @res;
42 0 $sth->execute;
43 0 ▶ while (my $row = $sth->fetchrow_hashref) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $sth->fetchrow_hashref) 0 0 0
44 0 push @res, $row;
45 }
46  
47 0 ▶ if (@$mods == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$mods == 1) 0 0 0
48 0 @res = map { $_->{author} } @res;
49 0 ▶ if (!@res) {
Branch: 2 branches
BranchTrueFalseTotal
if (not @res) { } 0 0 0
elsif (@res == 1) { } 0 0 0
50 0 return [404, "No such module"];
51 } elsif (@res == 1) {
52 0 return [200, "OK", $res[0]];
53 } else {
54 0 return [200, "OK", \@res];
55 }
56 }
57  
58 0 [200, "OK", \@res, {'table.fields'=>[qw/module author/]}];
59 }
60  
61 1 1;
62 # ABSTRACT: Get author of module(s)
63  
64 __END__
« App/lcpan/Cmd/dists_by_script_count.pm ↑ Summary App/lcpan/Cmd/dist_scripts.pm »