lib/XML/Compile/RPC.pm

filter: Statementstmt 100% 41 / 41 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 1 totaltotal 98.1% 53 / 54 CC 2 SCAR 1.7
CC
2
Cov
100%
_rewrite_string
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« lib/XML/Compile/RPC/Util.pm ↑ Summary
1 # Copyrights 2009-2013 by [Mark Overmeer].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.01.
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 package XML::Compile::RPC;
9 4 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 $VERSION = '0.17';
11  
12 4 ▶use base 'XML::Compile::Cache';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 4 ▶use Log::Report 'xml-compile-rpc', syntax => 'SHORT';
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16  
17 sub init($)
18 3 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
19  
20 3 push @{$args->{opts_rw}}, sloppy_floats => 1, sloppy_integers => 1
21 , mixed_elements => 'STRUCTURAL';
22  
23 3 push @{$args->{opts_readers}}
24 , hooks => [ {type => 'ValueType', replace => \&_rewrite_string}
25 , {type => 'ISO8601', replace => \&_reader_rewrite_date} ];
26  
27 3 push @{$args->{opts_writers}}
28 , hook => {type => 'ISO8601', before => \&_writer_rewrite_date};
29  
30 3 $self->SUPER::init($args);
31  
32 3 (my $xsd = __FILE__) =~ s,\.pm$,/xml-rpc.xsd,;
33 3 $self->importDefinitions($xsd);
34  
35 # only declared methods are accepted by the Cache
36 3 $self->declare(WRITER => 'methodCall');
37 3 $self->declare(READER => 'methodResponse');
38 3 $self;
39 }
40  
41 sub _rewrite_string($$$$$)
42 6 ▶{ my ($element, $reader, $path, $type, $replaced) = @_;
Subroutine _rewrite_string: called CC=2 SCAR=6.9
43 # panic $element->childNodes;
44  
45 6 ▶ (grep $_->isa('XML::LibXML::Element'), $element->childNodes)
Branch: 1 branch
BranchTrueFalseTotal
grep($_->isa('XML::LibXML::Element'), $element->childNodes) ? : 5 1 6
46 ? $replaced->($element)
47 : (value => {string => $element->textContent});
48 }
49  
50 # xsd:dateTime requires - and : between the components
51 sub _iso8601_to_dateTime($)
52 3 ▶{ my $s = shift;
Subroutine _iso8601_to_dateTime: called CC=1 SCAR=0.0
53 3 $s =~ s/^([12][0-9][0-9][0-9])-?([01][0-9])-?([0-3][0-9])T/$1-$2-$3T/;
54 3 $s =~ s/T([012][0-9]):?([0-5][0-9]):?([0-6][0-9])/T$1:$2:$3/;
55 3 $s;
56 }
57  
58 sub _writer_rewrite_date
59 2 ▶{ my ($doc, $string, $path) = @_;
Subroutine _writer_rewrite_date: called CC=1 SCAR=0.0
60 2 _iso8601_to_dateTime $string;
61 }
62  
63 sub _reader_rewrite_date
64 1 ▶{ my ($element, $reader, $path, $type, $replaced) = @_;
Subroutine _reader_rewrite_date: called CC=1 SCAR=0.0
65 1 my $schema_time = _iso8601_to_dateTime $element->textContent;
66 # $schema_time should get validated...
67 1 ('dateTime.iso8601' => $schema_time);
68 }
69  
70 4 1;
« lib/XML/Compile/RPC/Util.pm ↑ Summary