| 1 | package Pod::Knit::Plugin::Sort; | ||||||||||||||||||||
| 2 | 3 | our $AUTHORITY = 'cpan:YANICK'; | |||||||||||||||||||
| 3 | # ABSTRACT: Reorder sections | ||||||||||||||||||||
| 4 | 3 | $Pod::Knit::Plugin::Sort::VERSION = '0.0.1'; | |||||||||||||||||||
| 5 | 3 | ▶ | use 5.10.0; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 3 | ▶ | use List::AllUtils qw/ part /; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 3 | ▶ | use Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 3 | extends 'Pod::Knit::Plugin'; | |||||||||||||||||||
| 14 | 3 | with 'Pod::Knit::DOM::WebQuery'; | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 3 | ▶ | use experimental 'signatures', 'postderef'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | has "order" => ( | ||||||||||||||||||||
| 19 | isa => 'ArrayRef', | ||||||||||||||||||||
| 20 | is => 'ro', | ||||||||||||||||||||
| 21 | lazy => 1, | ||||||||||||||||||||
| 22 | 1 | ▶ | default => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 23 | 1 | [] | |||||||||||||||||||
| 24 | }, | ||||||||||||||||||||
| 25 | 3 | ); | |||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 2 | ▶ | sub munge( $self, $doc ) { | ||||||||||||||||||
|
Subroutine
munge: called CC=4 SCAR=14.0
| |||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 2 | ▶ | my $sections = $doc->dom->find( 'head1' )->map(sub{ $_->parent }); | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 2 | my $i = 0; | |||||||||||||||||||
| 32 | 2 | my %index = map { $_ => $i++ } $self->order->@*; | |||||||||||||||||||
| 33 | 2 | ▶ | my $rest = $index{'*'} || $i; | ||||||||||||||||||
|
Condition66%2/3
$index{'*'} || $i
MC/DC50%1/2
$index{'*'} || $i
$index{'*'}
$i
Truth table66%2/3
A || B
A= $index{'*'}B= $i
| |||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | my @order = | ||||||||||||||||||||
| 36 | 6 | ▶ | map { $_ ? @$_ : () } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 37 | 2 | ▶ | part { $index{ $_->find('head1')->text } // $rest } @$sections; | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
Condition66%2/3
$index{$_->find("head1")->text} // $rest
MC/DC0%0/2
$index{$_->find("head1")->text} // $rest
$index{$_->find("head1")->text}
$rest
Truth table66%2/3
A // B
A= $index{$_->find("head1")->text}B= $rest
| |||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 2 | for( @order ) { | |||||||||||||||||||
| 40 | 8 | $_->detach; | |||||||||||||||||||
| 41 | 8 | $doc->dom->append($_); | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 3 | 1; | |||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | __END__ | ||||||||||||||||||||