blib/lib/EPUB/Parser/File/OPF/Context/Spine.pm

filter: Statementstmt 100% 34 / 34 Branchbran 50.0% 1 / 2 Conditioncond 75.0% 3 / 4 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 4 / 4 totaltotal 94.5% 52 / 55 SCAR 16.1
CC
5
Cov
95%
attrs
3.0
ordered_list
2.0
items_path
2.0
CRAP 5.0
« blib/lib/EPUB/Parser/File/Navi/Context/Toc.pm ↑ Summary blib/lib/EPUB/Parser/File/Parser/OPF.pm »
1 package EPUB::Parser::File::OPF::Context::Spine;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use parent 'EPUB::Parser::File::OPF::Context';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use EPUB::Parser::Util::AttributePacker;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub ordered_list {
9 6 ▶ my $self = shift;
Subroutine ordered_list: called CC=2 SCAR=7.1
Pod documented
10 6 my $node_list = $self->parser->find('pkg:itemref');
11 6 ▶ EPUB::Parser::Util::AttributePacker->ordered_list($node_list) || [];
Branch: 1 branch
BranchTrueFalseTotal
"EPUB::Parser::Util::AttributePacker"->ordered_list($node_list) or [] 0 6 6
12 }
13  
14 sub attrs {
15 5 ▶ my $self = shift;
Subroutine attrs: called CC=3 SCAR=11.0
Pod documented
16  
17 5 my $items;
18 5 my $attr_by_id = $self->opf->manifest->attr_by_id;
19  
20 5 for my $idref ( @{$self->ordered_list} ) {
21 45 push @$items, $attr_by_id->{$idref->{idref}};
22 }
23  
24 5 ▶ return $items || [];
Condition50%1/2
$items || []
l!l
50
MC/DC0%0/1
$items || []
$items
Truth table50%1/2
A
A= $items
Aresult
11
00
25 }
26  
27 sub items_path {
28 4 ▶ my $self = shift;
Subroutine items_path: called CC=2 SCAR=6.9
Pod documented
29 4 ▶ my $args = shift || {};
Condition100%2/2
shift() || {}
l!l
31
MC/DC100%1/1
shift() || {}
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
30 4 my @href = map { $_->{href} } @{$self->attrs};
31  
32 4 $self->opf->manifest->_items_path({ %$args, href => \@href });
33 }
34  
35 sub items {
36 2 ▶ my $self = shift;
Subroutine items: called CC=1 SCAR=0.0
Pod documented
37 2 $self->opf->manifest->_items( $self->items_path({ abs => 1 }) );
38 }
39  
40  
41  
42 3 1;
43  
44 __END__
45  
46 =encoding utf-8
47  
48 =head1 NAME
49  
50 EPUB::Parser::File::OPF::Context::Spine - parses spine node in opf file
51  
52 =head1 METHODS
53  
54 =head2 ordered_list
55  
56 Attribute of each child nodes of spine is added to hash.
57 For exsample,
58  
59 [
60 { idref => "_cover.xhtml", linear => "no"},
61 { idref => '_nav.xhtml' },
62 { idref => "_document_0_0.xhtml" },
63 ....
64 ]
65  
66 =head2 attrs
67  
68 Get Manifest infomation corresponding to Spine.
69 For example,
70  
71 [{
72 'href' => 'cover.xhtml',
73 'media-type' => 'application/xhtml+xml'
74 },{
75 'href' => 'nav.xhtml',
76 'media-type' => 'application/xhtml+xml',
77 'properties' => 'nav'
78 },{
79 ...
80 }]
81  
82  
83 =head2 items_path
84  
85 Return path of item which spine has is obtained.
86  
87 =head2 items
88  
89 Return item which spine has is obtained.
90 The item is instance of L<EPUB::Parser::Util::Archive::Iterator>.
91  
92 =head1 LICENSE
93  
94 Copyright (C) tokubass.
95  
96 This library is free software; you can redistribute it and/or modify
97 it under the same terms as Perl itself.
98  
99 =head1 AUTHOR
100  
101 tokubass E<lt>tokubass {at} cpan.orgE<gt>
102  
103 =cut
104  
« blib/lib/EPUB/Parser/File/Navi/Context/Toc.pm ↑ Summary blib/lib/EPUB/Parser/File/Parser/OPF.pm »