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

filter: Statementstmt 50.0% 13 / 26 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 34.0% 16 / 47 CC 7 SCAR 35.9
CC
7
Cov
34%
coerce
56.0
meta
2.0
BEGIN
1.0
CRAP 36.1
« Data/Sah/Coerce/perl/To_array/From_str_or_array/expand_perl_modname_wildcard.pm ↑ Summary Sah/Schema/perl/filename.pm »
1 package Data::Sah::Coerce::perl::To_array::From_str_or_array::expand_perl_modprefix_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 prefixes',
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 my %cargs = @_;
27  
28 0 my $dt = $cargs{data_term};
29 0 my $gen_args = $cargs{args};
30  
31 0 my $ns_prefix = $gen_args->{ns_prefix};
32 0 ▶ if (defined $ns_prefix) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ns_prefix) 0 0 0
33 0 ▶ $ns_prefix .= "::" unless $ns_prefix =~ /::\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $ns_prefix =~ /::\z/ 0 0 0
34 }
35  
36 0 my $res = {};
37  
38 0 $res->{expr_match} = "ref($dt) eq '' || ref($dt) eq 'ARRAY'";
39 0 ▶ $res->{modules}{"PERLANCAR::Module::List"} //= "0.004004";
Condition0%0/2
$res->{"modules"}{"PERLANCAR::Module::List"} //= "0.004004"
l!l
00
MC/DC0%0/1
$res->{"modules"}{"PERLANCAR::Module::List"} //= "0.004004"
$res->{"modules"}{"PERLANCAR::Module::List"}
Truth table0%0/2
A
A= $res->{"modules"}{"PERLANCAR::Module::List"}
Aresult
11
00
40 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
41 0 ▶ $res->{expr_coerce} = join(
Branch: 2 branches
BranchTrueFalseTotal
defined $ns_prefix ? : 0 0 0
defined $ns_prefix ? : 0 0 0
42 "",
43 "do { ",
44 "my \$tmp = $dt; \$tmp = [\$tmp] unless ref \$tmp eq 'ARRAY'; ",
45 "my \$i = -1; ",
46 "while (++\$i < \@\$tmp) { ",
47 " next if \$tmp->[\$i] =~ /=/; ", # probably a perl::modname_with_optional_args instead of just perl::modname, skip expanding wildcard
48 " \$tmp->[\$i] =~ s!/!::!g; ",
49 " my \$el = \$tmp->[\$i]; ",
50 " next unless String::Wildcard::Bash::contains_wildcard(\$el); ",
51 " my \$mods = PERLANCAR::Module::List::list_modules(" . (defined($ns_prefix) ? Data::Dmp::dmp($ns_prefix) . " . " : "") . "\$el, {wildcard=>1, list_modules=>0, list_prefixes=>1}); ",
52 " my \@mods = sort keys \%\$mods; ",
53 (defined($ns_prefix) ? " for (\@mods) { substr(\$_, 0, ".length($ns_prefix).") = '' } " : ""),
54 " if (\@mods) { splice \@\$tmp, \$i, 1, \@mods; \$i += \@mods - 1 } ",
55 "} ", # while
56 "\$tmp ",
57 "}", # do
58 );
59  
60 0 $res;
61 }
62  
63 1 1;
64 # ABSTRACT:
65  
66 __END__
« Data/Sah/Coerce/perl/To_array/From_str_or_array/expand_perl_modname_wildcard.pm ↑ Summary Sah/Schema/perl/filename.pm »