line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
1703
|
use strict; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
126
|
|
2
|
5
|
|
|
5
|
|
15
|
use warnings; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
200
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Maven::Xml::XmlFile; |
5
|
|
|
|
|
|
|
$Maven::Xml::XmlFile::VERSION = '1.12'; |
6
|
|
|
|
|
|
|
# ABSTRACT: A base class for Maven XML file |
7
|
|
|
|
|
|
|
# PODNAME: Maven::Xml::XmlFile |
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
17
|
use parent qw(Maven::Xml::XmlNodeParser); |
|
5
|
|
|
|
|
4
|
|
|
5
|
|
|
|
|
27
|
|
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__ |