| 1 | package Dancer::Serializer::XML; | ||||||||||||||||||||||||||||
| 2 | 168 | our $AUTHORITY = 'cpan:SUKRIA'; | |||||||||||||||||||||||||||
| 3 | #ABSTRACT: serializer for handling XML data | ||||||||||||||||||||||||||||
| 4 | 168 | $Dancer::Serializer::XML::VERSION = '1.3513'; | |||||||||||||||||||||||||||
| 5 | 168 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 168 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 168 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 168 | ▶ | use Dancer::ModuleLoader; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 168 | ▶ | use Dancer::Config 'setting'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 168 | ▶ | use base 'Dancer::Serializer::Abstract'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | # singleton for the XML::Simple object | ||||||||||||||||||||||||||||
| 13 | 168 | my $_xs; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | # helpers | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | sub from_xml { | ||||||||||||||||||||||||||||
| 18 | 0 | ▶ | my $s = Dancer::Serializer::XML->new; | ||||||||||||||||||||||||||
|
Subroutine
from_xml: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | 0 | $s->deserialize(@_); | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | sub to_xml { | ||||||||||||||||||||||||||||
| 23 | 0 | ▶ | my $s = Dancer::Serializer::XML->new; | ||||||||||||||||||||||||||
|
Subroutine
to_xml: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 24 | 0 | $s->serialize(@_); | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | # class definition | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | sub loaded_xmlsimple { | ||||||||||||||||||||||||||||
| 30 | 0 | ▶ | Dancer::ModuleLoader->load('XML::Simple'); | ||||||||||||||||||||||||||
|
Subroutine
loaded_xmlsimple: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | sub loaded_xmlbackends { | ||||||||||||||||||||||||||||
| 34 | # we need either XML::Parser or XML::SAX too | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | Dancer::ModuleLoader->load('XML::Parser') or | ||||||||||||||||||||||||||
|
Subroutine
loaded_xmlbackends: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | Dancer::ModuleLoader->load('XML::SAX'); | ||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | sub init { | ||||||||||||||||||||||||||||
| 40 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | die 'XML::Simple is needed and is not installed' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | unless $self->loaded_xmlsimple; | ||||||||||||||||||||||||||||
| 43 | 0 | ▶ | die 'XML::Simple needs XML::Parser or XML::SAX and neither is installed' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | unless $self->loaded_xmlbackends; | ||||||||||||||||||||||||||||
| 45 | 0 | $_xs = XML::Simple->new(); | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | sub serialize { | ||||||||||||||||||||||||||||
| 49 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
serialize: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 50 | 0 | my $entity = shift; | |||||||||||||||||||||||||||
| 51 | 0 | my %options = (RootName => 'data'); | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | my $s = setting('engines') || {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
setting('engines') || {}
MC/DC0%0/1
setting('engines') || {}
setting('engines')
Truth table0%0/2
A
A= setting('engines')
| |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | if (exists($s->{XMLSerializer}) && exists($s->{XMLSerializer}{serialize})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $s->{"XMLSerializer"} and exists $s->{"XMLSerializer"}{"serialize"}
MC/DC0%0/2
exists $s->{"XMLSerializer"} and exists $s->{"XMLSerializer"}{"serialize"}
exists $s->{"XMLSerializer"}
exists $s->{"XMLSerializer"}{"serialize"}
Truth table0%0/3
A and B
A= exists $s->{"XMLSerializer"}B= exists $s->{"XMLSerializer"}{"serialize"}
| |||||||||||||||||||||||||||||
| 55 | 0 | %options = (%options, %{$s->{XMLSerializer}{serialize}}); | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | %options = (%options, @_); | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | $_xs->XMLout($entity, %options); | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | sub deserialize { | ||||||||||||||||||||||||||||
| 65 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
deserialize: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 0 | my $xml = shift; | |||||||||||||||||||||||||||
| 67 | 0 | my %options = (); | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | my $s = setting('engines') || {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
setting('engines') || {}
MC/DC0%0/1
setting('engines') || {}
setting('engines')
Truth table0%0/2
A
A= setting('engines')
| |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if (exists($s->{XMLSerializer}) && exists($s->{XMLSerializer}{deserialize})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $s->{"XMLSerializer"} and exists $s->{"XMLSerializer"}{"deserialize"}
MC/DC0%0/2
exists $s->{"XMLSerializer"} and exists $s->{"XMLSerializer"}{"deserialize"}
exists $s->{"XMLSerializer"}
exists $s->{"XMLSerializer"}{"deserialize"}
Truth table0%0/3
A and B
A= exists $s->{"XMLSerializer"}B= exists $s->{"XMLSerializer"}{"deserialize"}
| |||||||||||||||||||||||||||||
| 71 | 0 | %options = (%options, %{$s->{XMLSerializer}{deserialize}}); | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | %options = (%options, @_); | |||||||||||||||||||||||||||
| 75 | 0 | $_xs->XMLin($xml, %options); | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub content_type {'text/xml'} | ||||||||||||||||||||||||||
|
Subroutine
content_type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 168 | 1; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | __END__ | ||||||||||||||||||||||||||||