Skip Menu |

This queue is for tickets about the Geo-METAR CPAN distribution.

Report information
The Basics
Id: 32088
Status: open
Priority: 0/
Queue: Geo-METAR

People
Owner: koos [...] kzdoos.xs4all.nl
Requestors: amoore [...] mooresystems.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.15
Fixed in: (no value)



Subject: METAR information is not cleared between calls to ->metar method
If you call ->metar twice, on two different METAR reports, the information isn't cleared and the reports get mixed. For instance, if you call ->metar on a report that has a 'RUNWAY' value, and then you use the same object to call it again on another report that has an 'RUNWAY' value, then, when you ask for ->runway, you get a list of both sets of runways. Also, if the first report has some information and the second doesn't, then that information is not deleted. I've attached a test script to demonstrate this. I believe the fix is to call most of the code in the 'new' method each time that 'metar' is called. I can provide a patch to do that if you'd like. Thanks, -Andy
Subject: usetwice.t
#!/usr/bin/perl # =HEAD2 usewtice This test suite verifies that all object attributes are reset when a second METAR report is parsed. Weather information from previous reports should no longer be in the object after it parses a second METAR report. =cut use strict; use warnings; use Test::More tests => 34; use Data::Dumper; use Geo::METAR; my @methods = qw( METAR TYPE SITE DATE TIME MOD WIND_DIR_DEG WIND_DIR_ENG WIND_DIR_ABB WIND_KTS WIND_GUST_KTS WIND_MPH WIND_GUST_MPH WIND_VAR WIND_VAR_1 WIND_VAR_2 VISIBILITY RUNWAY WEATHER WEATHER_LOG SKY TEMP_F TEMP_C DEW_F DEW_C HOURLY_TEMP_F HOURLY_TEMP_C HOURLY_DEW_F HOURLY_DEW_C HOURLY_PRECIP ALT SLP REMARKS ); my @report = ( 'KMCI 041553Z 19017KT 10SM FEW150 OVC250 01/M06 A3006 RMK AO2 PK WND 19028/1525 SLP188 T00061056', 'KFDY 251450Z 21012G21KT 8SM OVC065 04/M01 A3010 RMK 57014' ); my $m = Geo::METAR->new(); isa_ok( $m, 'Geo::METAR' ); # parse the first report, call each method in it, and record the results in %firstresult. $m->metar( $report[0] ); my %firstresult; foreach my $method ( @methods) { $firstresult{ $method } = $m->$method(); } # Then, parse a two reports and verify that we get the same answers back. $m = Geo::METAR->new(); isa_ok( $m, 'Geo::METAR' ); $m->metar( $report[1] ); $m->metar( $report[0] ); foreach my $method ( @methods ) { is_deeply( $m->$method, $firstresult{ $method }, "$method" ) or diag( Data::Dumper->Dump( [ $m->$method() ], [ "$method" ] ) ); } __END__