| 1 | package Dist::Zilla::Plugin::PodPurler; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | { | ||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | $Dist::Zilla::Plugin::PodPurler::VERSION = '0.093401'; | |||||||||||||||||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: like PodWeaver, but more erratic and amateurish | ||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Moose::Autobox 0.08; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use List::MoreUtils qw(any); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | with 'Dist::Zilla::Role::FileMunger'; | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Pod::Elemental 0.092930; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use Pod::Elemental::Selectors -all; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use Pod::Elemental::Transformer::Pod5; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use Pod::Elemental::Transformer::Nester; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use Pod::Elemental::Transformer::Gatherer; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | sub munge_file { | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | my ($self, $file) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
munge_file: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | return $self->munge_pod($file) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$file->name =~ /\.(?:pm|pod)$/i and !($file->name =~ m[/]) || $file->name =~ m[^lib/]
not $file->name =~ m[/] or $file->name =~ m[^lib/]
MC/DC0%0/3
$file->name =~ /\.(?:pm|pod)$/i and !($file->name =~ m[/]) || $file->name =~ m[^lib/]
$file->name =~ /\.(?:pm|pod)$/i
not $file->name =~ m[/]
$file->name =~ m[^lib/]
Truth table0%0/4
A and not(B) or C
A= $file->name =~ /\.(?:pm|pod)$/iB= not $file->name =~ m[/]C= $file->name =~ m[^lib/]
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | if $file->name =~ /\.(?:pm|pod)$/i | ||||||||||||||||||||||||||||||||||||||||||
| 25 | and ($file->name !~ m{/} or $file->name =~ m{^lib/}); | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | sub munge_perl_string { | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | my ($self, $doc, $arg) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
munge_perl_string: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my $document = $doc->{pod}; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | Pod::Elemental::Transformer::Pod5->new->transform_node($document); | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my $nester = Pod::Elemental::Transformer::Nester->new({ | |||||||||||||||||||||||||||||||||||||||||
| 37 | top_selector => s_command([ qw(head1 method attr) ]), | ||||||||||||||||||||||||||||||||||||||||||
| 38 | content_selectors => [ | ||||||||||||||||||||||||||||||||||||||||||
| 39 | s_flat, | ||||||||||||||||||||||||||||||||||||||||||
| 40 | s_command( [ qw(head2 head3 head4 over item back) ]), | ||||||||||||||||||||||||||||||||||||||||||
| 41 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 42 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $nester->transform_node($document); | |||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | for my $pair ( | |||||||||||||||||||||||||||||||||||||||||
| 47 | [ method => 'METHODS' ], | ||||||||||||||||||||||||||||||||||||||||||
| 48 | [ attr => 'ATTRIBUTES' ], | ||||||||||||||||||||||||||||||||||||||||||
| 49 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my $sel = s_command($pair->[0]); | |||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ($document->children->grep($sel)->length) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my $gatherer = Pod::Elemental::Transformer::Gatherer->new({ | |||||||||||||||||||||||||||||||||||||||||
| 53 | gather_selector => $sel, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | container => Pod::Elemental::Element::Nested->new({ | ||||||||||||||||||||||||||||||||||||||||||
| 55 | command => 'head1', | ||||||||||||||||||||||||||||||||||||||||||
| 56 | content => "$pair->[1]\n", | ||||||||||||||||||||||||||||||||||||||||||
| 57 | }), | ||||||||||||||||||||||||||||||||||||||||||
| 58 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $gatherer->transform_node($document); | |||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | $gatherer->container->children->grep($sel)->each_value(sub { | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | $_->command('head2'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | unless ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | $document->children->grep(sub { | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | s_command('head1', $_) and $_->content eq "VERSION\n" | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | })->length | ||||||||||||||||||||||||||||||||||||||||||
| 72 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my $version_section = Pod::Elemental::Element::Nested->new({ | |||||||||||||||||||||||||||||||||||||||||
| 74 | command => 'head1', | ||||||||||||||||||||||||||||||||||||||||||
| 75 | content => "VERSION\n", | ||||||||||||||||||||||||||||||||||||||||||
| 76 | children => [ | ||||||||||||||||||||||||||||||||||||||||||
| 77 | Pod::Elemental::Element::Pod5::Ordinary->new({ | ||||||||||||||||||||||||||||||||||||||||||
| 78 | content => sprintf "version %s\n", $self->zilla->version, | ||||||||||||||||||||||||||||||||||||||||||
| 79 | }), | ||||||||||||||||||||||||||||||||||||||||||
| 80 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 81 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $document->children->unshift($version_section); | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | unless ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | $document->children->grep(sub { | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | s_command('head1', $_) and $_->content eq "NAME\n" | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | })->length | ||||||||||||||||||||||||||||||||||||||||||
| 90 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 91 | Carp::croak "couldn't find package declaration in " . $arg->{filename} | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | unless my $pkg_node = $doc->{ppi}->find_first('PPI::Statement::Package'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my $package = $pkg_node->namespace; | |||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | $self->log("couldn't find abstract in " . $arg->{filename}) | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | unless my ($abstract) = $doc->{ppi} =~ /^\s*#+\s*ABSTRACT:\s*(.+)$/m; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my $name = $package; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | $name .= " - $abstract" if $abstract; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my $name_section = Pod::Elemental::Element::Nested->new({ | |||||||||||||||||||||||||||||||||||||||||
| 103 | command => 'head1', | ||||||||||||||||||||||||||||||||||||||||||
| 104 | content => "NAME\n", | ||||||||||||||||||||||||||||||||||||||||||
| 105 | children => [ | ||||||||||||||||||||||||||||||||||||||||||
| 106 | Pod::Elemental::Element::Pod5::Ordinary->new({ | ||||||||||||||||||||||||||||||||||||||||||
| 107 | content => "$name\n", | ||||||||||||||||||||||||||||||||||||||||||
| 108 | }), | ||||||||||||||||||||||||||||||||||||||||||
| 109 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 110 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $document->children->unshift($name_section); | |||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | unless ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | $document->children->grep(sub { | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | s_command('head1', $_) and $_->content =~ /\AAUTHORS?\n\z/ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | })->length | ||||||||||||||||||||||||||||||||||||||||||
| 119 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my @authors = $self->zilla->authors->flatten; | |||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | my $name = @authors > 1 ? 'AUTHORS' : 'AUTHOR'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $author_section = Pod::Elemental::Element::Nested->new({ | |||||||||||||||||||||||||||||||||||||||||
| 124 | command => 'head1', | ||||||||||||||||||||||||||||||||||||||||||
| 125 | content => "$name\n", | ||||||||||||||||||||||||||||||||||||||||||
| 126 | children => [ | ||||||||||||||||||||||||||||||||||||||||||
| 127 | Pod::Elemental::Element::Pod5::Ordinary->new({ | ||||||||||||||||||||||||||||||||||||||||||
| 128 | content => join("\n", @authors) . "\n" | ||||||||||||||||||||||||||||||||||||||||||
| 129 | }), | ||||||||||||||||||||||||||||||||||||||||||
| 130 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 131 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $document->children->push($author_section); | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | unless ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | $document->children->grep(sub { | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | s_command('head1', $_) and $_->content =~ /\A(?:COPYRIGHT|LICENSE)\n\z/ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | })->length | ||||||||||||||||||||||||||||||||||||||||||
| 140 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my $legal_section = Pod::Elemental::Element::Nested->new({ | |||||||||||||||||||||||||||||||||||||||||
| 142 | command => 'head1', | ||||||||||||||||||||||||||||||||||||||||||
| 143 | content => "COPYRIGHT AND LICENSE\n", | ||||||||||||||||||||||||||||||||||||||||||
| 144 | children => [ | ||||||||||||||||||||||||||||||||||||||||||
| 145 | Pod::Elemental::Element::Pod5::Ordinary->new({ | ||||||||||||||||||||||||||||||||||||||||||
| 146 | content => $self->zilla->license->notice | ||||||||||||||||||||||||||||||||||||||||||
| 147 | }), | ||||||||||||||||||||||||||||||||||||||||||
| 148 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 149 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $document->children->push($legal_section); | |||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 155 | pod => $document, | ||||||||||||||||||||||||||||||||||||||||||
| 156 | ppi => $doc->{ppi}, | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | sub munge_pod { | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | my ($self, $file) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
munge_pod: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my $content = $file->content; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my $new_content = $self->munge_perl_string( | |||||||||||||||||||||||||||||||||||||||||
| 165 | $content, | ||||||||||||||||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||||||||||||||||
| 167 | filename => $file->name, | ||||||||||||||||||||||||||||||||||||||||||
| 168 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 169 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $file->content($new_content); | |||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 2 | with 'Pod::Elemental::PerlMunger'; | |||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 2 | ▶ | no Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | __END__ | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | Dist::Zilla::Plugin::PodPurler - like PodWeaver, but more erratic and amateurish | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | version 0.093401 | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | PodPurler ress, which rips apart your kinda-POD and reconstructs it as boring | ||||||||||||||||||||||||||||||||||||||||||
| 195 | old real POD. | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | =head1 WARNING | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | This library has been superceded by L<Pod::Weaver> and | ||||||||||||||||||||||||||||||||||||||||||
| 200 | L<Dist::Zilla::Plugin::PodWeaver>. It is unlikely to be updated again unless | ||||||||||||||||||||||||||||||||||||||||||
| 201 | there are serious security problems (!?) or someone gives me some money. | ||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | Ricardo SIGNES <rjbs@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | This software is copyright (c) 2013 by Ricardo SIGNES. | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 212 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | =cut | ||||||||||||||||||||||||||||||||||||||||||