File Coverage

blib/lib/Data/Sah/Coerce/perl/To_str/From_str/normalize_perl_modprefix.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 20 22 90.9


line stmt bran cond sub pod time code
1              
2             use 5.010001;
3 1     1   5973 use strict;
  1         4  
4 1     1   4 use warnings;
  1         2  
  1         17  
5 1     1   4  
  1         2  
  1         210  
6             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
7             our $DATE = '2022-09-11'; # DATE
8             our $DIST = 'Sah-Schemas-Perl'; # DIST
9             our $VERSION = '0.045'; # VERSION
10              
11             +{
12             v => 4,
13             summary => 'Coerce perl::modprefix from str',
14 1     1 0 10 prio => 50,
15             };
16             }
17              
18             my %args = @_;
19              
20             my $dt = $args{data_term};
21 1     1 0 14  
22             my $res = {};
23 1         2  
24             $res->{expr_match} = "!ref($dt)";
25 1         2 $res->{expr_coerce} = join(
26             "",
27 1         2 "do { my \$tmp = $dt;",
28 1         4 " my \$argssuffix = ''; \$argssuffix = \$1 if \$tmp =~ s/(=.*)\\z//;", # extract args suffix (=arg1,arg2) first
29             " my \$versuffix = ''; \$versuffix = \$1 if \$tmp =~ s/(\@[0-9][0-9A-Za-z]*(\\.[0-9A-Za-z_]+)*)\\z//;", # extract version suffix part first
30             " \$tmp =~ s!::?|/|\\.|-!::!g; \$tmp .= '::' if \$tmp =~ /\\A\\w+(::\\w+)*\\z/;",
31             " \$tmp . \$versuffix . \$argssuffix",
32             "}",
33             );
34              
35             $res;
36             }
37              
38 1         3 1;
39             # ABSTRACT:
40              
41              
42             =pod
43              
44             =encoding UTF-8
45              
46             =head1 NAME
47              
48             Data::Sah::Coerce::perl::To_str::From_str::normalize_perl_modprefix
49              
50             =head1 VERSION
51              
52             This document describes version 0.045 of Data::Sah::Coerce::perl::To_str::From_str::normalize_perl_modprefix (from Perl distribution Sah-Schemas-Perl), released on 2022-09-11.
53              
54             =head1 DESCRIPTION
55              
56             This rule can normalize strings in the form of:
57              
58             Foo::Bar
59              
60             Foo:Bar
61             Foo:Bar:
62              
63             Foo-Bar
64             Foo-Bar-
65              
66             Foo/Bar
67             Foo/Bar/
68              
69             Foo.Bar
70             Foo.Bar.
71              
72             into:
73              
74             Foo::Bar::
75              
76             =for Pod::Coverage ^(meta|coerce)$
77              
78             =head1 HOMEPAGE
79              
80             Please visit the project's homepage at L<https://metacpan.org/release/Sah-Schemas-Perl>.
81              
82             =head1 SOURCE
83              
84             Source repository is at L<https://github.com/perlancar/perl-Sah-Schemas-Perl>.
85              
86             =head1 AUTHOR
87              
88             perlancar <perlancar@cpan.org>
89              
90             =head1 CONTRIBUTING
91              
92              
93             To contribute, you can send patches by email/via RT, or send pull requests on
94             GitHub.
95              
96             Most of the time, you don't need to build the distribution yourself. You can
97             simply modify the code, then test via:
98              
99             % prove -l
100              
101             If you want to build the distribution (e.g. to try to install it locally on your
102             system), you can install L<Dist::Zilla>,
103             L<Dist::Zilla::PluginBundle::Author::PERLANCAR>,
104             L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
105             Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond
106             that are considered a bug and can be reported to me.
107              
108             =head1 COPYRIGHT AND LICENSE
109              
110             This software is copyright (c) 2022, 2021, 2020, 2019, 2018, 2017, 2016 by perlancar <perlancar@cpan.org>.
111              
112             This is free software; you can redistribute it and/or modify it under
113             the same terms as the Perl 5 programming language system itself.
114              
115             =head1 BUGS
116              
117             Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Sah-Schemas-Perl>
118              
119             When submitting a bug or request, please include a test-file or a
120             patch to an existing test-file that illustrates the bug or desired
121             feature.
122              
123             =cut