File Coverage

blib/lib/Sah/Schema/perl/qualified_funcname.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1              
2             use strict;
3 1     1   40772 use warnings;
  1         2  
  1         26  
4 1     1   5  
  1         2  
  1         102  
5             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
6             our $DATE = '2021-12-01'; # DATE
7             our $DIST = 'Sah-Schemas-Perl'; # DIST
8             our $VERSION = '0.042'; # VERSION
9              
10             our $schema = [str => {
11             summary => 'Perl function name qualified with a package name, e.g. Foo::subname',
12             description => <<'_',
13              
14             Currently function name is restricted to this regex:
15              
16             \A[A-Za-z_][A-Za-z_0-9]*\z
17              
18             and package name is restricted to this regex:
19              
20             [A-Za-z_][A-Za-z_0-9]*(::[A-Za-z_0-9]+)*
21              
22             This schema includes syntax validity check only; it does not check whether the
23             function actually exists.
24              
25             _
26             match => '\A(?:[A-Za-z_][A-Za-z_0-9]*(::[A-Za-z_0-9]+)*::)[A-Za-z_]([A-Za-z_0-9]+)*\z',
27              
28             # TODO: provide convenience by providing list of core function names etc
29             #'x.completion' => 'perl_funcname',
30              
31             }];
32              
33             1;
34             # ABSTRACT: Perl function name qualified with a package name, e.g. Foo::subname
35              
36              
37             =pod
38              
39             =encoding UTF-8
40              
41             =head1 NAME
42              
43             Sah::Schema::perl::qualified_funcname - Perl function name qualified with a package name, e.g. Foo::subname
44              
45             =head1 VERSION
46              
47             This document describes version 0.042 of Sah::Schema::perl::qualified_funcname (from Perl distribution Sah-Schemas-Perl), released on 2021-12-01.
48              
49             =head1 SYNOPSIS
50              
51             To check data against this schema (requires L<Data::Sah>):
52              
53             use Data::Sah qw(gen_validator);
54             my $validator = gen_validator("perl::qualified_funcname*");
55             say $validator->($data) ? "valid" : "INVALID!";
56              
57             # Data::Sah can also create validator that returns nice error message string
58             # and/or coerced value. Data::Sah can even create validator that targets other
59             # language, like JavaScript. All from the same schema. See its documentation
60             # for more details.
61              
62             To validate function parameters against this schema (requires L<Params::Sah>):
63              
64             use Params::Sah qw(gen_validator);
65              
66             sub myfunc {
67             my @args = @_;
68             state $validator = gen_validator("perl::qualified_funcname*");
69             $validator->(\@args);
70             ...
71             }
72              
73             To specify schema in L<Rinci> function metadata and use the metadata with
74             L<Perinci::CmdLine> to create a CLI:
75              
76             # in lib/MyApp.pm
77             package MyApp;
78             our %SPEC;
79             $SPEC{myfunc} = {
80             v => 1.1,
81             summary => 'Routine to do blah ...',
82             args => {
83             arg1 => {
84             summary => 'The blah blah argument',
85             schema => ['perl::qualified_funcname*'],
86             },
87             ...
88             },
89             };
90             sub myfunc {
91             my %args = @_;
92             ...
93             }
94             1;
95              
96             # in myapp.pl
97             package main;
98             use Perinci::CmdLine::Any;
99             Perinci::CmdLine::Any->new(url=>'MyApp::myfunc')->run;
100              
101             # in command-line
102             % ./myapp.pl --help
103             myapp - Routine to do blah ...
104             ...
105              
106             % ./myapp.pl --version
107              
108             % ./myapp.pl --arg1 ...
109              
110             =head1 DESCRIPTION
111              
112             Currently function name is restricted to this regex:
113              
114             \A[A-Za-z_][A-Za-z_0-9]*\z
115              
116             and package name is restricted to this regex:
117              
118             [A-Za-z_][A-Za-z_0-9]*(::[A-Za-z_0-9]+)*
119              
120             This schema includes syntax validity check only; it does not check whether the
121             function actually exists.
122              
123             =head1 HOMEPAGE
124              
125             Please visit the project's homepage at L<https://metacpan.org/release/Sah-Schemas-Perl>.
126              
127             =head1 SOURCE
128              
129             Source repository is at L<https://github.com/perlancar/perl-Sah-Schemas-Perl>.
130              
131             =head1 SEE ALSO
132              
133             L<Sah::Schema::perl::funcname>
134              
135             L<Sah::Schema::perl::unqualified_funcname>
136              
137             =head1 AUTHOR
138              
139             perlancar <perlancar@cpan.org>
140              
141             =head1 CONTRIBUTING
142              
143              
144             To contribute, you can send patches by email/via RT, or send pull requests on
145             GitHub.
146              
147             Most of the time, you don't need to build the distribution yourself. You can
148             simply modify the code, then test via:
149              
150             % prove -l
151              
152             If you want to build the distribution (e.g. to try to install it locally on your
153             system), you can install L<Dist::Zilla>,
154             L<Dist::Zilla::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
155             Dist::Zilla plugin and/or Pod::Weaver::Plugin. Any additional steps required
156             beyond that are considered a bug and can be reported to me.
157              
158             =head1 COPYRIGHT AND LICENSE
159              
160             This software is copyright (c) 2021, 2020, 2019, 2018, 2017, 2016 by perlancar <perlancar@cpan.org>.
161              
162             This is free software; you can redistribute it and/or modify it under
163             the same terms as the Perl 5 programming language system itself.
164              
165             =head1 BUGS
166              
167             Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Sah-Schemas-Perl>
168              
169             When submitting a bug or request, please include a test-file or a
170             patch to an existing test-file that illustrates the bug or desired
171             feature.
172              
173             =cut