Parser/File/OPF.pm

filter: Statementstmt 96.2% 51 / 53 Branchbran 50.0% 3 / 6 Conditioncond 60.0% 9 / 15 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 100% 20 / 20 Podpod 92.3% 12 / 13 totaltotal 81.2% 95 / 117 CC 9 SCAR 5.8
CC
9
Cov
85%
guess_version
4.1
nav_path
2.3
parser
2.0
CRAP 1.8
« Parser/File/Container.pm ↑ Summary Parser/File/Document.pm »
1 package EPUB::Parser::File::OPF;
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 Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 14 ▶use EPUB::Parser::File::Parser::OPF;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 14 ▶use EPUB::Parser::File::OPF::Context;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 14 ▶use EPUB::Parser::File::Container;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 14 ▶use Smart::Args;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 10 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
11 10 args(
12 my $class => 'ClassName',
13 my $zip => { isa => 'EPUB::Parser::Util::Archive' },
14 my $epub_version,
15 );
16  
17 10 my $self = bless {
18 zip => $zip,
19 epub_version => $epub_version,
20 } => $class;
21  
22 10 return $self;
23 }
24  
25 17 ▶sub parser {
Subroutine parser: called CC=2 SCAR=7.1
Pod documented
26 17 my $self = shift;
27  
28 $self->{parser}
29 17 ▶ ||= EPUB::Parser::File::Parser::OPF->new({ data => $self->data });
Condition66%2/3
$self->{"parser"} ||= "EPUB::Parser::File::Parser::OPF"->new({"data", $self->data})
l!l&&r!l&&!r
7100
MC/DC0%0/2
$self->{"parser"} ||= "EPUB::Parser::File::Parser::OPF"->new({"data", $self->data})
$self->{"parser"} "EPUB::Parser::File::Parser::OPF"->new({"data", $self->data})
Truth table66%2/3
A ||= B
A= $self->{"parser"}B= "EPUB::Parser::File::Parser::OPF"->new({"data", $self->data})
ABresult
1X1
011
000
30 }
31  
32 18 ▶sub path {
Subroutine path: called CC=2 SCAR=7.0
Pod documented
33 18 my $self = shift;
34  
35 18 ▶ $self->{path} ||= do {
Condition66%2/3
$self->{"path"} ||= do { my $container = "EPUB::Parser::File::Container"->new({"zip", $self->{"zip"}}); $container->opf_path }
l!l&&r!l&&!r
8100
MC/DC0%0/2
$self->{"path"} ||= do { my $container = "EPUB::Parser::File::Container"->new({"zip", $self->{"zip"}}); $container->opf_path }
$self->{"path"} do { my $container = "EPUB::Parser::File::Container"->new({"zip", $self->{"zip"}}); $container->opf_path }
Truth table66%2/3
A ||= B
A= $self->{"path"}B= do { my $container = "EPUB::Parser::File::Container"->new({"zip", $self->{"zip"}}); $container->opf_path }
ABresult
1X1
011
000
36 10 my $container = EPUB::Parser::File::Container->new({ zip => $self->{zip} });
37 10 $container->opf_path;
38 };
39 }
40  
41 17 ▶sub dir {
Subroutine dir: called CC=2 SCAR=7.0
Pod documented
42 17 my $self = shift;
43 17 require File::Basename;
44 17 ▶ $self->{dir} ||= File::Basename::dirname($self->path);
Condition66%2/3
$self->{"dir"} ||= File::Basename::dirname($self->path)
l!l&&r!l&&!r
1070
MC/DC0%0/2
$self->{"dir"} ||= File::Basename::dirname($self->path)
$self->{"dir"} File::Basename::dirname($self->path)
Truth table66%2/3
A ||= B
A= $self->{"dir"}B= File::Basename::dirname($self->path)
ABresult
1X1
011
000
45 }
46  
47  
48 11 ▶sub data {
Subroutine data: called CC=2 SCAR=7.1
Pod documented
49 11 my $self = shift;
50 11 ▶ $self->{data} ||= $self->{zip}->get_member_data({ file_path => $self->path });
Condition66%2/3
$self->{"data"} ||= $self->{"zip"}->get_member_data({"file_path", $self->path})
l!l&&r!l&&!r
1100
MC/DC0%0/2
$self->{"data"} ||= $self->{"zip"}->get_member_data({"file_path", $self->path})
$self->{"data"} $self->{"zip"}->get_member_data({"file_path", $self->path})
Truth table66%2/3
A ||= B
A= $self->{"data"}B= $self->{"zip"}->get_member_data({"file_path", $self->path})
ABresult
1X1
011
000
51 }
52  
53 46 ▶sub context {
Subroutine context: called CC=2 SCAR=6.9
Pod undocumented
54 46 my $self = shift;
55 46 my $context_name = shift;
56 46 ▶ return $self->{$context_name} if $self->{$context_name};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$context_name} 32 14 46
57  
58 14 $self->{$context_name} = EPUB::Parser::File::OPF::Context->new({
59 opf => $self,
60 parser => $self->parser,
61 context_name => $context_name,
62 });
63 }
64  
65 6 ▶sub spine { shift->context('spine' ) }
Subroutine spine: called CC=1 SCAR=0.0
Pod documented
66 26 ▶sub manifest { shift->context('manifest') }
Subroutine manifest: called CC=1 SCAR=0.0
Pod documented
67 12 ▶sub metadata { shift->context('metadata') }
Subroutine metadata: called CC=1 SCAR=0.0
Pod documented
68 1 ▶sub guide { shift->context('guide' ) }
Subroutine guide: called CC=1 SCAR=0.0
Pod documented
69  
70 4 ▶sub nav_path {
Subroutine nav_path: called CC=2 SCAR=8.1
Pod documented
71 4 my $self = shift;
72 4 ▶ $self->{nav_path} ||= sprintf("%s/%s", $self->dir, $self->manifest->nav_path);
Condition33%1/3
$self->{"nav_path"} ||= sprintf("%s/%s", $self->dir, $self->manifest->nav_path)
l!l&&r!l&&!r
040
MC/DC0%0/2
$self->{"nav_path"} ||= sprintf("%s/%s", $self->dir, $self->manifest->nav_path)
$self->{"nav_path"} sprintf("%s/%s", $self->dir, $self->manifest->nav_path)
Truth table33%1/3
A ||= B
A= $self->{"nav_path"}B= sprintf("%s/%s", $self->dir, $self->manifest->nav_path)
ABresult
1X1
011
000
73 }
74  
75 2 ▶sub cover_image_path {
Subroutine cover_image_path: called CC=1 SCAR=0.0
Pod documented
76 2 shift->manifest->cover_image_path(@_);
77 }
78  
79 1 ▶sub guess_version {
Subroutine guess_version: called CC=3 SCAR=14.2
Pod documented
80 1 my $self = shift;
81 1 my $version = $self->parser->single('/pkg:package/@version')->string_value;
82
83 1 ▶ if ($version) {
Branch: 2 branches
BranchTrueFalseTotal
if ($version) { } 1 0 1
elsif ($self->nav_path) { } 0 0 0
84 1 return $version;
85 }
86 elsif ( $self->nav_path ) {
87 0 return '3.0';
88 }
89 else {
90 0 return;
91 }
92 }
93  
94  
95 14 1;
96  
97  
98 __END__
« Parser/File/Container.pm ↑ Summary Parser/File/Document.pm »