Parser/Manager/Pages.pm

filter: Statementstmt 100% 31 / 31 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 90.4% 38 / 42 CC 6 SCAR 13.9
CC
6
Cov
94%
get_page_from_each_chapter
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
« Parser/Util/AttributePacker.pm ↑ Summary Parser/File/Parser.pm »
1 package EPUB::Parser::Manager::Pages;
2 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 14 ▶use Smart::Args;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
7 1 args(
8 my $class => 'ClassName',
9 my $opf,
10 my $navi,
11 );
12  
13 1 my $self = bless {
14 opf => $opf,
15 navi => $navi,
16 } => $class;
17  
18 1 return $self;
19 }
20  
21 1 ▶sub get_page_from_each_chapter {
Subroutine get_page_from_each_chapter: called CC=6 SCAR=18.0
Pod undocumented
22 1 args(
23 my $self,
24 );
25  
26 1 my $tree = {
27 chapter_group => [],
28 no_chapter_member => [],
29 };
30  
31 1 my $chapter_paths = $self->{navi}->chapter_list({ abs => 1 });
32 1 my $spine_paths = $self->{opf}->spine->items_path({ abs => 1 });
33 1 my %spine_paths;
34 1 @spine_paths{@$spine_paths} = (0 .. @$spine_paths-1);
35  
36  
37 1 my @chapter_index_on_spine;
38 1 for my $chapter_path (@$chapter_paths) {
39 7 ▶ next if !defined $spine_paths{$chapter_path};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $spine_paths{$chapter_path} 0 7 7
40 7 push @chapter_index_on_spine, $spine_paths{$chapter_path};
41 }
42  
43 1 ▶ if ( $chapter_index_on_spine[0] > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chapter_index_on_spine[0] > 0) 1 0 1
44 1 for my $i ( 0 .. $chapter_index_on_spine[0] -1 ) {
45 2 push @{$tree->{no_chapter_member}}, $spine_paths->[$i];
46 }
47 }
48  
49 1 for my $i ( reverse @chapter_index_on_spine ) {
50 7 unshift @{$tree->{chapter_group}}, [splice(@$spine_paths,$i)];
51 }
52  
53 1 return $tree;
54 }
55  
56  
57 14 1;
58  
« Parser/Util/AttributePacker.pm ↑ Summary Parser/File/Parser.pm »