Knit/Plugin/Sort.pm

filter: Statementstmt 100% 36 / 36 Branchbran 50.0% 1 / 2 Conditioncond 66.6% 4 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 10 / 10 Podpod n/a totaltotal 89.6% 52 / 58 CC 5 SCAR 7.0
CC
5
Cov
93%
munge
4.1
__ANON__
2.0
BEGIN
1.0
CRAP 2.0
« Knit.pm ↑ Summary use.pl »
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
l!l&&r!l&&!r
101
MC/DC50%1/2
$index{'*'} || $i
$index{'*'} $i
Truth table66%2/3
A || B
A= $index{'*'}B= $i
ABresult
1X1
011
000
34  
35 my @order =
36 6 ▶ map { $_ ? @$_ : () }
Branch: 1 branch
BranchTrueFalseTotal
$_ ? : 6 0 6
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
l!l&&r!l&&!r
440
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
ABresult
1X1
011
000
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__
« Knit.pm ↑ Summary use.pl »