Sah/Schema/perl/pod_or_pm_filename.pm

filter: Statementstmt 54.5% 12 / 22 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod n/a totaltotal 51.8% 14 / 27 CC 2 SCAR 12.5
CC
2
Cov
50%
__ANON__
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.5
« Sah/Schema/perl/pod_filename.pm ↑ Summary Data/Sah/Coerce/perl/To_str/From_str/convert_perl_pm_or_pod_to_path.pm »
1 package Sah::Schema::perl::pod_or_pm_filename;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
7 1 our $DATE = '2024-02-16'; # DATE
8 1 our $DIST = 'Sah-SchemaBundle-Perl'; # DIST
9 1 our $VERSION = '0.050'; # VERSION
10  
11 our $schema = [str => {
12 summary => 'A .pod or .pm filename, e.g. /path/Foo.pm or /path/Bar/Baz.pod',
13 description => <<'_',
14  
15 String containing filename of a Perl POD or module. For convenience, when value
16 is in the form of:
17  
18 Foo
19 Foo.pod
20 Foo.pm
21 Foo::Bar
22 Foo/Bar
23 Foo/Bar.pod
24 Foo/Bar.pm
25  
26 and a matching .pod or .pm file is found in `@INC`, then it will be coerced
27 (converted) into the path of that .pod/.pm file, e.g.:
28  
29 /home/ujang/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Foo/Bar.pm
30 lib/Foo/Bar.pod
31  
32 To prevent such coercion, you can use prefixing path, e.g.:
33  
34 ./Foo::Bar
35 ../Foo/Bar
36 /path/to/Foo/Bar
37  
38 This schema comes with convenience completion too.
39  
40 This schema is like another schema `perl::filename` except that .pod is
41 prioritized over .pm. If both `Foo.pm` and `Foo.pod` are found in `@INC`, the
42 path to `Foo.pod` will be returned.
43  
44 _
45 'x.perl.coerce_rules' => [
46 'From_str::convert_perl_pod_or_pm_to_path',
47 ],
48 0 ▶ 'x.completion' => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
49 0 require Complete::File;
50 0 require Complete::Module;
51 0 require Complete::Util;
52  
53 0 my %args = @_;
54 0 my $word = $args{word};
55  
56 0 my @answers;
57 0 push @answers, Complete::File::complete_file(word => $word);
58 0 ▶ if ($word =~ m!\A\w*((?:::|/)\w+)*\z!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($word =~ m[\A\w*((?:::|/)\w+)*\z]) 0 0 0
59 0 push @answers, Complete::Module::complete_module(word => $word);
60 }
61  
62 0 Complete::Util::combine_answers(@answers);
63 },
64  
65 1 }];
66  
67 1 1;
68 # ABSTRACT: A .pod or .pm filename, e.g. /path/Foo.pm or /path/Bar/Baz.pod
69  
70 __END__
« Sah/Schema/perl/pod_filename.pm ↑ Summary Data/Sah/Coerce/perl/To_str/From_str/convert_perl_pm_or_pod_to_path.pm »