lib/XML/Loy/GeoRSS.pm

filter: Statementstmt 97.5% 78 / 80 Branchbran 74.1% 43 / 58 Conditioncond 68.9% 20 / 29 MC/DCmcdc 43.7% 7 / 16 Subroutinesub 93.7% 15 / 16 Podpod 100% 11 / 11 totaltotal 82.8% 174 / 210 CC 44 SCAR 20.8
CC
44
Cov
84%
geo_polygon
12.6
geo_line
10.2
geo_point
10.0
CRAP 8.0
« blib/lib/XML/Loy/Date/RFC822.pm ↑ Summary blib/lib/XML/Loy/Atom.pm »
1 package XML::Loy::GeoRSS;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use XML::Loy with => (
Subroutine BEGIN: called CC=1 SCAR=0.0
6 prefix => 'georss',
7 namespace => 'http://www.georss.org/georss'
8 1 );
9  
10 1 ▶use Carp qw/carp/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Scalar::Util qw/looks_like_number/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # No constructor
14 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
15 0 carp 'Only use ' . __PACKAGE__ . ' as an extension';
16 0 return;
17 };
18  
19  
20 # Add 'point' element
21 4 ▶sub geo_point {
Subroutine geo_point: called CC=9 SCAR=23.0
Pod documented
22 4 my $self = shift;
23  
24 # Get
25 4 ▶ if (@_ <= 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_ <= 1) { } 2 2 4
elsif (@_ == 2 and &looks_like_number($_[0]) and &looks_like_number($_[1])) { } 1 2 3
26 # Get point object
27 2 ▶ my $point = $self->find('point') or return;
Branch: 1 branch
BranchTrueFalseTotal
my $point = $self->find("point") or return 2 0 2
28 2 ▶ $point = $point->[ shift // 0 ] or return;
Branch: 1 branch
BranchTrueFalseTotal
$point = $$point[shift() // 0] or return 2 0 2
Condition50%1/2
shift() // 0
l!l
02
MC/DC0%0/1
shift() // 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
29  
30 # Wrong namespace
31 2 ▶ return if $point->namespace ne __PACKAGE__->_namespace;
Branch: 1 branch
BranchTrueFalseTotal
if $point->namespace ne __PACKAGE__->_namespace 0 2 2
32  
33 # Return point
34 2 return [ split /\s+/, $point->text ];
35 }
36  
37 # Set
38 ▶ elsif (@_ == 2 && looks_like_number($_[0]) && looks_like_number($_[1])) {
Condition66%4/6
@_ == 2 and &looks_like_number($_[0]) and &looks_like_number($_[1])
!ll&&!rl&&r
101
@_ == 2 and &looks_like_number($_[0])
!ll&&!rl&&r
101
MC/DC33%1/3
@_ == 2 and &looks_like_number($_[0]) and &looks_like_number($_[1])
@_ == 2 &looks_like_number($_[0]) &looks_like_number($_[1])
Truth table50%2/4
A and B and C
A= @_ == 2B= &looks_like_number($_[0])C= &looks_like_number($_[1])
ABCresult
0XX0
10X0
1100
1111
39 1 return $self->add(point => $_[0] . ' ' . $_[1]);
40 }
41  
42 # Parameterlist has wrong length
43 1 return;
44 };
45  
46  
47 # Add 'line' element
48 14 ▶sub geo_line {
Subroutine geo_line: called CC=10 SCAR=23.3
Pod documented
49 14 my $self = shift;
50  
51 # Get
52 14 ▶ if (@_ <= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ <= 1) 10 4 14
53 10 ▶ my $line = $self->find('line') or return;
Branch: 1 branch
BranchTrueFalseTotal
my $line = $self->find("line") or return 10 0 10
54 10 ▶ $line = $line->[ shift // 0 ] or return;
Branch: 1 branch
BranchTrueFalseTotal
$line = $$line[shift() // 0] or return 10 0 10
Condition100%2/2
shift() // 0
l!l
64
MC/DC100%1/1
shift() // 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
55  
56 # Wrong namespace
57 10 ▶ return if $line->namespace ne __PACKAGE__->_namespace;
Branch: 1 branch
BranchTrueFalseTotal
if $line->namespace ne __PACKAGE__->_namespace 0 10 10
58  
59 # Return line
60 10 my @points;
61 10 my @v = split /\s+/, $line->text;
62 10 ▶ push @points, [ shift(@v), shift(@v) // 0 ] while @v;
Branch: 1 branch
BranchTrueFalseTotal
@v and do { push @points, [shift @v, shift @v // 0] } 26 10 36
Condition50%1/2
shift @v // 0
l!l
260
MC/DC0%0/1
shift @v // 0
shift @v
Truth table50%1/2
A
A= shift @v
Aresult
11
00
63 10 return \@points;
64 };
65  
66 # Parameterlist not even or too small
67 4 ▶ return if @_ % 2 || @_ < 4;
Branch: 1 branch
BranchTrueFalseTotal
if @_ % 2 or @_ < 4 2 2 4
Condition100%3/3
@_ % 2 or @_ < 4
l!l&&r!l&&!r
112
MC/DC100%2/2
@_ % 2 or @_ < 4
@_ % 2 @_ < 4
Truth table100%3/3
A or B
A= @_ % 2B= @_ < 4
ABresult
1X1
011
000
68  
69 # Set
70 2 return $self->add(line => join(' ',@_) );
71 };
72  
73  
74 # Add 'polygon' element
75 13 ▶sub geo_polygon {
Subroutine geo_polygon: called CC=12 SCAR=25.3
Pod documented
76 13 my $self = shift;
77  
78 # Get
79 13 ▶ if (@_ <= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ <= 1) 8 5 13
80 8 ▶ my $poly = $self->find('polygon') or return;
Branch: 1 branch
BranchTrueFalseTotal
my $poly = $self->find("polygon") or return 8 0 8
81 8 ▶ $poly = $poly->[ shift // 0 ] or return;
Branch: 1 branch
BranchTrueFalseTotal
$poly = $$poly[shift() // 0] or return 8 0 8
Condition50%1/2
shift() // 0
l!l
08
MC/DC0%0/1
shift() // 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
82  
83 # Wrong namespace
84 8 ▶ return if $poly->namespace ne __PACKAGE__->_namespace;
Branch: 1 branch
BranchTrueFalseTotal
if $poly->namespace ne __PACKAGE__->_namespace 0 8 8
85  
86 # Return polygon
87 8 my @points;
88 8 my @v = split /\s+/, $poly->text;
89 8 ▶ push @points, [ shift(@v), shift(@v) // 0 ] while @v;
Branch: 1 branch
BranchTrueFalseTotal
@v and do { push @points, [shift @v, shift @v // 0] } 32 8 40
Condition50%1/2
shift @v // 0
l!l
320
MC/DC0%0/1
shift @v // 0
shift @v
Truth table50%1/2
A
A= shift @v
Aresult
11
00
90 8 return \@points;
91 };
92  
93 # Parameterlist not even or too small
94 5 ▶ return if @_ % 2 || @_ < 6;
Branch: 1 branch
BranchTrueFalseTotal
if @_ % 2 or @_ < 6 3 2 5
Condition100%3/3
@_ % 2 or @_ < 6
l!l&&r!l&&!r
122
MC/DC100%2/2
@_ % 2 or @_ < 6
@_ % 2 @_ < 6
Truth table100%3/3
A or B
A= @_ % 2B= @_ < 6
ABresult
1X1
011
000
95  
96 # Last pair is not identical to first pair
97 2 ▶ if ($_[0] != $_[$#_ - 1] && $_[1] != $_[$#_]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] != $_[$#_ - 1] and $_[1] != $_[$#_]) 1 1 2
Condition66%2/3
$_[0] != $_[$#_ - 1] and $_[1] != $_[$#_]
!ll&&!rl&&r
101
MC/DC50%1/2
$_[0] != $_[$#_ - 1] and $_[1] != $_[$#_]
$_[0] != $_[$#_ - 1] $_[1] != $_[$#_]
Truth table66%2/3
A and B
A= $_[0] != $_[$#_ - 1]B= $_[1] != $_[$#_]
ABresult
0X0
100
111
98 1 push(@_, @_[0..1]);
99 };
100  
101 # Add polygon
102 2 return $self->add(polygon => join(' ', @_));
103 };
104  
105  
106 # Add properties
107 1 ▶sub geo_property {
Subroutine geo_property: called CC=4 SCAR=13.9
Pod documented
108 1 my $self = shift;
109  
110 1 my %properties = @_;
111  
112 # Add all available properties
113 1 foreach my $tag (grep(/^(?:(?:relationship|featuretype)tag|featurename)$/i,
114 keys %properties)) {
115  
116 3 my $val = $properties{$tag};
117  
118 # Add as an array, if it is one
119 3 ▶ foreach (ref $val ? @$val : ($val)) {
Branch: 1 branch
BranchTrueFalseTotal
ref $val ? : 2 1 3
120 5 $self->add( lc($tag) => $_ );
121 };
122 };
123  
124 1 return $self;
125 };
126  
127  
128 # Add 'floor' element
129 1 ▶sub geo_floor {
Subroutine geo_floor: called CC=1 SCAR=0.0
Pod documented
130 1 shift->add(floor => shift);
131 };
132  
133  
134 # Add 'elev' element
135 1 ▶sub geo_elev {
Subroutine geo_elev: called CC=1 SCAR=0.0
Pod documented
136 1 shift->add(elev => shift);
137 };
138  
139  
140 # Add 'radius' element
141 1 ▶sub geo_radius {
Subroutine geo_radius: called CC=1 SCAR=0.0
Pod documented
142 1 shift->add(radius => shift);
143 };
144  
145  
146 # Add 'where' element
147 1 ▶sub geo_where {
Subroutine geo_where: called CC=1 SCAR=0.0
Pod documented
148 1 shift->add('where');
149 };
150  
151  
152 # Add 'box' element
153 8 ▶sub geo_box {
Subroutine geo_box: called CC=7 SCAR=19.9
Pod documented
154 8 my $self = shift;
155  
156 8 ▶ if (@_ <= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ <= 1) 4 4 8
157 4 ▶ my $box = $self->find('box') or return;
Branch: 1 branch
BranchTrueFalseTotal
my $box = $self->find("box") or return 4 0 4
158 4 ▶ $box = $box->[ shift // 0 ] or return;
Branch: 1 branch
BranchTrueFalseTotal
$box = $$box[shift() // 0] or return 4 0 4
Condition50%1/2
shift() // 0
l!l
04
MC/DC0%0/1
shift() // 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
159  
160 # Wrong namespace
161 4 ▶ return if $box->namespace ne __PACKAGE__->_namespace;
Branch: 1 branch
BranchTrueFalseTotal
if $box->namespace ne __PACKAGE__->_namespace 0 4 4
162  
163 # Return box
164 4 my @points;
165 4 my @v = split /\s+/, $box->text;
166 return [
167 4 [$v[0], $v[1]],
168 [$v[2], $v[3]]
169 ];
170 };
171  
172 # Parameterlist has wrong length
173 4 ▶ return unless @_ == 4;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 4 3 1 4
174  
175 1 return $self->add(box => join(' ',@_));
176 };
177  
178  
179 # Add 'circle' element
180 6 ▶sub geo_circle {
Subroutine geo_circle: called CC=7 SCAR=19.9
Pod documented
181 6 my $self = shift;
182  
183 6 ▶ if (@_ <= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ <= 1) 3 3 6
184 3 ▶ my $circle = $self->find('circle') or return;
Branch: 1 branch
BranchTrueFalseTotal
my $circle = $self->find("circle") or return 3 0 3
185 3 ▶ $circle = $circle->[ shift // 0 ] or return;
Branch: 1 branch
BranchTrueFalseTotal
$circle = $$circle[shift() // 0] or return 3 0 3
Condition50%1/2
shift() // 0
l!l
03
MC/DC0%0/1
shift() // 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
186  
187 # Wrong namespace
188 3 ▶ return if $circle->namespace ne __PACKAGE__->_namespace;
Branch: 1 branch
BranchTrueFalseTotal
if $circle->namespace ne __PACKAGE__->_namespace 0 3 3
189  
190 # Return point
191 3 my @v = split /\s+/, $circle->text;
192 3 return [ [ $v[0], $v[1] ], $v[2] ];
193 };
194  
195 # Parameterlist has wrong length
196 3 ▶ return unless @_ == 3;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 2 1 3
197  
198 1 return $self->add(circle => join(' ',@_));
199 };
200  
201  
202 1 1;
203  
204  
205 __END__
« blib/lib/XML/Loy/Date/RFC822.pm ↑ Summary blib/lib/XML/Loy/Atom.pm »