App/lcpan/Cmd/dist_meta.pm

filter: Statementstmt 57.1% 16 / 28 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 43.4% 20 / 46 CC 6 SCAR 33.4
CC
6
Cov
41%
handle_cmd
42.0
BEGIN
1.0
BEGIN
1.0
CRAP 28.3
« App/lcpan/Cmd/copy_rel.pm ↑ Summary App/lcpan/Cmd/deps_to_other_author.pm »
1 package App::lcpan::Cmd::dist_meta;
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 metadata',
19 args => {
20 %App::lcpan::common_args,
21 %App::lcpan::dist_args,
22 },
23 };
24 0 ▶sub handle_cmd {
Subroutine handle_cmd: not called CC=6 SCAR=37.4
Pod documented
25 0 my %args = @_;
26  
27 0 my $state = App::lcpan::_init(\%args, 'ro');
28 0 my $dbh = $state->{dbh};
29  
30 my ($cpanid, $file_name, $file_id, $has_metajson, $has_metayml) = $dbh->selectrow_array(
31 0 "SELECT cpanid, name, id, has_metajson, has_metayml FROM file WHERE is_latest_dist AND dist_name=?", {}, $args{dist});
32 0 ▶ $file_id or return [404, "No such dist '$args{dist}'"];
Branch: 1 branch
BranchTrueFalseTotal
$file_id or return [404, qq[No such dist '$args{"dist"}']] 0 0 0
33 0 ▶ $has_metajson || $has_metayml or return [412, "Dist does not have metadata"];
Branch: 1 branch
BranchTrueFalseTotal
$has_metajson or $has_metayml or return [412, "Dist does not have metadata"] 0 0 0
Condition0%0/3
$has_metajson or $has_metayml
l!l&&r!l&&!r
000
MC/DC0%0/2
$has_metajson or $has_metayml
$has_metajson $has_metayml
Truth table0%0/3
A or B
A= $has_metajsonB= $has_metayml
ABresult
1X1
011
000
34  
35 0 my $path = App::lcpan::_fullpath($file_name, $state->{cpan}, $cpanid);
36 0 my $la_res = App::lcpan::_list_archive_members($path, $file_name, $file_id);
37 0 ▶ return [500, "Can't read archive $path: $la_res->[1]"] unless $la_res->[0] == 200;
Branch: 1 branch
BranchTrueFalseTotal
unless $la_res->[0] == 200 0 0 0
38  
39 0 my $gm_res = App::lcpan::_get_meta($la_res);
40 0 ▶ return [500, "Can't extract distmeta from $path: $gm_res->[1]"] unless $gm_res->[0] == 200;
Branch: 1 branch
BranchTrueFalseTotal
unless $gm_res->[0] == 200 0 0 0
41 0 $gm_res;
42 }
43  
44 1 1;
45 # ABSTRACT: Get distribution metadata
46  
47 __END__
« App/lcpan/Cmd/copy_rel.pm ↑ Summary App/lcpan/Cmd/deps_to_other_author.pm »