Report.pm

filter: Statementstmt 20.9% 35 / 167 Branchbran 0.0% 0 / 68 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 32.1% 9 / 28 Podpod 25.0% 1 / 4 totaltotal 16.5% 45 / 272 CC 36 SCAR 23.5
CC
36
Cov
15%
_request
20.0
GetCurrentWeather
13.3
Parse_XML_Data_decode
12.0
CRAP 10.5
↑ Summary GenerateXML.pm »
1 package NDFD::Weather::Report;
2 1 ▶use 5.010000;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use SOAP::Lite;# + trace => 'debug';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use XML::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 our $VERSION=1.00;
9 1 require Exporter;
10 1 our @ISA = qw(Exporter);
11
12 # Items to export into callers namespace by default. Note: do not export
13 # names by default without a very good reason. Use EXPORT_OK instead.
14 # Do not simply export all your public functions/methods/constants.
15
16 # This allows declaration use NDFD::Weather::Report ':all';
17 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
18 # will save memory.
19 1 our %EXPORT_TAGS = ( 'all' => [ qw(
20 NDFDgen LatLonListCityNames GetCurrentWeather
21 ) ] );
22
23 1 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
24
25 1 our @EXPORT = qw(
26
27 );
28
29 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
30 0 my $class = shift;
31 0 my %params=@_;
32 0 my $self ={
33 %params,
34 };
35 0 return bless $self, $class;
36 }
37 0 ▶sub _request{
Subroutine _request: not called CC=4 SCAR=30.0
38 0 my $class=shift;
39 0 my ($self)=shift;
40 $$self{'uri'} = ($$self{'uri'}) ? $$self{'uri'} :
41 'http://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php?wsdl',
42 $$self{'proxy'} = ($$self{'proxy'}) ? $$self{'proxy'} :
43 'http://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php',
44 $$self{'EndPoint_url'} = ($$self{'EndPoint_url'}) ? $$self{'EndPoint_url'} :
45 'http://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl',
46 my $soap_request = SOAP::Lite
47 -> uri($$self{'uri'})
48 0 ▶ ->on_action(sub{join '#',@_ })
Subroutine __ANON__: not called CC=1 SCAR=6.9
49 0 ▶ -> proxy($$self{'proxy'}
Branch: 3 branches
BranchTrueFalseTotal
$self->{'uri'} ? : 0 0 0
$self->{'proxy'} ? : 0 0 0
$self->{'EndPoint_url'} ? : 0 0 0
50 );
51 0 $soap_request->ns($$self{'EndPoint_url'}, 'ndf');
52 0 $soap_request->envprefix('soapenv');
53 0 $soap_request->readable(1);
54 }
55 0 ▶sub Parse_XML_Data_decode{
Subroutine Parse_XML_Data_decode: not called CC=3 SCAR=24.8
Pod undocumented
56 0 my $class=shift;
57 0 my ($xml)=shift;
58 0 ▶ if (SOAP::Deserializer->is_xml($xml)==1){
Branch: 1 branch
BranchTrueFalseTotal
if ("SOAP::Deserializer"->is_xml($xml) == 1) 0 0 0
59 0 return eval{
60 0 SOAP::Deserializer->decode($xml);
61 };
62 }
63
64 ####error message marker no. 1 ###
65 0 ▶ print "xml_Data_parse_error","Xml parsing error: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
66 }
67 0 ▶sub Parse_XML_deserialize{
Subroutine Parse_XML_deserialize: not called CC=3 SCAR=24.8
Pod undocumented
68 0 my $class=shift;
69 0 my ($xml)=shift;
70 0 ▶ if (SOAP::Deserializer->is_xml($xml)==1){
Branch: 1 branch
BranchTrueFalseTotal
if ("SOAP::Deserializer"->is_xml($xml) == 1) 0 0 0
71 0 return eval{
72 0 SOAP::Deserializer->deserialize($xml);
73 };
74 }
75
76 ####error message marker no. 2 ###
77 0 ▶ print "xml_Data_parse_error","Xml parsing error: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
78 }
79 0 ▶sub Parse_XML_Data{
Subroutine Parse_XML_Data: not called CC=2 SCAR=17.9
Pod undocumented
80 0 my $class=shift;
81 0 my ($xml)=shift;
82 0 return eval{
83 0 XMLin($xml,ForceArray => 1,NormaliseSpace=>2,SuppressEmpty=>undef)
84 };
85
86 ####error message marker no. 3 ###
87 0 ▶ print "xml_Data_parse_error","Xml parsing error: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
88 }
89
90
91 package NDFD::Weather::Processer;
92 1 ▶use NDFD::Weather::GenerateXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
93 1 ▶use NDFD::Weather::RequestProcess;
Subroutine BEGIN: called CC=1 SCAR=0.0
94 1 our @ISA = qw(NDFD::Weather::Report);
95 0 ▶sub CornerPoints{
Subroutine CornerPoints: not called CC=3 SCAR=24.8
96 0 my $Process_Return1=
97 NDFD::Weather::RequestProcess
98 ->_CP(shift)
99 ;
100 0 ▶ if(!$Process_Return1->valueof('//CornerPointsResponse/listLatLonOut/')){
Branch: 1 branch
BranchTrueFalseTotal
unless ($Process_Return1->valueof("//CornerPointsResponse/listLatLonOut/")) 0 0 0
101 0 ▶ if(!$Process_Return1->valueof('//ExceptionText')){
Branch: 1 branch
BranchTrueFalseTotal
if (not $Process_Return1->valueof('//ExceptionText')) { } 0 0 0
102
103 0 my $error_msg0 =$Process_Return1->valueof('//faultstring');
104 0 my $error_msg1 =$Process_Return1->valueof('//detail');
105 0 return "Error :-".$error_msg0.". Details :- ".$error_msg1;
106 }else{
107 return
108 0 $Process_Return1
109 ->valueof('//ExceptionText');
110 }
111 }
112 0 return $Process_Return1->valueof('//CornerPointsResponse/listLatLonOut/');
113 }
114 0 ▶sub LatLonListCityNames{
Subroutine LatLonListCityNames: not called CC=3 SCAR=24.8
115 0 my $Process_Return2=
116 NDFD::Weather::RequestProcess
117 ->_LLLCN(shift)
118 ;
119 0 ▶ if(!$Process_Return2->valueof('//LatLonListCityNamesResponse/listLatLonOut/')){
Branch: 1 branch
BranchTrueFalseTotal
unless ($Process_Return2->valueof("//LatLonListCityNamesResponse/listLatLonOut/")) 0 0 0
120 0 ▶ if(!$Process_Return2->valueof('//ExceptionText')){
Branch: 1 branch
BranchTrueFalseTotal
if (not $Process_Return2->valueof('//ExceptionText')) { } 0 0 0
121
122 0 my $error_msg0 =$Process_Return2->valueof('//faultstring');
123 0 my $error_msg1 =$Process_Return2->valueof('//detail');
124 0 return "Error :-".$error_msg0.". Details :- ".$error_msg1;
125 }else{
126 return
127 0 $Process_Return2
128 ->valueof('//ExceptionText');
129 }
130 }
131 0 return $Process_Return2->valueof('//LatLonListCityNamesResponse/listLatLonOut/');
132 }
133 0 ▶sub LatLonListZipCode{
Subroutine LatLonListZipCode: not called CC=3 SCAR=24.8
134 0 my $Process_Return3=
135 NDFD::Weather::RequestProcess
136 ->_LLLZC(shift)
137 ;
138 0 ▶ if(!$Process_Return3->valueof('//LatLonListZipCodeResponse/listLatLonOut/')){
Branch: 1 branch
BranchTrueFalseTotal
unless ($Process_Return3->valueof("//LatLonListZipCodeResponse/listLatLonOut/")) 0 0 0
139 0 ▶ if(!$Process_Return3->valueof('//ExceptionText')){
Branch: 1 branch
BranchTrueFalseTotal
if (not $Process_Return3->valueof('//ExceptionText')) { } 0 0 0
140
141 0 my $error_msg0 =$Process_Return3->valueof('//faultstring');
142 0 my $error_msg1 =$Process_Return3->valueof('//detail');
143 0 return "Error :-".$error_msg0.". Details :- ".$error_msg1;
144 }else{
145 return
146 0 $Process_Return3
147 ->valueof('//ExceptionText');
148 }
149 }
150 0 return $Process_Return3->valueof('//LatLonListZipCodeResponse/listLatLonOut/');
151 }
152 0 ▶sub NDFDgenByDay{
Subroutine NDFDgenByDay: not called CC=3 SCAR=24.8
153 0 my $Process_Return4=
154 NDFD::Weather::RequestProcess
155 ->_NDFDGBD(shift);
156 0 ▶ if(!$Process_Return4->valueof('//NDFDgenByDayResponse/dwmlByDayOut')){
Branch: 1 branch
BranchTrueFalseTotal
unless ($Process_Return4->valueof("//NDFDgenByDayResponse/dwmlByDayOut")) 0 0 0
157 0 ▶ if(!$Process_Return4->valueof('//ExceptionText')){
Branch: 1 branch
BranchTrueFalseTotal
if (not $Process_Return4->valueof('//ExceptionText')) { } 0 0 0
158
159 0 my $error_msg0 =$Process_Return4->valueof('//faultstring');
160 0 my $error_msg1 =$Process_Return4->valueof('//detail');
161 0 return "Error :-".$error_msg0.". Details :- ".$error_msg1;
162 }else{
163 return
164 0 $Process_Return4
165 ->valueof('//ExceptionText');
166 }
167 }
168 0 return $Process_Return4->valueof('//NDFDgenByDayResponse/dwmlByDayOut');
169 }
170 0 ▶sub NDFDgenByDayLatLonList{
Subroutine NDFDgenByDayLatLonList: not called CC=3 SCAR=24.8
171 0 my $Process_Return5=
172 NDFD::Weather::RequestProcess
173 ->_NDFDGBDLLL(shift)
174 ;
175 0 ▶ if(!$Process_Return5->valueof('//NDFDgenByDayLatLonListResponse/dwmlByDayOut')){
Branch: 1 branch
BranchTrueFalseTotal
unless ($Process_Return5->valueof("//NDFDgenByDayLatLonListResponse/dwmlByDayOut")) 0 0 0
176 0 ▶ if(!$Process_Return5->valueof('//ExceptionText')){
Branch: 1 branch
BranchTrueFalseTotal
if (not $Process_Return5->valueof('//ExceptionText')) { } 0 0 0
177
178 0 my $error_msg0 =$Process_Return5->valueof('//faultstring');
179 0 my $error_msg1 =$Process_Return5->valueof('//detail');
180 0 return "Error :-".$error_msg0.". Details :- ".$error_msg1;
181 }else{
182 return
183 0 $Process_Return5
184 ->valueof('//ExceptionText');
185 }
186 }
187 0 return $Process_Return5->valueof('//NDFDgenByDayLatLonListResponse/dwmlByDayOut');
188 }
189 0 ▶sub GmlLatLonList{
Subroutine GmlLatLonList: not called CC=3 SCAR=24.8
190 0 my $Process_Return6 =
191 NDFD::Weather::RequestProcess
192 ->_GLLL(shift)
193 ;
194 0 ▶ if(!$Process_Return6->valueof('//GmlLatLonListResponse/dwGmlOut')){
Branch: 1 branch
BranchTrueFalseTotal
unless ($Process_Return6->valueof("//GmlLatLonListResponse/dwGmlOut")) 0 0 0
195 0 ▶ if(!$Process_Return6->valueof('//ExceptionText')){
Branch: 1 branch
BranchTrueFalseTotal
if (not $Process_Return6->valueof('//ExceptionText')) { } 0 0 0
196
197 0 my $error_msg0 =$Process_Return6->valueof('//faultstring');
198 0 my $error_msg1 =$Process_Return6->valueof('//detail');
199 0 return "Error :-".$error_msg0.". Details :- ".$error_msg1;
200 }else{
201 return
202 0 $Process_Return6
203 ->valueof('//ExceptionText');
204 }
205 }
206 #else{return $Process_Return6->valueof('//GmlLatLonListResponse/dwGmlOut')};
207 0 return $Process_Return6->valueof('//GmlLatLonListResponse/dwGmlOut');
208 }
209 0 ▶sub NDFDgen{
Subroutine NDFDgen: not called CC=3 SCAR=24.8
210 0 my $Process_Return7 =
211 NDFD::Weather::RequestProcess
212 ->_NDFDG(shift)
213 ;
214 0 ▶ if(!$Process_Return7->valueof('//NDFDgenResponse/dwmlOut')){
Branch: 1 branch
BranchTrueFalseTotal
unless ($Process_Return7->valueof("//NDFDgenResponse/dwmlOut")) 0 0 0
215 0 ▶ if(!$Process_Return7->valueof('//ExceptionText')){
Branch: 1 branch
BranchTrueFalseTotal
if (not $Process_Return7->valueof('//ExceptionText')) { } 0 0 0
216
217 0 my $error_msg0 =$Process_Return7->valueof('//faultstring');
218 0 my $error_msg1 =$Process_Return7->valueof('//detail');
219 0 return "Error :-".$error_msg0.". Details :- ".$error_msg1;
220 }else{
221 return
222 0 $Process_Return7
223 ->valueof('//ExceptionText');
224 }
225 }
226 0 return $Process_Return7->valueof('//NDFDgenResponse/dwmlOut');
227 }
228
229 0 ▶sub GmlTimeSeries{
Subroutine GmlTimeSeries: not called CC=3 SCAR=24.8
230 0 my $Process_Return8 =
231 NDFD::Weather::RequestProcess
232 ->_GTS(shift)
233 ;
234 0 ▶ if(!$Process_Return8->valueof('//GmlTimeSeriesResponse/dwGmlOut')){
Branch: 1 branch
BranchTrueFalseTotal
unless ($Process_Return8->valueof("//GmlTimeSeriesResponse/dwGmlOut")) 0 0 0
235 #&debug($Process_Return8
236 # ->valueof('//ExceptionText'));
237 0 ▶ if(!$Process_Return8->valueof('//ExceptionText')){
Branch: 1 branch
BranchTrueFalseTotal
if (not $Process_Return8->valueof('//ExceptionText')) { } 0 0 0
238
239 0 my $error_msg0 =$Process_Return8->valueof('//faultstring');
240 0 my $error_msg1 =$Process_Return8->valueof('//detail');
241 0 return "Error :-".$error_msg0.". Details :- ".$error_msg1;
242 }else{
243 return
244 0 $Process_Return8
245 ->valueof('//ExceptionText');
246 }
247
248 }
249 0 return $Process_Return8->valueof('//GmlTimeSeriesResponse/dwGmlOut');
250 }
251 0 ▶sub LatLonListLine{
Subroutine LatLonListLine: not called CC=3 SCAR=24.8
252 0 my $Process_Return9 =
253 NDFD::Weather::RequestProcess
254 ->_LLLL(shift)
255 ;
256 0 ▶ if(!$Process_Return9->valueof('//LatLonListLineResponse/listLatLonOut')){
Branch: 1 branch
BranchTrueFalseTotal
unless ($Process_Return9->valueof("//LatLonListLineResponse/listLatLonOut")) 0 0 0
257 0 ▶ if(!$Process_Return9->valueof('//ExceptionText')){
Branch: 1 branch
BranchTrueFalseTotal
if (not $Process_Return9->valueof('//ExceptionText')) { } 0 0 0
258
259 0 my $error_msg0 =$Process_Return9->valueof('//faultstring');
260 0 my $error_msg1 =$Process_Return9->valueof('//detail');
261 0 return "Error :-".$error_msg0.". Details :- ".$error_msg1;
262 }else{
263 return
264 0 $Process_Return9
265 ->valueof('//ExceptionText');
266 }
267
268 }
269 0 return $Process_Return9->valueof('//LatLonListLineResponse/listLatLonOut');
270 }
271 0 ▶sub LatLonListSquare{
Subroutine LatLonListSquare: not called CC=3 SCAR=24.8
272 0 my $Process_Return10 =
273 NDFD::Weather::RequestProcess
274 ->_LLLS(shift)
275 ;
276 0 ▶ if(!$Process_Return10->valueof('//LatLonListSquareResponse/listLatLonOut')){
Branch: 1 branch
BranchTrueFalseTotal
unless ($Process_Return10->valueof("//LatLonListSquareResponse/listLatLonOut")) 0 0 0
277 0 ▶ if(!$Process_Return10->valueof('//ExceptionText')){
Branch: 1 branch
BranchTrueFalseTotal
if (not $Process_Return10->valueof('//ExceptionText')) { } 0 0 0
278
279 0 my $error_msg0 =$Process_Return10->valueof('//faultstring');
280 0 my $error_msg1 =$Process_Return10->valueof('//detail');
281 0 return "Error :-".$error_msg0.". Details :- ".$error_msg1;
282 }else{
283 return
284 0 $Process_Return10
285 ->valueof('//ExceptionText');
286 }
287
288 }
289 0 return $Process_Return10->valueof('//LatLonListSquareResponse/listLatLonOut');
290 }
291 0 ▶sub LatLonListSubgrid{
Subroutine LatLonListSubgrid: not called CC=3 SCAR=24.8
292 0 my $Process_Return11 =
293 NDFD::Weather::RequestProcess
294 ->_LLLSBD(shift)
295 ;
296 0 ▶ if(!$Process_Return11->valueof('//LatLonListSubgridResponse/listLatLonOut')){
Branch: 1 branch
BranchTrueFalseTotal
unless ($Process_Return11->valueof("//LatLonListSubgridResponse/listLatLonOut")) 0 0 0
297 0 ▶ if(!$Process_Return11->valueof('//ExceptionText')){
Branch: 1 branch
BranchTrueFalseTotal
if (not $Process_Return11->valueof('//ExceptionText')) { } 0 0 0
298
299 0 my $error_msg0 =$Process_Return11->valueof('//faultstring');
300 0 my $error_msg1 =$Process_Return11->valueof('//detail');
301 0 return "Error :-".$error_msg0.". Details :- ".$error_msg1;
302 }else{
303 return
304 0 $Process_Return11
305 ->valueof('//ExceptionText');
306 }
307
308 }
309 0 return $Process_Return11->valueof('//LatLonListSubgridResponse/listLatLonOut');
310 }
311 0 ▶sub NDFDgenLatLonList{
Subroutine NDFDgenLatLonList: not called CC=3 SCAR=24.8
312 0 my $Process_Return12 =
313 NDFD::Weather::RequestProcess
314 ->_NDFDLLLT(shift)
315 ;
316 0 ▶ if(!$Process_Return12->valueof('//NDFDgenLatLonListResponse/dwmlOut')){
Branch: 1 branch
BranchTrueFalseTotal
unless ($Process_Return12->valueof("//NDFDgenLatLonListResponse/dwmlOut")) 0 0 0
317
318 0 ▶ if(!$Process_Return12->valueof('//ExceptionText')){
Branch: 1 branch
BranchTrueFalseTotal
if (not $Process_Return12->valueof('//ExceptionText')) { } 0 0 0
319
320 0 my $error_msg0 =$Process_Return12->valueof('//faultstring');
321 0 my $error_msg1 =$Process_Return12->valueof('//detail');
322 0 return "Error :-".$error_msg0.". Details :- ".$error_msg1;
323 }else{
324 return
325 0 $Process_Return12
326 ->valueof('//ExceptionText');
327 }
328
329 }
330 0 return $Process_Return12->valueof('//NDFDgenLatLonListResponse/dwmlOut');
331 }
332 0 ▶sub GetCurrentWeather{
Subroutine GetCurrentWeather: not called CC=4 SCAR=25.8
333 0 shift;
334 0 my $latitude=shift;
335 0 my $longitude=shift;
336
337
338 0 ▶ die "latitude or longitude vlaue is missing !!" unless defined $latitude and $longitude;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $latitude and $longitude 0 0 0
Condition0%0/3
defined $latitude and $longitude
!ll&&!rl&&r
000
MC/DC0%0/2
defined $latitude and $longitude
defined $latitude $longitude
Truth table0%0/3
A and B
A= defined $latitudeB= $longitude
ABresult
0X0
100
111
339
340 1 ▶ use LWP::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
341 0 my $url = "http://forecast.weather.gov/MapClick.php?lat=$latitude&lon=$longitude&unit=0&lg=english&FcstType=dwml";
342 0 my $content = get $url;
343 0 ▶ die "Couldn't get $url" unless defined $content;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $content 0 0 0
344 #$q->header('text/xml');
345 0 return $content;
346 }
347 #sub debug{
348 # my $messsage=shift;
349 # print $messsage;
350 #}
351 1 1;
352 __END__
↑ Summary GenerateXML.pm »