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