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.
@@ -1,37 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'metar_test_helper'
4
-
5
- class TestMetarRaw < Test::Unit::TestCase
6
-
7
- def setup
8
- end
9
-
10
- def test_fetch
11
- raw = Metar::Raw.fetch('LIRQ')
12
- assert_instance_of(String, raw)
13
- end
14
-
15
- def test_new
16
- assert_nothing_thrown do
17
- raw = Metar::Raw.new('LIRQ')
18
- end
19
- end
20
-
21
- def test_cccc
22
- raw = Metar::Raw.new('LIRQ')
23
- assert_equal('LIRQ', raw.cccc)
24
- end
25
-
26
- def test_time
27
- raw = Metar::Raw.new('LIRQ')
28
- assert_instance_of(Time, raw.time)
29
- assert_equal(2010, raw.time.year)
30
- end
31
-
32
- def test_metar
33
- raw = Metar::Raw.new('LIRQ')
34
- assert_instance_of(String, raw.metar)
35
- end
36
-
37
- end
@@ -1,105 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require 'metar_test_helper'
5
-
6
- class TestMetarReport < Test::Unit::TestCase
7
- def setup
8
- end
9
-
10
- def test_name
11
- report = setup_report('LIRQ', "2010/02/06 15:20\nLIRQ 061520Z 01007KT 350V050 9999 SCT035 BKN080 08/02 Q1005")
12
- assert_equal('Firenze / Peretola', report.station_name)
13
- end
14
-
15
- def test_date
16
- report = setup_report('LIRQ', "2010/02/06 15:20\nLIRQ 061520Z 01007KT 350V050 9999 SCT035 BKN080 08/02 Q1005")
17
- assert_equal('06/02/2010', report.date)
18
- end
19
-
20
- def test_time
21
- report = setup_report('LIRQ', "2010/02/06 15:20\nLIRQ 061520Z 01007KT 350V050 9999 SCT035 BKN080 08/02 Q1005")
22
- assert_equal('15:20', report.time)
23
- end
24
-
25
- def test_wind_knots
26
- report = setup_report('LIRQ', "2010/02/06 15:20\nLIRQ 061520Z 01007KT 350V050 9999 SCT035 BKN080 08/02 Q1005")
27
- assert_equal('13km/h N', report.wind)
28
- end
29
-
30
- def test_variable_wind
31
- report = setup_report('LIRQ', "2010/02/06 15:20\nLIRQ 061520Z 01007KT 350V050 9999 SCT035 BKN080 08/02 Q1005")
32
- I18n.locale = :en
33
- assert_equal('350 degrees - 50 degrees', report.variable_wind)
34
- end
35
-
36
- def test_visibility
37
- report = setup_report('LIRQ', "2010/02/06 15:20\nLIRQ 061520Z 01007KT 350V050 9999 SCT035 BKN080 08/02 Q1005")
38
- assert_equal('more than 10km', report.visibility)
39
- end
40
-
41
- def test_runway_visible_range
42
- report = setup_report('ESSB', "2010/02/15 10:20\nESSB 151020Z 26003KT 2000 R12/1000N R30/1500N VV002 M07/M07 Q1013 1271//55")
43
- I18n.locale = :en
44
- assert_equal('runway 12: 1000m, runway 30: 1500m', report.runway_visible_range)
45
- I18n.locale = :it
46
- assert_equal('pista 12: 1000m, pista 30: 1500m', report.runway_visible_range)
47
- end
48
-
49
- def test_runway_visible_range_variable
50
- report = setup_report('KPDX', "2010/02/15 11:08\nKPDX 151108Z 11006KT 1/4SM R10R/1600VP6000FT FG OVC002 05/05 A3022 RMK AO2")
51
- I18n.locale = :en
52
- assert_equal('runway 10R: from 1600ft to more than 6000ft', report.runway_visible_range)
53
- end
54
-
55
- def test_present_weather
56
- report = setup_report('DAAS', "2010/02/15 10:00\nDAAS 151000Z 16012KT 9999 -RA FEW010 BKN026 06/05 Q1006")
57
- assert_equal('light rain', report.present_weather)
58
- I18n.locale = :it
59
- assert_equal('pioggia leggera', report.present_weather)
60
- end
61
-
62
- def test_sky_conditions
63
- report = setup_report('LIRQ', "2010/02/06 15:20\nLIRQ 061520Z 01007KT 350V050 9999 SCT035 BKN080 08/02 Q1005")
64
- I18n.locale = :en
65
- assert_equal('scattered cloud at 1050m, broken cloud at 2400m', report.sky_conditions)
66
- I18n.locale = :it
67
- assert_equal('nuvole sparse a 1050m, nuvolosità parziale a 2400m', report.sky_conditions)
68
- end
69
-
70
- def test_vertical_visibility
71
- report = setup_report('CYXS', "2010/02/15 10:34\nCYXS 151034Z AUTO 09003KT 1/8SM FZFG VV001 M03/M03 A3019 RMK SLP263 ICG")
72
- assert_equal('30m', report.vertical_visibility)
73
- end
74
-
75
- def test_temperature
76
- report = setup_report('LIRQ', "2010/02/06 15:20\nLIRQ 061520Z 01007KT 350V050 9999 SCT035 BKN080 08/02 Q1005")
77
- assert_equal('8°C', report.temperature)
78
- end
79
-
80
- def test_dew_point
81
- report = setup_report('LIRQ', "2010/02/06 15:20\nLIRQ 061520Z 01007KT 350V050 9999 SCT035 BKN080 08/02 Q1005")
82
- assert_equal( '2°C', report.dew_point )
83
- end
84
-
85
- def test_sea_level_pressure
86
- report = setup_report('LIRQ', "2010/02/06 15:20\nLIRQ 061520Z 01007KT 350V050 9999 SCT035 BKN080 08/02 Q1005")
87
- assert_equal('1.00500 bar', report.sea_level_pressure)
88
- end
89
-
90
- def test_to_s
91
- report = setup_report('LIRQ', "2010/02/06 15:20\nLIRQ 061520Z 01007KT 350V050 9999 SCT035 BKN080 08/02 Q1005")
92
- Metar::Report.attributes -= [:station_code, :variable_wind, :observer, :remarks]
93
- I18n.locale = :en
94
- assert_equal( "name: Firenze / Peretola\ncountry: Italy\ntime: 15:20\nwind: 13km/h N\nvisibility: more than 10km\nsky: broken cloud\ntemperature: 8°C", report.to_s )
95
- end
96
-
97
- private
98
-
99
- def setup_report(cccc, metar)
100
- raw = Metar::Raw.new(cccc, metar)
101
- parser = Metar::Parser.new(raw)
102
- Metar::Report.new(parser)
103
- end
104
-
105
- end
@@ -1,88 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'metar_test_helper'
4
-
5
- class TestStation < Test::Unit::TestCase
6
-
7
- def setup
8
- end
9
-
10
- def test_class_method_exist_on_existing_station
11
- assert Metar::Station.exist?('LIRQ')
12
- end
13
-
14
- def test_class_method_exist_on_non_existant_station
15
- assert (not Metar::Station.exist?('X'))
16
- end
17
-
18
- def test_find_by_cccc_on_existing_station
19
- assert_not_nil Metar::Station.find_by_cccc('LIRQ')
20
- end
21
-
22
- def test_find_by_cccc_works_after_station_all
23
- Metar::Station.all
24
- assert_not_nil Metar::Station.find_by_cccc('LIRQ')
25
- end
26
-
27
- def test_to_latitude_incorrect_gives_nil
28
- assert_nil Metar::Station.to_latitude('23-15')
29
- end
30
-
31
- def test_to_latitude_n
32
- assert_equal 43.8, Metar::Station.to_latitude('43-48N')
33
- end
34
-
35
- def test_to_latitude_s
36
- assert_equal -23.25, Metar::Station.to_latitude('23-15S')
37
- end
38
-
39
- def test_to_longitude_e
40
- assert_equal 11.2, Metar::Station.to_longitude('11-12E')
41
- end
42
-
43
- def test_to_longitude_w
44
- assert_equal -11.2, Metar::Station.to_longitude('11-12W')
45
- end
46
-
47
- def test_instantiation_sets_cccc
48
- station = Metar::Station.new('LIRQ')
49
- assert_equal 'LIRQ', station.cccc
50
- end
51
-
52
- def test_simple_instantiation_doesnt_cause_loading
53
- station = Metar::Station.new('LIRQ')
54
- assert (not station.loaded?)
55
- end
56
-
57
- def test_calling_attributes_causes_loading
58
- station = Metar::Station.new('LIRQ')
59
- station.name
60
- assert station.loaded?
61
- end
62
-
63
- def test_name
64
- station = Metar::Station.new('LIRQ')
65
- assert_equal 'Firenze / Peretola', station.name
66
- end
67
-
68
- def test_state
69
- station = Metar::Station.new('LIRQ')
70
- assert_equal '', station.state
71
- end
72
-
73
- def test_country
74
- station = Metar::Station.new('LIRQ')
75
- assert_equal 'Italy', station.country
76
- end
77
-
78
- def test_latitude_is_a_decimal_number
79
- station = Metar::Station.new('LIRQ')
80
- assert_equal station.latitude.to_s, station.latitude.to_f.to_s
81
- end
82
-
83
- def test_longitude_is_a_decimal_number
84
- station = Metar::Station.new('LIRQ')
85
- assert_equal station.longitude.to_s, station.longitude.to_f.to_s
86
- end
87
-
88
- end