metar-parser 0.9.11 → 0.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +15 -9
- data/Rakefile +23 -14
- data/bin/download_raw.rb +0 -2
- data/lib/metar/data.rb +84 -73
- data/lib/metar/parser.rb +2 -8
- data/lib/metar/raw.rb +1 -5
- data/lib/metar/report.rb +22 -48
- data/lib/metar/station.rb +16 -63
- data/lib/metar/version.rb +1 -1
- data/locales/en.yml +8 -2
- data/locales/it.yml +6 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/unit/distance_spec.rb +85 -0
- data/spec/unit/parser_spec.rb +234 -0
- data/spec/unit/pressure_spec.rb +32 -0
- data/spec/unit/raw_spec.rb +196 -0
- data/spec/unit/report_spec.rb +187 -0
- data/spec/unit/runway_visible_range_spec.rb +88 -0
- data/spec/unit/sky_condition_spec.rb +73 -0
- data/spec/unit/speed_spec.rb +50 -0
- data/spec/unit/station_spec.rb +254 -0
- data/spec/unit/temperature_spec.rb +47 -0
- data/spec/unit/variable_wind_spec.rb +34 -0
- data/spec/unit/vertical_visibility_spec.rb +37 -0
- data/spec/unit/visibility_spec.rb +84 -0
- data/spec/unit/weather_phenomenon_spec.rb +68 -0
- data/spec/unit/wind_spec.rb +99 -0
- metadata +85 -18
- data/test/all_tests.rb +0 -6
- data/test/metar_test_helper.rb +0 -33
- data/test/unit/data_test.rb +0 -376
- data/test/unit/parser_test.rb +0 -144
- data/test/unit/raw_test.rb +0 -37
- data/test/unit/report_test.rb +0 -105
- data/test/unit/station_test.rb +0 -88
data/test/all_tests.rb
DELETED
data/test/metar_test_helper.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'rubygems' if RUBY_VERSION < '1.9'
|
2
|
-
require File.join(File.expand_path(File.dirname(__FILE__) + '/../lib'), 'metar')
|
3
|
-
|
4
|
-
Metar::Station.load_local
|
5
|
-
|
6
|
-
RAW_EXAMPLE = "2010/02/06 15:20\nLIRQ 061520Z 01007KT 350V050 9999 SCT035 BKN080 08/02 Q1005"
|
7
|
-
# Use a fixed string for testing
|
8
|
-
Metar::Raw.instance_eval do
|
9
|
-
def fetch(cccc)
|
10
|
-
RAW_EXAMPLE
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# Don't load station data from files
|
15
|
-
module Metar
|
16
|
-
class Station
|
17
|
-
|
18
|
-
class << self
|
19
|
-
|
20
|
-
def all_structures
|
21
|
-
[
|
22
|
-
{ :cccc => 'LIRQ', :country => 'Italy', :latitude => '43-48N', :longitude => '011-12E', :name => 'Firenze / Peretola', :state => '' },
|
23
|
-
{ :cccc => 'DAAS', :country => 'Algeria', :latitude => '36-11N', :longitude => '005-25E', :name => 'Setif', :state => '' },
|
24
|
-
{ :cccc => 'ESSB', :country => 'Sweden', :latitude => '59-21N', :longitude => '017-57E',:name => 'Stockholm / Bromma', :state => '' },
|
25
|
-
{ :cccc => 'KPDX', :country => 'United States', :latitude => '45-35N', :longitude => '122-36W', :name => 'PORTLAND INTERNATIONAL AIRPORT', :state => '' },
|
26
|
-
{ :cccc => 'CYXS', :country => 'Canada', :latitude => '53-53N', :longitude => '122-41W', :name => 'Prince George, B. C.', :state => '' },
|
27
|
-
]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
require 'test/unit'
|
data/test/unit/data_test.rb
DELETED
@@ -1,376 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require 'metar_test_helper'
|
5
|
-
|
6
|
-
class TestMetarData < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def setup
|
9
|
-
I18n.locale = :en
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_m9t_translations_available
|
13
|
-
distance = M9t::Distance.new( 10000 )
|
14
|
-
|
15
|
-
assert_equal( '10 kilometers', distance.to_s( :units => :kilometers,
|
16
|
-
:precision => 0 ) )
|
17
|
-
end
|
18
|
-
|
19
|
-
# Distance
|
20
|
-
def test_distance_nil
|
21
|
-
distance = Metar::Distance.new
|
22
|
-
I18n.locale = :en
|
23
|
-
assert_equal('unknown', distance.to_s)
|
24
|
-
I18n.locale = :it
|
25
|
-
assert_equal('sconosciuto', distance.to_s)
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_distance_with_default_options
|
29
|
-
distance = Metar::Distance.new(123)
|
30
|
-
assert_equal(123, distance.value)
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_distance_setting_options
|
34
|
-
distance = Metar::Distance.new( 123 )
|
35
|
-
|
36
|
-
assert_equal('404ft', distance.to_s( :units => :feet ) )
|
37
|
-
end
|
38
|
-
|
39
|
-
# Speed
|
40
|
-
def test_speed_parse_blank_gives_nil
|
41
|
-
speed = Metar::Speed.parse('')
|
42
|
-
assert_nil(speed)
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_speed_class_options_set
|
46
|
-
assert_not_nil(Metar::Speed.options)
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_speed_parse_without_units
|
50
|
-
speed = Metar::Speed.parse('12')
|
51
|
-
assert_equal(12, speed.to_kilometers_per_hour)
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_speed_parse_kilometers_per_hour
|
55
|
-
speed = Metar::Speed.parse('12KMH')
|
56
|
-
assert_equal(12, speed.to_kilometers_per_hour)
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_speed_parse_knots
|
60
|
-
speed = Metar::Speed.parse('12KT')
|
61
|
-
|
62
|
-
assert_equal(12.0, speed.to_knots)
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_speed_parse_kilometers_per_hour_is_default
|
66
|
-
speed = Metar::Speed.parse( '12' )
|
67
|
-
assert_in_delta( M9t::Speed.kilometers_per_hour( 12 ).to_f, speed.to_f, 0.000001 )
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_speed_parse_explicit_units
|
71
|
-
speed = Metar::Speed.parse( '12MPS' )
|
72
|
-
assert_in_delta( 12, speed.to_f, 0.000001 )
|
73
|
-
|
74
|
-
speed = Metar::Speed.parse( '12KMH' )
|
75
|
-
assert_in_delta( M9t::Speed.kilometers_per_hour( 12 ).to_f, speed.to_f, 0.000001 )
|
76
|
-
|
77
|
-
speed = Metar::Speed.parse( '12KT' )
|
78
|
-
assert_in_delta( M9t::Speed.knots( 12 ).to_f, speed.to_f, 0.000001 )
|
79
|
-
end
|
80
|
-
|
81
|
-
# Temperature
|
82
|
-
def test_temperature_parse_blank_gives_nil
|
83
|
-
temperature = Metar::Temperature.parse('')
|
84
|
-
assert_nil(temperature)
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_temperature_parse_incorrect_gives_nil
|
88
|
-
temperature = Metar::Temperature.parse('XYZ')
|
89
|
-
assert_nil(temperature)
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_temperature_parse_positive
|
93
|
-
temperature = Metar::Temperature.parse('12')
|
94
|
-
assert_equal(12, temperature.value)
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_temperature_parse_negative
|
98
|
-
temperature = Metar::Temperature.parse('M12')
|
99
|
-
assert_equal(-12, temperature.value)
|
100
|
-
end
|
101
|
-
|
102
|
-
# Pressure
|
103
|
-
def test_pressure_parse_hectopascals
|
104
|
-
pressure = Metar::Pressure.parse('Q1002')
|
105
|
-
assert_equal(1.002, pressure.value)
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_pressure_parse_hectopascals_leading_zero
|
109
|
-
pressure = Metar::Pressure.parse('Q0992')
|
110
|
-
assert_equal(0.992, pressure.value)
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_pressure_parse_inches_of_mercury
|
114
|
-
pressure = Metar::Pressure.parse('A3019')
|
115
|
-
assert_in_delta(1.02235, pressure.value, 0.00001)
|
116
|
-
end
|
117
|
-
|
118
|
-
# Wind
|
119
|
-
def test_wind_parse_without_units
|
120
|
-
wind = Metar::Wind.parse( '18012' )
|
121
|
-
|
122
|
-
assert_equal(180, wind.direction.value)
|
123
|
-
assert_equal(12.0, wind.speed.to_kilometers_per_hour)
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_wind_parse_mps
|
127
|
-
wind = Metar::Wind.parse('18012MPS')
|
128
|
-
assert_equal(180, wind.direction.value)
|
129
|
-
assert_equal(12.0, wind.speed.value)
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_wind_parse_kmh
|
133
|
-
wind = Metar::Wind.parse('27012KMH')
|
134
|
-
assert_equal(270, wind.direction.value)
|
135
|
-
assert_equal(12.0, wind.speed.to_kilometers_per_hour)
|
136
|
-
end
|
137
|
-
|
138
|
-
def test_wind_parse_knots
|
139
|
-
wind = Metar::Wind.parse('24006KT')
|
140
|
-
|
141
|
-
assert_equal( 240, wind.direction.value )
|
142
|
-
assert_equal( 6, wind.speed.to_knots )
|
143
|
-
assert_equal( :kilometers_per_hour, wind.options[ :speed_units ] )
|
144
|
-
end
|
145
|
-
|
146
|
-
def test_wind_parse_variable_direction
|
147
|
-
wind = Metar::Wind.parse( 'VRB20KT' )
|
148
|
-
|
149
|
-
assert_equal( :variable_direction, wind.direction )
|
150
|
-
assert_equal( 20, wind.speed.to_knots )
|
151
|
-
assert_equal( '37km/h variable direction', wind.to_s )
|
152
|
-
end
|
153
|
-
|
154
|
-
def test_wind_parse_unknown_direction
|
155
|
-
wind = Metar::Wind.parse('///20KT')
|
156
|
-
assert_equal(:unknown_direction, wind.direction)
|
157
|
-
assert_equal(20, wind.speed.to_knots)
|
158
|
-
assert_equal('37km/h unknown direction', wind.to_s)
|
159
|
-
end
|
160
|
-
|
161
|
-
def test_wind_parse_unknown_direction_and_speed
|
162
|
-
wind = Metar::Wind.parse('/////')
|
163
|
-
assert_equal(:unknown_direction, wind.direction)
|
164
|
-
assert_equal(:unknown, wind.speed)
|
165
|
-
assert_equal('unknown speed unknown direction', wind.to_s)
|
166
|
-
end
|
167
|
-
|
168
|
-
def test_wind_parse_default_output_units_kilometers_per_hour
|
169
|
-
wind = Metar::Wind.parse('18012')
|
170
|
-
assert_equal(:kilometers_per_hour, wind.options[:speed_units])
|
171
|
-
wind = Metar::Wind.parse('18012MPS')
|
172
|
-
assert_equal(:kilometers_per_hour, wind.options[:speed_units])
|
173
|
-
wind = Metar::Wind.parse('27012KMH')
|
174
|
-
assert_equal(:kilometers_per_hour, wind.options[:speed_units])
|
175
|
-
wind = Metar::Wind.parse('24006KT')
|
176
|
-
assert_equal(:kilometers_per_hour, wind.options[:speed_units])
|
177
|
-
wind = Metar::Wind.parse('VRB20KT')
|
178
|
-
assert_equal(:kilometers_per_hour, wind.options[:speed_units])
|
179
|
-
wind = Metar::Wind.parse('///20KT')
|
180
|
-
assert_equal(:kilometers_per_hour, wind.options[:speed_units])
|
181
|
-
end
|
182
|
-
|
183
|
-
# VariableWind
|
184
|
-
def test_variable_wind
|
185
|
-
variable_wind = Metar::VariableWind.parse('350V050')
|
186
|
-
assert_equal(350, variable_wind.direction1.value)
|
187
|
-
assert_equal(50, variable_wind.direction2.value)
|
188
|
-
end
|
189
|
-
|
190
|
-
# Visibility
|
191
|
-
def test_visibility_parse_blank
|
192
|
-
visibility = Metar::Visibility.parse('')
|
193
|
-
assert_nil(visibility)
|
194
|
-
end
|
195
|
-
|
196
|
-
def test_visibility_parse_comparator_defaults_to_nil
|
197
|
-
visibility = Metar::Visibility.parse('0200NDV')
|
198
|
-
assert_nil(visibility.comparator)
|
199
|
-
end
|
200
|
-
|
201
|
-
def test_visibility_parse_9999
|
202
|
-
visibility = Metar::Visibility.parse('9999')
|
203
|
-
assert_equal('more than 10km', visibility.to_s)
|
204
|
-
I18n.locale = :it
|
205
|
-
assert_equal('piú di 10km', visibility.to_s)
|
206
|
-
end
|
207
|
-
|
208
|
-
def test_visibility_parse_ndv
|
209
|
-
visibility = Metar::Visibility.parse('0200NDV')
|
210
|
-
assert_equal(200, visibility.distance.value)
|
211
|
-
assert_nil(visibility.direction)
|
212
|
-
end
|
213
|
-
|
214
|
-
def test_visibility_parse_us_fractions_1_4
|
215
|
-
visibility = Metar::Visibility.parse('1/4SM')
|
216
|
-
assert_equal(M9t::Distance.miles(0.25).value, visibility.distance.value)
|
217
|
-
end
|
218
|
-
|
219
|
-
def test_visibility_parse_us_fractions_2_1_2
|
220
|
-
visibility = Metar::Visibility.parse('2 1/2SM')
|
221
|
-
assert_equal(M9t::Distance.miles(2.5).value, visibility.distance.value)
|
222
|
-
end
|
223
|
-
|
224
|
-
def test_visibility_parse_kilometers
|
225
|
-
visibility = Metar::Visibility.parse('5KM')
|
226
|
-
assert_equal(5000.0, visibility.distance.value)
|
227
|
-
end
|
228
|
-
|
229
|
-
def test_visibility_parse_compass
|
230
|
-
visibility = Metar::Visibility.parse('5NE')
|
231
|
-
assert_equal(5000.0, visibility.distance.value)
|
232
|
-
assert_equal(45.0, visibility.direction.value)
|
233
|
-
assert_equal( '5km NE', visibility.to_s )
|
234
|
-
end
|
235
|
-
|
236
|
-
# RunwayVisibleRange
|
237
|
-
def test_runway_visible_range
|
238
|
-
runway_visible_range = Metar::RunwayVisibleRange.parse('R12/1000N')
|
239
|
-
assert_equal('12', runway_visible_range.designator)
|
240
|
-
assert_equal(1000, runway_visible_range.visibility1.distance.value)
|
241
|
-
assert_equal(:no_change, runway_visible_range.tendency)
|
242
|
-
assert_equal('runway 12: 1000m', runway_visible_range.to_s)
|
243
|
-
end
|
244
|
-
|
245
|
-
def test_runway_visible_range_descriptor_with_letter
|
246
|
-
runway_visible_range = Metar::RunwayVisibleRange.parse('R12R/1000N')
|
247
|
-
assert_equal('12R', runway_visible_range.designator)
|
248
|
-
end
|
249
|
-
|
250
|
-
def test_runway_visible_range_variable
|
251
|
-
runway_visible_range = Metar::RunwayVisibleRange.parse('R10R/1600VP6000FT')
|
252
|
-
assert_equal('10R', runway_visible_range.designator)
|
253
|
-
assert_equal(1600, runway_visible_range.visibility1.distance.to_feet)
|
254
|
-
assert_equal(6000, runway_visible_range.visibility2.distance.to_feet)
|
255
|
-
end
|
256
|
-
|
257
|
-
# WeatherPhenomenon
|
258
|
-
def test_weather_phenomenon_snra
|
259
|
-
phenomenon = Metar::WeatherPhenomenon.parse('SNRA')
|
260
|
-
assert_equal('snow and rain', phenomenon.to_s)
|
261
|
-
I18n.locale = :it
|
262
|
-
assert_equal('neve mista a pioggia', phenomenon.to_s)
|
263
|
-
end
|
264
|
-
|
265
|
-
def test_weather_phenomenon_fzfg
|
266
|
-
freezing_rain = Metar::WeatherPhenomenon.parse('FZFG')
|
267
|
-
assert_equal('freezing fog', freezing_rain.to_s)
|
268
|
-
I18n.locale = :it
|
269
|
-
assert_equal('nebbia ghiacciata', freezing_rain.to_s)
|
270
|
-
end
|
271
|
-
|
272
|
-
def test_weather_phenomenon_with_modifier_plus
|
273
|
-
phenomenon = Metar::WeatherPhenomenon.parse('+RA')
|
274
|
-
assert_equal('heavy', phenomenon.modifier)
|
275
|
-
assert_equal('heavy rain', phenomenon.to_s)
|
276
|
-
I18n.locale = :it
|
277
|
-
assert_equal('pioggia intensa', phenomenon.to_s)
|
278
|
-
end
|
279
|
-
|
280
|
-
def test_weather_phenomenon_with_modifier_minus
|
281
|
-
phenomenon = Metar::WeatherPhenomenon.parse('-RA')
|
282
|
-
assert_equal('light', phenomenon.modifier)
|
283
|
-
assert_equal('light rain', phenomenon.to_s)
|
284
|
-
I18n.locale = :it
|
285
|
-
assert_equal('pioggia leggera', phenomenon.to_s)
|
286
|
-
end
|
287
|
-
|
288
|
-
# SkyCondition
|
289
|
-
def test_sky_condition_nsc
|
290
|
-
sky_condition = Metar::SkyCondition.parse('NSC')
|
291
|
-
assert_nil(sky_condition.quantity)
|
292
|
-
assert_nil(sky_condition.height)
|
293
|
-
assert_equal('clear skies', sky_condition.to_s)
|
294
|
-
I18n.locale = :it
|
295
|
-
assert_equal('cielo sereno', sky_condition.to_s)
|
296
|
-
end
|
297
|
-
|
298
|
-
def test_sky_condition_clr
|
299
|
-
sky_condition = Metar::SkyCondition.parse('CLR')
|
300
|
-
assert_equal('clear skies', sky_condition.to_s)
|
301
|
-
I18n.locale = :it
|
302
|
-
assert_equal('cielo sereno', sky_condition.to_s)
|
303
|
-
end
|
304
|
-
|
305
|
-
def test_sky_condition_broken
|
306
|
-
sky_condition = Metar::SkyCondition.parse('BKN016')
|
307
|
-
assert_equal('broken', sky_condition.quantity)
|
308
|
-
assert_equal(480, sky_condition.height.value)
|
309
|
-
assert_equal('broken cloud at 480m', sky_condition.to_s)
|
310
|
-
I18n.locale = :it
|
311
|
-
assert_equal('nuvolosità parziale a 480m', sky_condition.to_s)
|
312
|
-
end
|
313
|
-
|
314
|
-
def test_sky_condition_few
|
315
|
-
sky_condition = Metar::SkyCondition.parse('FEW016')
|
316
|
-
assert_equal('few', sky_condition.quantity)
|
317
|
-
assert_equal(480, sky_condition.height.value)
|
318
|
-
assert_equal('few clouds at 480m', sky_condition.to_s)
|
319
|
-
I18n.locale = :it
|
320
|
-
assert_equal('poche nuvole a 480m', sky_condition.to_s)
|
321
|
-
end
|
322
|
-
|
323
|
-
def test_sky_condition_ovc
|
324
|
-
sky_condition = Metar::SkyCondition.parse('OVC016')
|
325
|
-
assert_equal('overcast', sky_condition.quantity)
|
326
|
-
assert_equal(480, sky_condition.height.value)
|
327
|
-
assert_equal('overcast at 480m', sky_condition.to_s)
|
328
|
-
I18n.locale = :it
|
329
|
-
assert_equal('chiuso a 480m', sky_condition.to_s)
|
330
|
-
end
|
331
|
-
|
332
|
-
def test_sky_condition_sct
|
333
|
-
sky_condition = Metar::SkyCondition.parse( 'SCT016' )
|
334
|
-
assert_equal('scattered', sky_condition.quantity)
|
335
|
-
assert_equal(480, sky_condition.height.value)
|
336
|
-
assert_equal('scattered cloud at 480m', sky_condition.to_s)
|
337
|
-
I18n.locale = :it
|
338
|
-
assert_equal('nuvole sparse a 480m', sky_condition.to_s)
|
339
|
-
end
|
340
|
-
|
341
|
-
def test_sky_condition_cloud_types_cb
|
342
|
-
sky_condition = Metar::SkyCondition.parse('SCT016CB')
|
343
|
-
assert_equal('scattered', sky_condition.quantity)
|
344
|
-
assert_equal('cumulonimbus', sky_condition.type)
|
345
|
-
assert_equal(480, sky_condition.height.value)
|
346
|
-
assert_equal('scattered cumulonimbus at 480m', sky_condition.to_s)
|
347
|
-
I18n.locale = :it
|
348
|
-
assert_equal('cumulonembi sparsi a 480m', sky_condition.to_s)
|
349
|
-
end
|
350
|
-
|
351
|
-
def test_sky_condition_cloud_types_tcu
|
352
|
-
sky_condition = Metar::SkyCondition.parse('SCT016TCU')
|
353
|
-
assert_equal('scattered', sky_condition.quantity)
|
354
|
-
assert_equal('towering cumulus', sky_condition.type)
|
355
|
-
assert_equal(480, sky_condition.height.value)
|
356
|
-
assert_equal('scattered towering cumulus clouds at 480m', sky_condition.to_s)
|
357
|
-
I18n.locale = :it
|
358
|
-
assert_equal('cumulonembi sparsi a 480m', sky_condition.to_s)
|
359
|
-
end
|
360
|
-
|
361
|
-
# VerticalVisibility
|
362
|
-
def test_vertical_visibility
|
363
|
-
vertical_visibility = Metar::VerticalVisibility.parse('VV001')
|
364
|
-
assert_equal(30, vertical_visibility.value)
|
365
|
-
assert_equal('30m', vertical_visibility.to_s)
|
366
|
-
end
|
367
|
-
|
368
|
-
def test_vertical_visibility_unknown
|
369
|
-
vertical_visibility = Metar::VerticalVisibility.parse('///')
|
370
|
-
assert_nil(vertical_visibility.value)
|
371
|
-
assert_equal('unknown', vertical_visibility.to_s)
|
372
|
-
I18n.locale = :it
|
373
|
-
assert_equal('sconosciuto', vertical_visibility.to_s)
|
374
|
-
end
|
375
|
-
|
376
|
-
end
|
data/test/unit/parser_test.rb
DELETED
@@ -1,144 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require 'metar_test_helper'
|
5
|
-
|
6
|
-
class TestMetarParser < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def setup
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_new
|
12
|
-
raw = Metar::Raw.new('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
|
13
|
-
assert_nothing_thrown do
|
14
|
-
report = Metar::Parser.new(raw)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_time_obligatory
|
19
|
-
assert_raise(Metar::ParseError) {
|
20
|
-
setup_parser('PAIL', "2010/02/06 16:10\nPAIL 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
|
21
|
-
}
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_date
|
25
|
-
parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
|
26
|
-
assert_equal(Date.new(2010, 2, 6), parser.date)
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_observer_real
|
30
|
-
parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
|
31
|
-
assert_equal(:real, parser.observer)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_wind
|
35
|
-
parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
|
36
|
-
assert_in_delta(240, parser.wind.direction.value, 0.0001)
|
37
|
-
assert_in_delta(6, parser.wind.speed.to_knots, 0.0001)
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_variable_wind
|
41
|
-
parser = setup_parser('LIRQ', "2010/02/06 15:20\nLIRQ 061520Z 01007KT 350V050 9999 SCT035 BKN080 08/02 Q1005")
|
42
|
-
assert_in_delta(350, parser.variable_wind.direction1.value, 0.0001)
|
43
|
-
assert_in_delta(50, parser.variable_wind.direction2.value, 0.0001)
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_visibility_miles_and_fractions
|
47
|
-
parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
|
48
|
-
assert_in_delta( 1.75, parser.visibility.distance.to_miles, 0.01 )
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_runway_visible_range
|
52
|
-
parser = setup_parser('ESSB', "2010/02/15 10:20\nESSB 151020Z 26003KT 2000 R12/1000N R30/1500N VV002 M07/M07 Q1013 1271//55")
|
53
|
-
assert_equal(2, parser.runway_visible_range.length)
|
54
|
-
assert_equal('12', parser.runway_visible_range[0].designator)
|
55
|
-
assert_equal(1000, parser.runway_visible_range[0].visibility1.distance.value)
|
56
|
-
assert_equal(:no_change, parser.runway_visible_range[0].tendency)
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_runway_visible_range_defaults_to_empty_array
|
60
|
-
parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
|
61
|
-
assert_equal(0, parser.runway_visible_range.length)
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_runway_visible_range_variable
|
65
|
-
parser = setup_parser('KPDX', "2010/02/15 11:08\nKPDX 151108Z 11006KT 1/4SM R10R/1600VP6000FT FG OVC002 05/05 A3022 RMK AO2")
|
66
|
-
|
67
|
-
assert_equal(1600.0, parser.runway_visible_range[0].visibility1.distance.to_feet)
|
68
|
-
assert_equal(6000.0, parser.runway_visible_range[0].visibility2.distance.to_feet)
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_present_weather
|
72
|
-
parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
|
73
|
-
assert_equal(1, parser.present_weather.length)
|
74
|
-
assert_equal('light', parser.present_weather[0].modifier)
|
75
|
-
assert_equal('snow', parser.present_weather[0].phenomenon)
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_present_weather_defaults_to_empty_array
|
79
|
-
parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
|
80
|
-
assert_equal(0, parser.present_weather.length)
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_sky_conditions
|
84
|
-
parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
|
85
|
-
assert_equal(2, parser.sky_conditions.length)
|
86
|
-
assert_equal('broken', parser.sky_conditions[0].quantity)
|
87
|
-
assert_equal(480, parser.sky_conditions[0].height.value)
|
88
|
-
assert_equal('overcast', parser.sky_conditions[1].quantity)
|
89
|
-
assert_equal(900, parser.sky_conditions[1].height.value)
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_sky_conditions_defaults_to_empty_array
|
93
|
-
parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN M17/M20 A2910 RMK AO2 P0000")
|
94
|
-
assert_equal(0, parser.sky_conditions.length)
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_vertical_visibility
|
98
|
-
parser = setup_parser('CYXS', "2010/02/15 10:34\nCYXS 151034Z AUTO 09003KT 1/8SM FZFG VV001 M03/M03 A3019 RMK SLP263 ICG")
|
99
|
-
assert_equal(30, parser.vertical_visibility.value)
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_temperature_obligatory
|
103
|
-
assert_raise(Metar::ParseError) {
|
104
|
-
setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 A2910 RMK AO2 P0000")
|
105
|
-
}
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_temperature
|
109
|
-
parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
|
110
|
-
assert_equal(-17, parser.temperature.value)
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_dew_point
|
114
|
-
parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
|
115
|
-
assert_equal(-20, parser.dew_point.value)
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_sea_level_pressure
|
119
|
-
parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
|
120
|
-
assert_equal(29.10, parser.sea_level_pressure.to_inches_of_mercury)
|
121
|
-
end
|
122
|
-
|
123
|
-
def test_remarks
|
124
|
-
parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
|
125
|
-
assert_instance_of(Array, parser.remarks)
|
126
|
-
assert_equal(2, parser.remarks.length)
|
127
|
-
assert_equal('AO2', parser.remarks[0])
|
128
|
-
assert_equal('P0000', parser.remarks[1])
|
129
|
-
end
|
130
|
-
|
131
|
-
def test_remarks_defaults_to_empty_array
|
132
|
-
parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910")
|
133
|
-
assert_instance_of(Array, parser.remarks)
|
134
|
-
assert_equal(0, parser.remarks.length)
|
135
|
-
end
|
136
|
-
|
137
|
-
private
|
138
|
-
|
139
|
-
def setup_parser(cccc, metar)
|
140
|
-
raw = Metar::Raw.new(cccc, metar)
|
141
|
-
Metar::Parser.new(raw)
|
142
|
-
end
|
143
|
-
|
144
|
-
end
|