line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::CoalescePod; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:YANICK'; |
3
|
|
|
|
|
|
|
# ABSTRACT: merge .pod files into their .pm counterparts |
4
|
|
|
|
|
|
|
$Dist::Zilla::Plugin::CoalescePod::VERSION = '0.3.0'; |
5
|
1
|
|
|
1
|
|
4458294
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
6
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with qw( |
11
|
|
|
|
|
|
|
Dist::Zilla::Role::FileMunger |
12
|
|
|
|
|
|
|
Dist::Zilla::Role::FilePruner |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has _pod_files => ( |
16
|
|
|
|
|
|
|
is => 'rw', |
17
|
|
|
|
|
|
|
isa => 'ArrayRef', |
18
|
|
|
|
|
|
|
default => sub { [] }, |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub munge_file { |
22
|
7
|
|
|
7
|
0
|
43490
|
my ( $self, $file ) = @_; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# only look under /lib |
25
|
7
|
100
|
|
|
|
21
|
return unless $file->name =~ m#^lib/.*\.pm$#; |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
105
|
( my $podname = $file->name ) =~ s/\.pm$/.pod/; |
28
|
|
|
|
|
|
|
|
29
|
4
|
|
|
|
|
113
|
my ( $podfile ) = grep { $_->name eq $podname } |
30
|
2
|
50
|
|
|
|
103
|
@{ $self->_pod_files } or return; |
|
2
|
|
|
|
|
67
|
|
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
|
|
91
|
$self->log( "merged " . $podfile->name . " into " . $file->name ); |
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
|
|
924
|
my @content = ( $file->content ); |
35
|
|
|
|
|
|
|
|
36
|
2
|
100
|
|
|
|
843
|
if( $content[0] =~ s/(^__DATA__.*)//ms ) { |
37
|
1
|
|
|
|
|
4
|
push @content, $1; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# inject the pod |
41
|
2
|
|
|
|
|
9
|
splice @content, 1, 0, $podfile->content; |
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
1460
|
$file->content( join "\n\n", @content ); |
44
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
481
|
return; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub prune_files { |
49
|
1
|
|
|
1
|
0
|
151557
|
my ($self) = @_; |
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
4
|
my @files = @{ $self->zilla->files }; |
|
1
|
|
|
|
|
36
|
|
52
|
1
|
|
|
|
|
40
|
foreach my $file ( @files ) { |
53
|
10
|
100
|
|
|
|
509
|
next unless $file->name =~ m/\.pod$/; |
54
|
2
|
50
|
|
|
|
97
|
next if $file->name =~ /t\/corpus/; |
55
|
|
|
|
|
|
|
|
56
|
2
|
|
|
|
|
98
|
push @{ $self->_pod_files }, $file; |
|
2
|
|
|
|
|
70
|
|
57
|
2
|
|
|
|
|
55
|
$self->zilla->prune_file($file); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
120
|
return; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
#PODNAME: Foo |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=pod |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=encoding UTF-8 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 NAME |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Foo - merge .pod files into their .pm counterparts |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 VERSION |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
version 0.3.0 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 SYNOPSIS |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# in dist.ini |
85
|
|
|
|
|
|
|
[CoalescePod] |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 DESCRIPTION |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
If the files I<Foo.pm> and I<Foo.pod> both exist, the pod file is removed and |
90
|
|
|
|
|
|
|
its content appended to the end of the C<.pm> file (or just before a |
91
|
|
|
|
|
|
|
C<__DATA__> marker if present) |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 AUTHOR |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Yanick Champoux <yanick@cpan.org> |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This software is copyright (c) 2021, 2014, 2013, 2012 by Yanick Champoux. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
102
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |