line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
2127
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
152
|
|
2
|
5
|
|
|
5
|
|
20
|
use warnings; |
|
5
|
|
|
|
|
18
|
|
|
5
|
|
|
|
|
244
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Maven::Xml::XmlFile; |
5
|
|
|
|
|
|
|
$Maven::Xml::XmlFile::VERSION = '1.14'; |
6
|
|
|
|
|
|
|
# ABSTRACT: A base class for Maven XML file |
7
|
|
|
|
|
|
|
# PODNAME: Maven::Xml::XmlFile |
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
25
|
use parent qw(Maven::Xml::XmlNodeParser); |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
49
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Carp; |
12
|
|
|
|
|
|
|
use Log::Any; |
13
|
|
|
|
|
|
|
use XML::LibXML::Reader; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $logger = Log::Any->get_logger(); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _init { |
18
|
|
|
|
|
|
|
my ( $self, %options ) = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $xml_string = $options{string}; |
21
|
|
|
|
|
|
|
if ( !$xml_string && $options{file} ) { |
22
|
|
|
|
|
|
|
$logger->debugf( 'loading xml from file %s', $options{file} ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# http://www.perl.com/pub/2003/11/21/slurp.html |
25
|
|
|
|
|
|
|
$xml_string = do { local ( @ARGV, $/ ) = $options{file}; <> }; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
if ( !$xml_string && $options{url} ) { |
28
|
|
|
|
|
|
|
$logger->debugf( 'loading xml from uri %s', $options{url} ); |
29
|
|
|
|
|
|
|
my $agent = $options{agent}; |
30
|
|
|
|
|
|
|
if ( !$agent ) { |
31
|
|
|
|
|
|
|
require LWP::UserAgent; |
32
|
|
|
|
|
|
|
$agent = LWP::UserAgent->new(); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $response = $agent->get( $options{url} ); |
36
|
|
|
|
|
|
|
if ( !$response->is_success() ) { |
37
|
|
|
|
|
|
|
if ( $options{die_on_failure} ) { |
38
|
|
|
|
|
|
|
die($response); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
|
|
|
|
|
|
return; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$xml_string = $response->content(); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$self->_parse_node( XML::LibXML::Reader->new( string => $xml_string ) ); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return $self; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |