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