Sah/Schema/perl/pod_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/pm_filename.pm ↑ Summary Sah/Schema/perl/pod_or_pm_filename.pm »
1 package Sah::Schema::perl::pod_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 filename, e.g. /path/Foo.pod',
13 description => <<'_',
14  
15 Use this schema if you want to accept a filesystem path containing Perl POD. The
16 value of this schema is in the convenience of CLI completion, as well as
17 coercion from POD name.
18  
19 String containing filename of a Perl .pod file. For convenience, when value is
20 in the form of:
21  
22 Foo
23 Foo.pod
24 Foo::Bar
25 Foo/Bar
26 Foo/Bar.pod
27  
28 and a matching .pod file is found in `@INC`, then it will be coerced (converted)
29 into the filesystem path of that .pod file, e.g.:
30  
31 /home/ujang/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Foo/Bar.pod
32  
33 To prevent such coercion, you can use prefixing path, e.g.:
34  
35 ./Foo::Bar
36 ../Foo/Bar
37 /path/to/Foo/Bar
38  
39 This schema comes with convenience completion too.
40  
41 _
42 'x.perl.coerce_rules' => [
43 'From_str::convert_perl_pod_to_path',
44 ],
45 0 ▶ 'x.completion' => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
46 0 require Complete::File;
47 0 require Complete::Module;
48 0 require Complete::Util;
49  
50 0 my %args = @_;
51 0 my $word = $args{word};
52  
53 0 my @answers;
54 0 push @answers, Complete::File::complete_file(word => $word);
55 0 ▶ if ($word =~ m!\A\w*((?:::|/)\w+)*\z!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($word =~ m[\A\w*((?:::|/)\w+)*\z]) 0 0 0
56 0 push @answers, Complete::Module::complete_module(
57 word => $word, find_pod=>1, find_pm=>0, find_pmc=>0);
58 }
59  
60 0 Complete::Util::combine_answers(@answers);
61 },
62  
63 1 }];
64  
65 1 1;
66 # ABSTRACT: A .pod filename, e.g. /path/Foo.pod
67  
68 __END__
« Sah/Schema/perl/pm_filename.pm ↑ Summary Sah/Schema/perl/pod_or_pm_filename.pm »