line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::PodVersion 6.029; |
2
|
|
|
|
|
|
|
# ABSTRACT: add a VERSION head1 to each Perl document |
3
|
|
|
|
|
|
|
|
4
|
9
|
|
|
9
|
|
6513
|
use Moose; |
|
9
|
|
|
|
|
25
|
|
|
9
|
|
|
|
|
71
|
|
5
|
|
|
|
|
|
|
with( |
6
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileMunger', |
7
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileFinderUser' => { |
8
|
|
|
|
|
|
|
default_finders => [ ':InstallModules', ':ExecFiles' ], |
9
|
|
|
|
|
|
|
}, |
10
|
|
|
|
|
|
|
); |
11
|
|
|
|
|
|
|
|
12
|
9
|
|
|
9
|
|
65713
|
use Dist::Zilla::Pragmas; |
|
9
|
|
|
|
|
23
|
|
|
9
|
|
|
|
|
99
|
|
13
|
|
|
|
|
|
|
|
14
|
9
|
|
|
9
|
|
98
|
use namespace::autoclean; |
|
9
|
|
|
|
|
43
|
|
|
9
|
|
|
|
|
110
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
17
|
|
|
|
|
|
|
#pod |
18
|
|
|
|
|
|
|
#pod This plugin adds a C<=head1 VERSION> section to most perl files in the |
19
|
|
|
|
|
|
|
#pod distribution, indicating the version of the dist being built. This section is |
20
|
|
|
|
|
|
|
#pod added after C<=head1 NAME>. If there is no such section, the version section |
21
|
|
|
|
|
|
|
#pod will not be added. |
22
|
|
|
|
|
|
|
#pod |
23
|
|
|
|
|
|
|
#pod Note that this plugin is not useful if you are using the |
24
|
|
|
|
|
|
|
#pod L<[PodWeaver]|Dist::Zilla::Plugin::PodWeaver> plugin, as it also adds a |
25
|
|
|
|
|
|
|
#pod C<=head1 VERSION> section (via the L<[Version]|Pod::Weaver::Section::Version> |
26
|
|
|
|
|
|
|
#pod section). |
27
|
|
|
|
|
|
|
#pod |
28
|
|
|
|
|
|
|
#pod =cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub munge_files { |
31
|
9
|
|
|
9
|
0
|
2705
|
my ($self) = @_; |
32
|
|
|
|
|
|
|
|
33
|
9
|
|
|
|
|
26
|
$self->munge_file($_) for @{ $self->found_files }; |
|
9
|
|
|
|
|
70
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub munge_file { |
37
|
13
|
|
|
13
|
0
|
372
|
my ($self, $file) = @_; |
38
|
|
|
|
|
|
|
|
39
|
13
|
|
|
|
|
53
|
return $self->munge_pod($file); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub munge_pod { |
43
|
13
|
|
|
13
|
0
|
38
|
my ($self, $file) = @_; |
44
|
|
|
|
|
|
|
|
45
|
13
|
|
|
|
|
85
|
my @content = split /\n/, $file->content; |
46
|
|
|
|
|
|
|
|
47
|
13
|
|
|
|
|
122
|
require List::Util; |
48
|
13
|
|
|
|
|
225
|
List::Util->VERSION('1.33'); |
49
|
13
|
100
|
|
149
|
|
815
|
if (List::Util::any(sub { $_ =~ /^=head1 VERSION\b/ }, @content)) { |
|
149
|
|
|
|
|
291
|
|
50
|
1
|
|
|
|
|
19
|
$self->log($file->name . ' already has a VERSION section in POD'); |
51
|
1
|
|
|
|
|
266
|
return; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
12
|
|
|
|
|
101
|
for (0 .. $#content) { |
55
|
106
|
|
|
|
|
270
|
next until $content[$_] =~ /^=head1 NAME/; |
56
|
|
|
|
|
|
|
|
57
|
4
|
|
|
|
|
16
|
$_++; # move past the =head1 line itself |
58
|
4
|
|
|
|
|
36
|
$_++ while $content[$_] =~ /^\s*$/; |
59
|
|
|
|
|
|
|
|
60
|
4
|
|
|
|
|
29
|
$_++ while $content[$_] !~ /^\s*$/; # move past the abstract |
61
|
4
|
|
|
|
|
24
|
$_++ while $content[$_] =~ /^\s*$/; |
62
|
|
|
|
|
|
|
|
63
|
4
|
|
|
|
|
133
|
splice @content, $_ - 1, 0, ( |
64
|
|
|
|
|
|
|
q{}, |
65
|
|
|
|
|
|
|
"=head1 VERSION", |
66
|
|
|
|
|
|
|
q{}, |
67
|
|
|
|
|
|
|
"version " . $self->zilla->version . q{}, |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
4
|
|
|
|
|
22
|
$self->log_debug([ 'adding VERSION Pod section to %s', $file->name ]); |
71
|
|
|
|
|
|
|
|
72
|
4
|
|
|
|
|
420
|
my $content = join "\n", @content; |
73
|
4
|
50
|
|
|
|
30
|
$content .= "\n" if length $content; |
74
|
4
|
|
|
|
|
28
|
$file->content($content); |
75
|
4
|
|
|
|
|
28
|
return; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
$self->log([ |
79
|
8
|
|
|
|
|
75
|
"couldn't find '=head1 NAME' in %s, not adding '=head1 VERSION'", |
80
|
|
|
|
|
|
|
$file->name, |
81
|
|
|
|
|
|
|
]); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
88
|
|
|
|
|
|
|
#pod |
89
|
|
|
|
|
|
|
#pod Core Dist::Zilla plugins: |
90
|
|
|
|
|
|
|
#pod L<PkgVersion|Dist::Zilla::Plugin::PkgVersion>, |
91
|
|
|
|
|
|
|
#pod L<AutoVersion|Dist::Zilla::Plugin::AutoVersion>, |
92
|
|
|
|
|
|
|
#pod L<NextRelease|Dist::Zilla::Plugin::NextRelease>. |
93
|
|
|
|
|
|
|
#pod |
94
|
|
|
|
|
|
|
#pod =cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__END__ |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=pod |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=encoding UTF-8 |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 NAME |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Dist::Zilla::Plugin::PodVersion - add a VERSION head1 to each Perl document |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 VERSION |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
version 6.029 |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 DESCRIPTION |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This plugin adds a C<=head1 VERSION> section to most perl files in the |
113
|
|
|
|
|
|
|
distribution, indicating the version of the dist being built. This section is |
114
|
|
|
|
|
|
|
added after C<=head1 NAME>. If there is no such section, the version section |
115
|
|
|
|
|
|
|
will not be added. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Note that this plugin is not useful if you are using the |
118
|
|
|
|
|
|
|
L<[PodWeaver]|Dist::Zilla::Plugin::PodWeaver> plugin, as it also adds a |
119
|
|
|
|
|
|
|
C<=head1 VERSION> section (via the L<[Version]|Pod::Weaver::Section::Version> |
120
|
|
|
|
|
|
|
section). |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 PERL VERSION |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This module should work on any version of perl still receiving updates from |
125
|
|
|
|
|
|
|
the Perl 5 Porters. This means it should work on any version of perl released |
126
|
|
|
|
|
|
|
in the last two to three years. (That is, if the most recently released |
127
|
|
|
|
|
|
|
version is v5.40, then this module should work on both v5.40 and v5.38.) |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
130
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
131
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to lower |
132
|
|
|
|
|
|
|
the minimum required perl. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 SEE ALSO |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Core Dist::Zilla plugins: |
137
|
|
|
|
|
|
|
L<PkgVersion|Dist::Zilla::Plugin::PkgVersion>, |
138
|
|
|
|
|
|
|
L<AutoVersion|Dist::Zilla::Plugin::AutoVersion>, |
139
|
|
|
|
|
|
|
L<NextRelease|Dist::Zilla::Plugin::NextRelease>. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 AUTHOR |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Ricardo SIGNES 😏 <cpan@semiotic.systems> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Ricardo SIGNES. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
150
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=cut |