Parser/File/Document.pm

filter: Statementstmt 100% 37 / 37 Branchbran n/a Conditioncond 63.6% 7 / 11 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 7 totaltotal 75.3% 55 / 73 CC 6 SCAR 5.7
CC
6
Cov
92%
item_abs_paths
3.0
parser
2.0
path
2.0
CRAP 1.8
« Parser/File/OPF.pm ↑ Summary Parser/File/OPF/Context/Spine.pm »
1 package EPUB::Parser::File::Document;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use EPUB::Parser::File::Parser::Document;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Smart::Args;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 9 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
8 9 args(
9 my $class => 'ClassName',
10 my $archive_doc => { isa => 'EPUB::Parser::Util::Archive::Iterator' },
11 );
12  
13 9 my $self = bless {
14 archive_doc => $archive_doc,
15 } => $class;
16  
17 9 $self->path($archive_doc->path);
18  
19 9 return $self;
20 }
21  
22 18 ▶sub parser {
Subroutine parser: called CC=2 SCAR=7.1
Pod undocumented
23 18 my $self = shift;
24  
25 $self->{parser}
26 18 ▶ ||= EPUB::Parser::File::Parser::Document->new({ data => $self->data });
Condition66%2/3
$self->{"parser"} ||= "EPUB::Parser::File::Parser::Document"->new({"data", $self->data})
l!l&&r!l&&!r
990
MC/DC0%0/2
$self->{"parser"} ||= "EPUB::Parser::File::Parser::Document"->new({"data", $self->data})
$self->{"parser"} "EPUB::Parser::File::Parser::Document"->new({"data", $self->data})
Truth table66%2/3
A ||= B
A= $self->{"parser"}B= "EPUB::Parser::File::Parser::Document"->new({"data", $self->data})
ABresult
1X1
011
000
27 }
28  
29 9 ▶sub data {
Subroutine data: called CC=1 SCAR=0.0
Pod undocumented
30 9 my $self = shift;
31 9 $self->{archive_doc}->data;
32 }
33  
34 27 ▶sub path {
Subroutine path: called CC=2 SCAR=7.1
Pod undocumented
35 27 my $self = shift;
36 27 ▶ $self->{path} ||= $self->{archive_doc}->path;
Condition66%2/3
$self->{"path"} ||= $self->{"archive_doc"}->path
l!l&&r!l&&!r
1890
MC/DC0%0/2
$self->{"path"} ||= $self->{"archive_doc"}->path
$self->{"path"} $self->{"archive_doc"}->path
Truth table66%2/3
A ||= B
A= $self->{"path"}B= $self->{"archive_doc"}->path
ABresult
1X1
011
000
37 }
38  
39  
40 25 ▶sub dir {
Subroutine dir: called CC=2 SCAR=7.0
Pod undocumented
41 25 my $self = shift;
42 25 require File::Basename;
43 25 ▶ $self->{dir} ||= File::Basename::dirname($self->path);
Condition66%2/3
$self->{"dir"} ||= File::Basename::dirname($self->path)
l!l&&r!l&&!r
1690
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
44 }
45  
46 9 ▶sub items_node {
Subroutine items_node: called CC=1 SCAR=0.0
Pod undocumented
47 9 my $self = shift;
48 9 ( $self->parser->find('//*/@href'), $self->parser->find('//*/@src') );
49 }
50  
51 9 ▶sub item_abs_paths {
Subroutine item_abs_paths: called CC=3 SCAR=11.0
Pod undocumented
52 9 my $self = shift;
53 9 my $ret;
54 9 require URI;
55  
56 9 for my $node ($self->items_node) {
57 25 my $doc_item_path = $node->string_value;
58  
59 25 my $uri = URI->new($doc_item_path)->abs($self->dir . '/');
60 25 (my $abs_path = $uri->as_string ) =~ s{^/}{};
61 #(my $no_fragment = $uri->path ) =~ s{^/}{};
62 25 $ret->{$doc_item_path} = $abs_path;
63 }
64  
65 9 ▶ return $ret || {};
Condition50%1/2
$ret || {}
l!l
90
MC/DC0%0/1
$ret || {}
$ret
Truth table50%1/2
A
A= $ret
Aresult
11
00
66 }
67  
68  
69  
70 1 1;
« Parser/File/OPF.pm ↑ Summary Parser/File/OPF/Context/Spine.pm »