Weaver/Plugin/EnsurePod5.pm

filter: Statementstmt 92.3% 36 / 39 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 1 totaltotal 87.5% 49 / 56 CC 5 SCAR 11.4
CC
5
Cov
87%
_strip_nonpod
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.1
« Weaver/Section/Authors.pm ↑ Summary Weaver/Section/Collect.pm »
1 package Pod::Weaver::Plugin::EnsurePod5 4.022;
2 # ABSTRACT: ensure that the Pod5 translator has been run on this document
3  
4 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 with 'Pod::Weaver::Role::Preparer';
6  
7 # BEGIN BOILERPLATE
8 9 ▶use v5.22.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 9 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 9 ▶no feature 'switch';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 9 ▶use experimental qw(postderef postderef_qq); # This experiment gets mainlined.
Subroutine BEGIN: called CC=1 SCAR=0.0
13 # END BOILERPLATE
14  
15 9 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 9 ▶use Pod::Elemental::Transformer::Pod5;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 #pod =head1 OVERVIEW
20 #pod
21 #pod This plugin is very, very simple: it runs the Pod5 transformer on the input
22 #pod document and removes any leftover whitespace-only Nonpod elements. If
23 #pod non-whitespace-only Nonpod elements are found, an exception is raised.
24 #pod
25 #pod =cut
26  
27 53 ▶sub _strip_nonpod {
Subroutine _strip_nonpod: called CC=5 SCAR=19.4
28 53 my ($self, $node) = @_;
29  
30 # XXX: This is really stupid. -- rjbs, 2009-10-24
31  
32 53 foreach my $i (reverse 0 .. $node->children->$#*) {
33 337 my $para = $node->children->[$i];
34  
35 337 ▶ if ($para->isa('Pod::Elemental::Element::Pod5::Nonpod')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($para->isa('Pod::Elemental::Element::Pod5::Nonpod')) { } 0 337 337
elsif ($para->does('Pod::Elemental::Node')) { } 24 313 337
36 0 ▶ if ($para->content !~ /\S/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $para->content =~ /\S/u) { } 0 0 0
37 0 splice $node->children->@*, $i, 1
38 } else {
39 0 confess "can't cope with a Nonpod element with non-whitespace content";
40 }
41 } elsif ($para->does('Pod::Elemental::Node')) {
42 24 $self->_strip_nonpod($para);
43 }
44 }
45 }
46  
47 29 ▶sub prepare_input {
Subroutine prepare_input: called CC=1 SCAR=0.0
Pod undocumented
48 29 my ($self, $input) = @_;
49 29 my $pod_document = $input->{pod_document};
50  
51 29 Pod::Elemental::Transformer::Pod5->new->transform_node($pod_document);
52  
53 29 $self->_strip_nonpod($pod_document);
54  
55 29 return;
56 }
57  
58 9 __PACKAGE__->meta->make_immutable;
59 9 1;
60  
61 __END__
« Weaver/Section/Authors.pm ↑ Summary Weaver/Section/Collect.pm »