File Coverage

blib/lib/Data/Sah/Coerce/perl/To_str/From_str/normalize_perl_modname.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   5671 use strict;
  1         4  
4 1     1   4 use warnings;
  1         2  
  1         18  
5 1     1   11  
  1         3  
  1         183  
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 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 13  
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         3 " 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
50              
51             =head1 VERSION
52              
53             This document describes version 0.042 of Data::Sah::Coerce::perl::To_str::From_str::normalize_perl_modname (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.pm
62             Foo/Bar
63             Foo.Bar
64              
65             into:
66              
67             Foo::Bar
68              
69             =for Pod::Coverage ^(meta|coerce)$
70              
71             =head1 HOMEPAGE
72              
73             Please visit the project's homepage at L<https://metacpan.org/release/Sah-Schemas-Perl>.
74              
75             =head1 SOURCE
76              
77             Source repository is at L<https://github.com/perlancar/perl-Sah-Schemas-Perl>.
78              
79             =head1 AUTHOR
80              
81             perlancar <perlancar@cpan.org>
82              
83             =head1 CONTRIBUTING
84              
85              
86             To contribute, you can send patches by email/via RT, or send pull requests on
87             GitHub.
88              
89             Most of the time, you don't need to build the distribution yourself. You can
90             simply modify the code, then test via:
91              
92             % prove -l
93              
94             If you want to build the distribution (e.g. to try to install it locally on your
95             system), you can install L<Dist::Zilla>,
96             L<Dist::Zilla::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
97             Dist::Zilla plugin and/or Pod::Weaver::Plugin. Any additional steps required
98             beyond that are considered a bug and can be reported to me.
99              
100             =head1 COPYRIGHT AND LICENSE
101              
102             This software is copyright (c) 2021, 2020, 2019, 2018, 2017, 2016 by perlancar <perlancar@cpan.org>.
103              
104             This is free software; you can redistribute it and/or modify it under
105             the same terms as the Perl 5 programming language system itself.
106              
107             =head1 BUGS
108              
109             Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Sah-Schemas-Perl>
110              
111             When submitting a bug or request, please include a test-file or a
112             patch to an existing test-file that illustrates the bug or desired
113             feature.
114              
115             =cut