« blib/lib/Pod/Elemental/Transformer/Author/GETTY.pm
↑ Summary
blib/lib/Dist/Zilla/Plugin/Author/GETTY/Binary.pm »
| 1 | package Pod::Weaver::Section::Author::GETTY::Support; | ||||||||||
| 2 | # ABSTRACT: Support section that is left out when it has nothing to say | ||||||||||
| 3 | 4 | our $VERSION = '0.328'; | |||||||||
| 4 | 4 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 4 | extends 'Pod::Weaver::Section::GenerateSection'; | |||||||||
| 6 | |||||||||||
| 7 | 4 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | |||||||||||
| 10 | 81 | ▶ | around weave_section => sub { | ||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=17.9
| |||||||||||
| 11 | 81 | my ($orig, $self, $document, $input) = @_; | |||||||||
| 12 | |||||||||||
| 13 | # GenerateSection fills its template stash from | ||||||||||
| 14 | # $input->{distmeta}{resources}{repository}{web} and the like, which | ||||||||||
| 15 | # autovivifies empty resources, repository and bugtracker hashes in the | ||||||||||
| 16 | # dist's own distmeta, the one META.json is written from. It gets a copy of | ||||||||||
| 17 | # distmeta with a copy of resources, which it may vivify freely. | ||||||||||
| 18 | 81 | ▶ | if (ref $input->{distmeta} eq 'HASH') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 80 | my %distmeta = %{ $input->{distmeta} }; | |||||||||
| 20 | 80 | ▶ | $distmeta{resources} = { %{ $distmeta{resources} } } if ref $distmeta{resources} eq 'HASH'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 80 | $input = { %$input, distmeta => \%distmeta }; | |||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | 81 | my $before = scalar @{ $document->children }; | |||||||||
| 25 | 81 | $self->$orig($document, $input); | |||||||||
| 26 | 81 | ▶ | return if @{ $document->children } == $before; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | |||||||||||
| 28 | 81 | my $section = $document->children->[-1]; | |||||||||
| 29 | 81 | ▶ | my @text = $section->can('children') ? @{ $section->children } : ($section); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 81 | ▶ | pop @{ $document->children } unless grep { $_->content =~ /\S/ } @text; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 4 | }; | |||||||||
| 32 | |||||||||||
| 33 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||
| 34 | |||||||||||
| 35 | 4 | 1; | |||||||||
| 36 | |||||||||||
| 37 | __END__ | ||||||||||