metar-parser 1.1.3 → 1.1.4
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 +6 -5
- data/lib/metar/data.rb +6 -0
- data/lib/metar/version.rb +3 -4
- data/spec/unit/wind_spec.rb +12 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -32,7 +32,7 @@ Hello World
|
|
32
32
|
This prints the latest weather report for Portland International Airport:
|
33
33
|
|
34
34
|
```ruby
|
35
|
-
station = Metar::Station.find_by_cccc(
|
35
|
+
station = Metar::Station.find_by_cccc('KPDX')
|
36
36
|
puts station.report.to_s
|
37
37
|
```
|
38
38
|
|
@@ -48,13 +48,13 @@ puts Metar::Station.countries
|
|
48
48
|
Find a country's weather stations:
|
49
49
|
|
50
50
|
```ruby
|
51
|
-
spanish = Metar::Station.find_all_by_country(
|
51
|
+
spanish = Metar::Station.find_all_by_country('Spain')
|
52
52
|
```
|
53
53
|
|
54
54
|
Get The Data
|
55
55
|
------------
|
56
56
|
```ruby
|
57
|
-
station = Metar::Station.find_by_cccc(
|
57
|
+
station = Metar::Station.find_by_cccc('KPDX')
|
58
58
|
parser = station.parser
|
59
59
|
puts parser.temperature.value
|
60
60
|
```
|
@@ -63,8 +63,8 @@ Use Your Own Raw Data
|
|
63
63
|
---------------------
|
64
64
|
```ruby
|
65
65
|
metar_string = "KHWD 280554Z AUTO 29007KT 10SM OVC008 14/12 A3002 RMK AO2 SLP176 T01390117 10211\n"
|
66
|
-
raw = Metar::Raw::Data.new(
|
67
|
-
parser = Metar::Parser.new(
|
66
|
+
raw = Metar::Raw::Data.new(metar_string)
|
67
|
+
parser = Metar::Parser.new(raw)
|
68
68
|
```
|
69
69
|
|
70
70
|
Compliance
|
@@ -96,6 +96,7 @@ Contributors
|
|
96
96
|
|
97
97
|
* [Joe Yates](https://github.com/joeyates)
|
98
98
|
* [Derek Johnson](https://github.com/EpicDraws)
|
99
|
+
* [Florian Egermann and Mathias Wollin](https://github.com/math)
|
99
100
|
|
100
101
|
Alternative Software
|
101
102
|
====================
|
data/lib/metar/data.rb
CHANGED
@@ -110,6 +110,12 @@ module Metar
|
|
110
110
|
new( Direction.new( $1 ),
|
111
111
|
Speed.parse( $2 + $4 ),
|
112
112
|
Speed.parse( $3 ) )
|
113
|
+
when s =~ /^VRB(\d{2})G(\d{2,3})(|MPS|KMH|KT)$/
|
114
|
+
speed = $1 + $3
|
115
|
+
gusts = $2 + $3
|
116
|
+
new( :variable_direction,
|
117
|
+
Speed.parse(speed),
|
118
|
+
Speed.parse(gusts))
|
113
119
|
when s =~ /^VRB(\d{2}(|MPS|KMH|KT))$/
|
114
120
|
new( :variable_direction,
|
115
121
|
Speed.parse($1))
|
data/lib/metar/version.rb
CHANGED
data/spec/unit/wind_spec.rb
CHANGED
@@ -34,25 +34,36 @@ describe Metar::Wind do
|
|
34
34
|
context '.parse' do
|
35
35
|
|
36
36
|
[
|
37
|
+
# Direction and speed
|
37
38
|
[ 'treats 5 digits as degrees and kilometers per hour', '12345', [ 123.0, 12.50, nil ] ],
|
38
39
|
[ 'understands 5 digits + KMH', '12345KMH', [ 123.0, 12.50, nil ] ],
|
39
40
|
[ 'understands 5 digits + MPS', '12345MPS', [ 123.0, 45.00, nil ] ],
|
40
41
|
[ 'understands 5 digits + KT', '12345KT', [ 123.0, 23.15, nil ] ],
|
41
42
|
[ 'rounds 360 down to 0', '36045KT', [ 0.0, 23.15, nil ] ],
|
42
43
|
[ 'returns nil for directions outside 0 to 360', '88845KT', [ nil, nil, nil ] ],
|
44
|
+
# +gusts
|
43
45
|
[ 'understands 5 digits + G + 2 digits', '12345G67', [ 123.0, 12.50, 18.61 ] ],
|
44
|
-
[ 'understands 5 digits + G + 2 digits + MPS', '12345G67MPS', [ 123.0, 45.00, 67.00 ] ],
|
45
46
|
[ 'understands 5 digits + G + 2 digits + KMH', '12345G67KMH', [ 123.0, 12.50, 18.61 ] ],
|
47
|
+
[ 'understands 5 digits + G + 2 digits + MPS', '12345G67MPS', [ 123.0, 45.00, 67.00 ] ],
|
46
48
|
[ 'understands 5 digits + G + 2 digits + KT', '12345G67KT', [ 123.0, 23.15, 34.47 ] ],
|
49
|
+
# Variable direction
|
47
50
|
[ 'understands VRB + 2 digits' 'VRB12', [ :variable_direction, 3.33, nil ] ],
|
48
51
|
[ 'understands VRB + 2 digits + KMH', 'VRB12KMH', [ :variable_direction, 3.33, nil ] ],
|
49
52
|
[ 'understands VRB + 2 digits + MPS', 'VRB12MPS', [ :variable_direction, 12.00, nil ] ],
|
50
53
|
[ 'understands VRB + 2 digits + KT', 'VRB12KT', [ :variable_direction, 6.17, nil ] ],
|
54
|
+
# + gusts
|
55
|
+
[ 'understands VRB + 2 digits + G + 2 digits', 'VRB45G67', [ :variable_direction, 12.50, 18.61 ] ],
|
56
|
+
[ 'understands VRB + 2 digits + G + 2 digits + KMH', 'VRB45G67KMH', [ :variable_direction, 12.50, 18.61 ] ],
|
57
|
+
[ 'understands VRB + 2 digits + G + 2 digits + MPS', 'VRB45G67MPS', [ :variable_direction, 45.00, 67.00 ] ],
|
58
|
+
[ 'understands VRB + 2 digits + G + 2 digits + KT', 'VRB45G67KT', [ :variable_direction, 23.15, 34.47 ] ],
|
59
|
+
# Unknown direction
|
51
60
|
[ 'understands /// + 2 digits', '///12', [ :unknown_direction, 3.33, nil ] ],
|
52
61
|
[ 'understands /// + 2 digits + KMH', '///12KMH', [ :unknown_direction, 3.33, nil ] ],
|
53
62
|
[ 'understands /// + 2 digits + MPS', '///12MPS', [ :unknown_direction, 12.00, nil ] ],
|
54
63
|
[ 'understands /// + 2 digits + KT', '///12KT', [ :unknown_direction, 6.17, nil ] ],
|
64
|
+
# Unknown direction and speed
|
55
65
|
[ 'understands /////', '/////', [ :unknown_direction, :unknown_speed, nil ] ],
|
66
|
+
# Bad data
|
56
67
|
[ 'returns nil for badly formatted values', 'XYZ12KT', [ nil, nil, nil ] ],
|
57
68
|
[ 'returns nil for nil', nil, [ nil, nil, nil ] ],
|
58
69
|
].each do | docstring, raw, expected |
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metar-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -194,7 +194,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
194
194
|
version: '0'
|
195
195
|
segments:
|
196
196
|
- 0
|
197
|
-
hash:
|
197
|
+
hash: 256504047505018704
|
198
198
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
199
199
|
none: false
|
200
200
|
requirements:
|
@@ -203,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
203
|
version: '0'
|
204
204
|
segments:
|
205
205
|
- 0
|
206
|
-
hash:
|
206
|
+
hash: 256504047505018704
|
207
207
|
requirements: []
|
208
208
|
rubyforge_project: nowarning
|
209
209
|
rubygems_version: 1.8.23
|