line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Presto::Client::ContentHandlers::XMLSimple; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:MPERRY'; |
3
|
|
|
|
|
|
|
$App::Presto::Client::ContentHandlers::XMLSimple::VERSION = '0.010'; |
4
|
|
|
|
|
|
|
# ABSTRACT: Handles (de)serializing of XML requests/responses |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
343
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
7
|
|
|
|
|
|
|
my $HAS_XML_SIMPLE; |
8
|
|
|
|
|
|
|
BEGIN { |
9
|
1
|
|
|
1
|
|
244
|
eval 'use XML::Simple; $HAS_XML_SIMPLE = 1;'; |
|
1
|
|
|
1
|
|
135
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
10
|
1
|
50
|
|
|
|
181
|
warn $@ if $@; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
sub can_deserialize { |
13
|
1
|
|
|
1
|
0
|
372
|
my $self = shift; |
14
|
1
|
|
|
|
|
2
|
my $content_type = shift; |
15
|
1
|
50
|
|
|
|
6
|
return unless $HAS_XML_SIMPLE; |
16
|
0
|
|
|
|
|
|
return $content_type =~ m{^application/xml}i; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub deserialize { |
20
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
21
|
0
|
|
|
|
|
|
my $content = shift; |
22
|
0
|
|
|
|
|
|
my $ref; |
23
|
0
|
0
|
0
|
|
|
|
eval { $ref = XMLin($content) || 1 } or do { |
|
0
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
warn "Unable to parse XML: $@"; |
25
|
|
|
|
|
|
|
}; |
26
|
0
|
|
|
|
|
|
return $ref; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub can_serialize { |
30
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
31
|
0
|
|
|
|
|
|
my $content_type = shift; |
32
|
0
|
0
|
|
|
|
|
return unless $HAS_XML_SIMPLE; |
33
|
0
|
|
|
|
|
|
return $content_type =~ m{^application/xml}i; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
sub serialize { |
36
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
37
|
0
|
|
|
|
|
|
my $data = shift; |
38
|
0
|
|
|
|
|
|
return XMLout($data); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |