File Coverage

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