Data/Sah/Coerce/perl/To_array/From_str_or_array/expand_perl_modname_wildcard.pm

filter: Statementstmt 48.1% 13 / 27 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 60.0% 3 / 5 Podpod 0.0% 0 / 2 totaltotal 33.3% 16 / 48 CC 7 SCAR 35.9
CC
7
Cov
33%
coerce
56.0
meta
2.0
BEGIN
1.0
CRAP 36.1
↑ Summary Data/Sah/Coerce/perl/To_array/From_str_or_array/expand_perl_modprefix_wildcard.pm »
1 package Data::Sah::Coerce::perl::To_array::From_str_or_array::expand_perl_modname_wildcard;
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 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
8 1 our $DATE = '2024-02-16'; # DATE
9 1 our $DIST = 'Sah-SchemaBundle-Perl'; # DIST
10 1 our $VERSION = '0.050'; # VERSION
11  
12 0 ▶sub meta {
Subroutine meta: not called CC=1 SCAR=6.9
Pod undocumented
13 +{
14 0 v => 4,
15 summary => 'Expand wildcard of Perl module names',
16 prio => 50,
17 args => {
18 ns_prefix => {
19 schema => 'str*',
20 },
21 },
22 };
23 }
24  
25 0 ▶sub coerce {
Subroutine coerce: not called CC=7 SCAR=40.3
Pod undocumented
26 0 require Data::Dmp;
27  
28 0 my %cargs = @_;
29  
30 0 my $dt = $cargs{data_term};
31 0 my $gen_args = $cargs{args};
32  
33 0 my $ns_prefix = $gen_args->{ns_prefix};
34 0 ▶ if (defined $ns_prefix) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ns_prefix) 0 0 0
35 0 ▶ $ns_prefix .= "::" unless $ns_prefix =~ /::\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $ns_prefix =~ /::\z/ 0 0 0
36 }
37  
38 0 my $res = {};
39 0 $res->{expr_match} = "ref($dt) eq '' || ref($dt) eq 'ARRAY'";
40 0 ▶ $res->{modules}{"PERLANCAR::Module::List"} //= "0.004002";
Condition0%0/2
$res->{"modules"}{"PERLANCAR::Module::List"} //= "0.004002"
l!l
00
MC/DC0%0/1
$res->{"modules"}{"PERLANCAR::Module::List"} //= "0.004002"
$res->{"modules"}{"PERLANCAR::Module::List"}
Truth table0%0/2
A
A= $res->{"modules"}{"PERLANCAR::Module::List"}
Aresult
11
00
41 0 ▶ $res->{modules}{"String::Wildcard::Bash"} //= "0.040";
Condition0%0/2
$res->{"modules"}{"String::Wildcard::Bash"} //= "0.040"
l!l
00
MC/DC0%0/1
$res->{"modules"}{"String::Wildcard::Bash"} //= "0.040"
$res->{"modules"}{"String::Wildcard::Bash"}
Truth table0%0/2
A
A= $res->{"modules"}{"String::Wildcard::Bash"}
Aresult
11
00
42 0 ▶ $res->{expr_coerce} = join(
Branch: 2 branches
BranchTrueFalseTotal
defined $ns_prefix ? : 0 0 0
defined $ns_prefix ? : 0 0 0
43 "",
44 "do { ",
45 "my \$tmp = $dt; \$tmp = [\$tmp] unless ref \$tmp eq 'ARRAY'; ",
46 "my \$i = -1; ",
47 "while (++\$i < \@\$tmp) { ",
48 " next if \$tmp->[\$i] =~ /=/; ", # probably a perl::modname_with_optional_args instead of just perl::modname, skip expanding wildcard
49 " \$tmp->[\$i] =~ s!/!::!g; ",
50 " my \$el = \$tmp->[\$i]; ",
51 " next unless String::Wildcard::Bash::contains_wildcard(\$el); ",
52 " my \$mods = PERLANCAR::Module::List::list_modules(" . (defined($ns_prefix) ? Data::Dmp::dmp($ns_prefix) . " . " : "") . "\$el, {wildcard=>1, list_modules=>1}); ",
53 " my \@mods = sort keys \%\$mods; ",
54 (defined($ns_prefix) ? " for (\@mods) { substr(\$_, 0, ".length($ns_prefix).") = '' } " : ""),
55 " if (\@mods) { splice \@\$tmp, \$i, 1, \@mods; \$i += \@mods - 1 } ",
56 "} ", # while
57 "\$tmp ",
58 "}", # do
59 );
60  
61 0 $res;
62 }
63  
64 1 1;
65 # ABSTRACT:
66  
67 __END__
↑ Summary Data/Sah/Coerce/perl/To_array/From_str_or_array/expand_perl_modprefix_wildcard.pm »