File Coverage

blib/lib/App/Presto/Client/ContentHandlers/XMLSimple.pm
Criterion Covered Total %
statement 10 27 37.0
branch 2 8 25.0
condition 0 2 0.0
subroutine 5 8 62.5
pod 0 4 0.0
total 17 49 34.6


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