blib/lib/Pod/Elemental/Transformer/Author/GETTY.pm

filter: Statementstmt 96.1% 25 / 26 Branchbran 87.5% 7 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 3 / 3 Podpod 0.0% 0 / 1 totaltotal 83.7% 36 / 43 CC 7 SCAR 17.7
CC
7
Cov
89%
transform_node
7.3
BEGIN
1.0
BEGIN
1.0
CRAP 5.9
« blib/lib/Dist/Zilla/Plugin/Author/GETTY/InstallCheck.pm ↑ Summary blib/lib/Pod/Weaver/Section/Author/GETTY/Support.pm »
1 package Pod::Elemental::Transformer::Author::GETTY;
2 # ABSTRACT: Transform custom POD commands to =head1 and =head2
3 4 our $VERSION = '0.328';
4 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 with 'Pod::Elemental::Transformer';
6  
7 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 # Commands that transform to =head1 with specific content
11 4 my %HEAD1_COMMANDS = (
12 synopsis => 'SYNOPSIS',
13 description => 'DESCRIPTION',
14 seealso => 'SEE ALSO',
15 );
16  
17 # Commands that transform to =head2 (keeping content as-is)
18 4 my @HEAD2_COMMANDS = qw(
19 attr
20 method
21 func
22 opt
23 env
24 hook
25 example
26 resource
27 event
28 );
29  
30 4 my %IS_HEAD2_COMMAND = map { $_ => 1 } @HEAD2_COMMANDS;
31  
32 73 ▶sub transform_node {
Subroutine transform_node: called CC=7 SCAR=19.8
Pod undocumented
33 73 my ($self, $node) = @_;
34  
35 73 for my $child (@{ $node->children }) {
36 40 ▶ if ($child->isa('Pod::Elemental::Element::Pod5::Command')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($child->isa("Pod::Elemental::Element::Pod5::Command")) 20 20 40
37 20 my $cmd = $child->command;
38  
39 # Transform head1 commands (replace content with fixed heading)
40 20 ▶ if (my $heading = $HEAD1_COMMANDS{$cmd}) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $heading = $HEAD1_COMMANDS{$cmd}) { } 1 19 20
elsif ($IS_HEAD2_COMMAND{$cmd}) { } 9 10 19
41 1 $child->{command} = 'head1';
42 1 $child->{content} = $heading;
43 }
44 # Transform head2 commands (keep content)
45 elsif ($IS_HEAD2_COMMAND{$cmd}) {
46 9 $child->{command} = 'head2';
47 }
48 }
49  
50 # Recurse into nested structures
51 40 ▶ if ($child->can('children') && $child->children) {
Branch: 1 branch
BranchTrueFalseTotal
if ($child->can("children") and $child->children) 0 40 40
Condition33%1/3
$child->can("children") and $child->children
!ll&&!rl&&r
4000
MC/DC0%0/2
$child->can("children") and $child->children
$child->can("children") $child->children
Truth table33%1/3
A and B
A= $child->can("children")B= $child->children
ABresult
0X0
100
111
52 0 $self->transform_node($child);
53 }
54 }
55  
56 73 return $node;
57 }
58  
59 4 __PACKAGE__->meta->make_immutable;
60  
61 4 1;
62  
63 __END__
« blib/lib/Dist/Zilla/Plugin/Author/GETTY/InstallCheck.pm ↑ Summary blib/lib/Pod/Weaver/Section/Author/GETTY/Support.pm »