Xml/XmlFile.pm

filter: Statementstmt 73.8% 31 / 42 Branchbran 20.0% 2 / 10 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 60.8% 42 / 69 CC 8 SCAR 26.2
CC
8
Cov
60%
_init
23.4
BEGIN
1.0
BEGIN
1.0
CRAP 13.8
« Maven.pm ↑ Summary Xml/Pom.pm »
1 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Maven::Xml::XmlFile;
5 7 $Maven::Xml::XmlFile::VERSION = '1.12';
6 # ABSTRACT: A base class for Maven XML file
7 # PODNAME: Maven::Xml::XmlFile
8  
9 7 ▶use parent qw(Maven::Xml::XmlNodeParser);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 7 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 7 ▶use Log::Any;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 7 ▶use XML::LibXML::Reader;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 7 my $logger = Log::Any->get_logger();
16  
17 sub _init {
18 30 ▶ my ( $self, %options ) = @_;
Subroutine _init: called CC=8 SCAR=31.5
19  
20 30 my $xml_string = $options{string};
21 30 ▶ if ( !$xml_string && $options{file} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $xml_string and $options{"file"}) 30 0 30
Condition33%1/3
not $xml_string and $options{"file"}
!ll&&!rl&&r
0030
MC/DC0%0/2
not $xml_string and $options{"file"}
not $xml_string $options{"file"}
Truth table33%1/3
not(A) and B
A= not $xml_stringB= $options{"file"}
ABresult
0X0
100
111
22 30 $logger->debugf( 'loading xml from file %s', $options{file} );
23  
24 # http://www.perl.com/pub/2003/11/21/slurp.html
25 30 $xml_string = do { local ( @ARGV, $/ ) = $options{file}; <> };
26 }
27 30 ▶ if ( !$xml_string && $options{url} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $xml_string and $options{"url"}) 0 30 30
Condition33%1/3
not $xml_string and $options{"url"}
!ll&&!rl&&r
3000
MC/DC0%0/2
not $xml_string and $options{"url"}
not $xml_string $options{"url"}
Truth table33%1/3
not(A) and B
A= not $xml_stringB= $options{"url"}
ABresult
0X0
100
111
28 0 $logger->debugf( 'loading xml from uri %s', $options{url} );
29 0 my $agent = $options{agent};
30 0 ▶ if ( !$agent ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($agent) 0 0 0
31 0 require LWP::UserAgent;
32 0 $agent = LWP::UserAgent->new();
33 }
34  
35 0 my $response = $agent->get( $options{url} );
36 0 ▶ if ( !$response->is_success() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($response->is_success) 0 0 0
37 0 ▶ if ( $options{die_on_failure} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{'die_on_failure'}) { } 0 0 0
38 0 die($response);
39 }
40 else {
41 0 return;
42 }
43 }
44  
45 0 $xml_string = $response->content();
46 }
47  
48 30 $self->_parse_node( XML::LibXML::Reader->new( string => $xml_string ) );
49  
50 30 return $self;
51 }
52  
53 7 1;
54  
55 __END__
« Maven.pm ↑ Summary Xml/Pom.pm »