App/lcpan/Cmd/mods_from_same_dist.pm

filter: Statementstmt 44.4% 16 / 36 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 39.2% 20 / 51 CC 6 SCAR 33.4
CC
6
Cov
35%
handle_cmd
42.0
BEGIN
1.0
BEGIN
1.0
CRAP 28.3
« App/lcpan/Cmd/authors_by_mod_mention_count.pm ↑ Summary App/lcpan/Cmd/scripts_from_same_dist.pm »
1 package App::lcpan::Cmd::mods_from_same_dist;
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 => 'Given a module, list all modules in the same distribution',
19 args => {
20 %App::lcpan::common_args,
21 %App::lcpan::mods_args,
22 %App::lcpan::flatest_args,
23 %App::lcpan::detail_args,
24 },
25 };
26 0 ▶sub handle_cmd {
Subroutine handle_cmd: not called CC=6 SCAR=37.4
Pod documented
27 0 my %args = @_;
28  
29 0 my $state = App::lcpan::_init(\%args, 'ro');
30 0 my $dbh = $state->{dbh};
31  
32 0 my $detail = $args{detail};
33  
34 0 my $emods = join(",", map {$dbh->quote($_)} @{ $args{modules} });
35 0 my @where;
36 0 push @where, "f.id IN (SELECT file_id FROM module WHERE name IN ($emods))";
37 0 ▶ if ($args{latest}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($args{'latest'}) { } 0 0 0
elsif (defined $args{'latest'}) { } 0 0 0
38 0 push @where, "f.is_latest_dist";
39 } elsif (defined $args{latest}) {
40 0 push @where, "NOT(f.is_latest_dist)";
41 }
42 0 my $sth = $dbh->prepare("SELECT
43 module.name name,
44 module.version version,
45 module.abstract abstract,
46 f.dist_name dist,
47 f.dist_version dist_version
48 FROM module
49 JOIN file f ON module.file_id=f.id
50 WHERE ".join(" AND ", @where)."
51 ORDER BY name DESC");
52 0 $sth->execute;
53 0 my @res;
54 0 ▶ while (my $row = $sth->fetchrow_hashref) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $sth->fetchrow_hashref) 0 0 0
55 0 ▶ push @res, $detail ? $row : $row->{name};
Branch: 1 branch
BranchTrueFalseTotal
$detail ? : 0 0 0
56 }
57 0 my $resmeta = {};
58 0 ▶ $resmeta->{'table.fields'} = [qw/name version abstract dist dist_version/]
Branch: 1 branch
BranchTrueFalseTotal
if $detail 0 0 0
59 if $detail;
60 0 [200, "OK", \@res, $resmeta];
61 }
62  
63 1 1;
64 # ABSTRACT: Given a module, list all modules in the same distribution
65  
66 __END__
« App/lcpan/Cmd/authors_by_mod_mention_count.pm ↑ Summary App/lcpan/Cmd/scripts_from_same_dist.pm »