Rabbit/Role/Document.pm

filter: Statementstmt 100% 35 / 35 Branchbran 87.5% 7 / 8 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 92.0% 58 / 63 CC 7 SCAR 13.5
CC
7
Cov
94%
_build__document
7.1
BEGIN
1.0
BEGIN
1.0
CRAP 3.9
« Rabbit/Trait/XPath.pm ↑ Summary Rabbit/Trait/XPathValueMap.pm »
1 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package XML::Rabbit::Role::Document;
5 14 $XML::Rabbit::Role::Document::VERSION = '0.4.1';
6 14 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 14 ▶use XML::LibXML 1.69 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 14 ▶use Encode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # ABSTRACT: XML Document base class
12  
13  
14 14 has '_file' => (
15 is => 'ro',
16 isa => 'Str',
17 init_arg => 'file',
18 predicate => '_has_file',
19 );
20  
21  
22 14 has '_fh' => (
23 is => 'ro',
24 isa => 'GlobRef',
25 init_arg => 'fh',
26 predicate => '_has_fh',
27 );
28  
29  
30 14 has '_xml' => (
31 is => 'ro',
32 isa => 'Str',
33 init_arg => 'xml',
34 predicate => '_has_xml',
35 );
36  
37  
38 14 has '_document' => (
39 is => 'ro',
40 isa => 'XML::LibXML::Document',
41 lazy_build => 1,
42 init_arg => 'dom',
43 );
44  
45 13 ▶sub _build__document {
Subroutine _build__document: called CC=7 SCAR=19.7
46 13 my ( $self ) = @_;
47 13 my $doc;
48 # Priority source order is: file, fh, xml (string) if multiple defined
49 13 ▶ $doc = $self->_parser->parse_file( $self->_file ) if $self->_has_file;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_has_file 11 2 13
50 13 ▶ $doc = $self->_parser->parse_fh( $self->_fh ) if $self->_has_fh and not defined($doc);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_has_fh and not defined $doc 1 12 13
Condition66%2/3
$self->_has_fh and not defined $doc
!ll&&!rl&&r
1201
MC/DC50%1/2
$self->_has_fh and not defined $doc
$self->_has_fh not defined $doc
Truth table66%2/3
A and not(B)
A= $self->_has_fhB= not defined $doc
ABresult
0X0
100
111
51 13 ▶ $doc = $self->_parser->parse_string( $self->_xml ) if $self->_has_xml and not defined($doc);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_has_xml and not defined $doc 1 12 13
Condition66%2/3
$self->_has_xml and not defined $doc
!ll&&!rl&&r
1201
MC/DC50%1/2
$self->_has_xml and not defined $doc
$self->_has_xml not defined $doc
Truth table66%2/3
A and not(B)
A= $self->_has_xmlB= not defined $doc
ABresult
0X0
100
111
52 13 ▶ confess("No input specified. Please specify argument file, fh, xml or dom.\n") unless $doc;
Branch: 1 branch
BranchTrueFalseTotal
unless $doc 0 13 13
53 13 return $doc;
54 }
55  
56 has '_parser' => (
57 is => 'ro',
58 isa => 'XML::LibXML',
59 lazy => 1,
60 13 ▶ default => sub { XML::LibXML->new( huge => 1 ), },
Subroutine __ANON__: called CC=1 SCAR=0.0
61 14 );
62  
63  
64 1 ▶sub dump_document_xml {
Subroutine dump_document_xml: called CC=1 SCAR=0.0
Pod documented
65 1 my ( $self ) = @_;
66 1 return Encode::decode(
67 $self->_document->actualEncoding,
68 $self->_document->toString(1),
69 );
70 }
71  
72 14 ▶no Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
73  
74 14 1;
75  
76 __END__
« Rabbit/Trait/XPath.pm ↑ Summary Rabbit/Trait/XPathValueMap.pm »