blib/lib/XML/Struct.pm

filter: Statementstmt 82.0% 32 / 39 Branchbran 30.0% 3 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 88.8% 8 / 9 Podpod 75.0% 3 / 4 totaltotal 70.1% 47 / 67 SCAR 21.3
CC
7
Cov
69%
textValues
12.0
readXML
5.9
BEGIN
1.0
CRAP 8.4
« blib/lib/XML/Struct/Writer/Stream.pm ↑ Summary Build »
1 package XML::Struct;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use XML::LibXML::Reader;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use XML::Struct::Reader;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use XML::Struct::Writer;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use XML::Struct::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 our $VERSION = '0.26';
10 5 our @ISA = qw(Exporter);
11 5 our @EXPORT_OK = qw(readXML writeXML simpleXML removeXMLAttr textValues);
12  
13 sub readXML { # ( [$from], %options )
14 32 ▶ my (%options) = @_ % 2 ? (from => @_) : @_;
Subroutine readXML: called CC=5 SCAR=17.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 ? : 32 0 32
15  
16 my %reader_options = (
17 54 map { $_ => delete $options{$_} }
18 32 grep { exists $options{$_} }
19 qw(attributes whitespace path stream simple micro root ns depth content deep)
20 );
21 32 ▶ if (%options) {
Branch: 1 branch
BranchTrueFalseTotal
if (%options) 32 0 32
22 32 ▶ if (exists $options{from} and keys %options == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $options{'from'} and keys %options == 1) { } 32 0 32
Condition33%1/3
exists $options{"from"} and keys %options == 1
!ll&&!rl&&r
0032
MC/DC0%0/2
exists $options{"from"} and keys %options == 1
exists $options{"from"} keys %options == 1
Truth table33%1/3
A and B
A= exists $options{"from"}B= keys %options == 1
ABresult
0X0
100
111
23 32 $reader_options{from} = $options{from};
24 } else {
25 0 $reader_options{from} = \%options;
26 }
27 }
28  
29 32 XML::Struct::Reader->new( %reader_options )->readDocument;
30 }
31  
32 sub writeXML {
33 1 ▶ my ($xml, %options) = @_;
Subroutine writeXML: called CC=1 SCAR=0.0
Pod documented
34 1 XML::Struct::Writer->new(%options)->write($xml);
35 }
36  
37 sub simpleXML {
38 1 ▶ my ($element, %options) = @_;
Subroutine simpleXML: called CC=1 SCAR=0.0
Pod documented
39 1 XML::Struct::Simple->new(%options)->transform($element);
40 }
41  
42 5 *removeXMLAttr = *XML::Struct::Simple::removeXMLAttr;
43  
44 # TODO: document (better name?)
45 sub textValues {
46 0 ▶ my ($element, $options) = @_;
Subroutine textValues: not called CC=3 SCAR=24.8
Pod undocumented
47 # TODO: %options (e.g. join => " ")
48  
49 0 my $children = $element->[2];
50 0 ▶ return "" if !$children;
Branch: 1 branch
BranchTrueFalseTotal
unless $children 0 0 0
51  
52 0 return join "", grep { $_ ne "" } map {
53 0 ▶ ref $_ ? textValues($_, $options) : $_
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 0 0 0
54 } @$children;
55 }
56  
57 5 1;
58 __END__
« blib/lib/XML/Struct/Writer/Stream.pm ↑ Summary Build »