line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
1512580
|
use 5.10.0; |
|
1
|
|
|
|
|
2
|
|
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
16
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::PodnameFromClassname; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: Insert PODNAME for Moops classes. |
8
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY |
9
|
|
|
|
|
|
|
our $VERSION = '0.1100'; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
4
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
12
|
1
|
|
|
1
|
|
4143
|
use namespace::autoclean; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
13
|
|
|
|
|
|
|
with ('Dist::Zilla::Role::FileMunger', 'Dist::Zilla::Role::FileFinderUser' => { default_finders => [':InstallModules']}); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub munge_files { |
16
|
1
|
|
|
1
|
0
|
40867
|
my $self = shift; |
17
|
1
|
|
|
|
|
2
|
$self->munge_file($_) for @{ $self->found_files }; |
|
1
|
|
|
|
|
4
|
|
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub munge_file { |
21
|
1
|
|
|
1
|
0
|
423
|
my $self = shift; |
22
|
1
|
|
|
|
|
1
|
my $file = shift; |
23
|
1
|
|
|
|
|
5
|
my $content = $file->content; |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
713
|
my $optional_ws = qr/[\t ]*/; |
26
|
|
|
|
|
|
|
|
27
|
1
|
50
|
|
|
|
66
|
if($content !~ m{^$optional_ws# PODCLASSNAME:?$}ms) { |
|
|
50
|
|
|
|
|
|
28
|
0
|
|
|
|
|
0
|
$self->log_debug(["Skipping %s, no # PODCLASSNAME directive found", $file->name]); |
29
|
0
|
|
|
|
|
0
|
return; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
elsif($content !~ m{^$optional_ws(?:class|library|namespace|role) +([a-zA-Z][a-zA-Z0-9_]*(?:::[a-zA-Z][a-zA-Z0-9_]*)*)}ms) { |
32
|
0
|
|
|
|
|
0
|
$self->log_debug(["Skipping %s, none of the keywords found", $file->name]); |
33
|
0
|
|
|
|
|
0
|
return; |
34
|
|
|
|
|
|
|
} |
35
|
1
|
|
|
|
|
4
|
my $classname = $1; |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
21
|
$content =~ s{^($optional_ws)# PODCLASSNAME:?$}{$1# PODNAME: $classname}ms; |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
7
|
$self->log(["Inserting podname for $classname"]); |
40
|
1
|
|
|
|
|
229
|
$file->content($content); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=pod |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=encoding UTF-8 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Dist::Zilla::Plugin::PodnameFromClassname - Insert PODNAME for Moops classes. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=begin html |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
<p> |
63
|
|
|
|
|
|
|
<img src="https://img.shields.io/badge/perl-5.10+-blue.svg" alt="Requires Perl 5.10+" /> |
64
|
|
|
|
|
|
|
<a href="https://travis-ci.org/Csson/p5-Dist-Zilla-Plugin-PodnameFromClassname"><img src="https://api.travis-ci.org/Csson/p5-Dist-Zilla-Plugin-PodnameFromClassname.svg?branch=master" alt="Travis status" /></a> |
65
|
|
|
|
|
|
|
<a href="http://cpants.cpanauthors.org/dist/Dist-Zilla-Plugin-PodnameFromClassname-0.1100"><img src="https://badgedepot.code301.com/badge/kwalitee/Dist-Zilla-Plugin-PodnameFromClassname/0.1100" alt="Distribution kwalitee" /></a> |
66
|
|
|
|
|
|
|
<a href="http://matrix.cpantesters.org/?dist=Dist-Zilla-Plugin-PodnameFromClassname%200.1100"><img src="https://badgedepot.code301.com/badge/cpantesters/Dist-Zilla-Plugin-PodnameFromClassname/0.1100" alt="CPAN Testers result" /></a> |
67
|
|
|
|
|
|
|
<img src="https://img.shields.io/badge/coverage-81.4%-orange.svg" alt="coverage 81.4%" /> |
68
|
|
|
|
|
|
|
</p> |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=end html |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 VERSION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Version 0.1100, released 2016-04-02. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SYNOPSIS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
In dist.ini: |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
[PodnameFromClassname] |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
In a L<Moops> class: |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# PODCLASSNAME |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
class My::Class { ... } |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Results in: |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# PODNAME: My::Class |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
class My::Class { ... } |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 DESCRIPTION |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Dist::Zilla::Plugin::PodnameFromClassname is useful together with L<Moops> and L<Pod::Weaver>. Since Moops classes generally don't also have a C<package> statement C<Pod::Weaver> can't pick up the module name. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Using this plugin and adding a C<# PODCLASSNAME> line fixes that (by replacing such a line with the standard C<# PODNAME: $classname> comment). There should be only one C<# PODCLASSNAME> comment per file. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
The plugin picks the first line that starts with C<class>, C<role>, C<namespace> or C<library> and uses the package name given on that line. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
The comment line should match this regular expression: |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
qr/^[\t ]*# PODCLASSNAME:?$/ms |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Note: While this plugin was developed with L<Moops> in mind, it should work with any module that introduces any of those keywords. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 SEE ALSO |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=over 4 |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
L<Dist::Zilla::Plugin::PodnameFromFilename> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
L<Dist::Zilla> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=back |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 SOURCE |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
L<https://github.com/Csson/p5-Dist-Zilla-Plugin-PodnameFromClassname> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 HOMEPAGE |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
L<https://metacpan.org/release/Dist-Zilla-Plugin-PodnameFromClassname> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 AUTHOR |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Erik Carlsson <info@code301.com> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Erik Carlsson. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
139
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |