| 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
Condition33%1/3
not $xml_string and $options{"file"}
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"}
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
not $xml_string and $options{"url"}
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"}
| |||||||||||||||||||||||||||||
| 28 | 0 | $logger->debugf( 'loading xml from uri %s', $options{url} ); | |||||||||||||||||||||||||||
| 29 | 0 | my $agent = $options{agent}; | |||||||||||||||||||||||||||
| 30 | 0 | ▶ | if ( !$agent ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | if ( $options{die_on_failure} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||