File Coverage

blib/lib/Data/Sah/Coerce/perl/To_str/From_str/normalize_perl_modname_or_prefix.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   6468 use strict;
  1         4  
4 1     1   6 use warnings;
  1         2  
  1         39  
5 1     1   6  
  1         2  
  1         188  
6             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
7             our $DATE = '2021-12-01'; # DATE
8             our $DIST = 'Sah-Schemas-Perl'; # DIST
9             our $VERSION = '0.042'; # VERSION
10              
11             +{
12             v => 4,
13             summary => 'Coerce perl::modname_or_prefix from str',
14 1     1 0 11 prio => 50,
15             };
16             }
17              
18             my %args = @_;
19              
20             my $dt = $args{data_term};
21 1     1 0 16  
22             my $res = {};
23 1         2  
24             $res->{expr_match} = "!ref($dt)";
25 1         2 $res->{expr_coerce} = join(
26             "",
27 1         3 "do { my \$tmp = $dt;",
28 1         5 " 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 = \$1 if \$tmp =~ m!\\A(\\w+(?:/\\w+)*)\.pm\\z!;",
31             " \$tmp =~ s!::?|/|\\.|-!::!g;",
32             " \$tmp . \$versuffix . \$argssuffix",
33             "}",
34             );
35              
36             $res;
37             }
38              
39 1         3 1;
40             # ABSTRACT:
41              
42              
43             =pod
44              
45             =encoding UTF-8
46              
47             =head1 NAME
48              
49             Data::Sah::Coerce::perl::To_str::From_str::normalize_perl_modname_or_prefix
50              
51             =head1 VERSION
52              
53             This document describes version 0.042 of Data::Sah::Coerce::perl::To_str::From_str::normalize_perl_modname_or_prefix (from Perl distribution Sah-Schemas-Perl), released on 2021-12-01.
54              
55             =head1 DESCRIPTION
56              
57             This rule can normalize strings in the form of:
58              
59             Foo::Bar
60             Foo:Bar
61             Foo-Bar
62             Foo/Bar
63             Foo/Bar.pm
64             Foo.Bar
65              
66             into `Foo::Bar`, while normalizing strings in the form of:
67              
68             Foo:Bar:
69             Foo-Bar-
70             Foo/Bar/
71             Foo.Bar.
72              
73             into:
74              
75             Foo::Bar::
76              
77             =for Pod::Coverage ^(meta|coerce)$
78              
79             =head1 HOMEPAGE
80              
81             Please visit the project's homepage at L<https://metacpan.org/release/Sah-Schemas-Perl>.
82              
83             =head1 SOURCE
84              
85             Source repository is at L<https://github.com/perlancar/perl-Sah-Schemas-Perl>.
86              
87             =head1 AUTHOR
88              
89             perlancar <perlancar@cpan.org>
90              
91             =head1 CONTRIBUTING
92              
93              
94             To contribute, you can send patches by email/via RT, or send pull requests on
95             GitHub.
96              
97             Most of the time, you don't need to build the distribution yourself. You can
98             simply modify the code, then test via:
99              
100             % prove -l
101              
102             If you want to build the distribution (e.g. to try to install it locally on your
103             system), you can install L<Dist::Zilla>,
104             L<Dist::Zilla::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
105             Dist::Zilla plugin and/or Pod::Weaver::Plugin. Any additional steps required
106             beyond that are considered a bug and can be reported to me.
107              
108             =head1 COPYRIGHT AND LICENSE
109              
110             This software is copyright (c) 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