File Coverage

blib/lib/Data/Sah/Coerce/perl/To_str/From_str/normalize_perl_distname.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   7125 use strict;
  1         3  
4 1     1   5 use warnings;
  1         2  
  1         18  
5 1     1   4  
  1         1  
  1         196  
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::distname 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 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         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 (@1.23) 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_distname
50              
51             =head1 VERSION
52              
53             This document describes version 0.045 of Data::Sah::Coerce::perl::To_str::From_str::normalize_perl_distname (from Perl distribution Sah-Schemas-Perl), released on 2022-09-11.
54              
55             =head1 DESCRIPTION
56              
57             This rule can normalize strings in the form of:
58              
59             Foo/Bar.pm
60             Foo::Bar
61             Foo:Bar
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>,
97             L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
98             Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond
99             that are considered a bug and can be reported to me.
100              
101             =head1 COPYRIGHT AND LICENSE
102              
103             This software is copyright (c) 2022, 2021, 2020, 2019, 2018, 2017, 2016 by perlancar <perlancar@cpan.org>.
104              
105             This is free software; you can redistribute it and/or modify it under
106             the same terms as the Perl 5 programming language system itself.
107              
108             =head1 BUGS
109              
110             Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Sah-Schemas-Perl>
111              
112             When submitting a bug or request, please include a test-file or a
113             patch to an existing test-file that illustrates the bug or desired
114             feature.
115              
116             =cut