App/lcpan/Cmd/mod2dist.pm

filter: Statementstmt 50.0% 16 / 32 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 48.7% 20 / 41 CC 3 SCAR 18.7
CC
3
Cov
44%
handle_cmd
12.0
BEGIN
1.0
BEGIN
1.0
CRAP 6.5
« App/lcpan/Cmd/extract_rel.pm ↑ Summary App/lcpan/Cmd/dist2rel.pm »
1 package App::lcpan::Cmd::mod2dist;
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 distribution name 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=3 SCAR=24.8
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 file.dist_name dist
38 FROM module
39 LEFT JOIN file ON module.file_id=file.id
40 WHERE module.name IN ($mods_s)");
41  
42 0 my $res;
43 0 ▶ if (@$mods == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$mods == 1) { } 0 0 0
44 0 $sth->execute;
45 0 (undef, $res) = $sth->fetchrow_array;
46 } else {
47 0 $sth->execute;
48 0 $res = {};
49 0 ▶ while (my $row = $sth->fetchrow_hashref) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $sth->fetchrow_hashref) 0 0 0
50 0 $res->{$row->{module}} = $row->{dist};
51 }
52 }
53 0 [200, "OK", $res];
54 }
55  
56 1 1;
57 # ABSTRACT: Get distribution name of module(s)
58  
59 __END__
« App/lcpan/Cmd/extract_rel.pm ↑ Summary App/lcpan/Cmd/dist2rel.pm »