metar-parser 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/metar/data/wind.rb +9 -2
- data/lib/metar/parser.rb +1 -1
- data/lib/metar/version.rb +1 -1
- data/spec/parser_spec.rb +26 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8669ee0013495030113f9eedef95ba35eef327aff2ba3971bc0bab985a88a522
|
4
|
+
data.tar.gz: 4cfb87824178aff9b7ba87dd0cb461c4426adc94a99e7ef1ee683351695361d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de8ac448ba1f2bbe8a9f2bd4ee826bae4a915eddaa5440bc75e52464aefa11805070956bcd3cc1b8cb2182682cda9ec21f86b53118a9ffec02287d446fab7df1
|
7
|
+
data.tar.gz: ff67729c9b93cde143b2de70b07b697ac10db14e8ef8554e911c8d5549df845f8f18d40a093cc0a8056afc4b7c8f9b9d53412b109721cf65db4ed47ef2f309c3
|
data/README.md
CHANGED
@@ -91,7 +91,7 @@ Translations are available for the following languages (and region):
|
|
91
91
|
* :'en-US'
|
92
92
|
* :it
|
93
93
|
* :'pt-BR'
|
94
|
-
|
94
|
+
|
95
95
|
Thanks to the I18n gem's fallback mechanism, under regional locales, language generic
|
96
96
|
translations will be used if a region-specific translation is not available.
|
97
97
|
I.e.
|
data/lib/metar/data/wind.rb
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
class Metar::Data::Wind < Metar::Data::Base
|
2
|
-
def self.parse(raw)
|
2
|
+
def self.parse(raw, strict: false)
|
3
3
|
return nil if raw.nil?
|
4
4
|
|
5
|
-
|
5
|
+
plain_match =
|
6
|
+
if strict
|
7
|
+
/^(\d{3})(\d{2}(|MPS|KMH|KT))$/
|
8
|
+
else
|
9
|
+
/^(\d{3})(\d{2,3}(|MPS|KMH|KT))$/
|
10
|
+
end
|
11
|
+
|
12
|
+
m1 = raw.match(plain_match)
|
6
13
|
if m1
|
7
14
|
return nil if m1[1].to_i > 360
|
8
15
|
return new(
|
data/lib/metar/parser.rb
CHANGED
data/lib/metar/version.rb
CHANGED
data/spec/parser_spec.rb
CHANGED
@@ -132,11 +132,33 @@ describe Metar::Parser do
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
|
-
|
136
|
-
|
135
|
+
context 'wind' do
|
136
|
+
it 'is parsed' do
|
137
|
+
parser = setup_parser("PAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
|
138
|
+
|
139
|
+
expect(parser.wind.direction.value).to be_within(0.0001).of(240)
|
140
|
+
expect(parser.wind.speed.to_knots).to be_within(0.0001).of(6)
|
141
|
+
end
|
137
142
|
|
138
|
-
|
139
|
-
|
143
|
+
context 'in strict mode' do
|
144
|
+
before do
|
145
|
+
Metar::Parser.compliance = :strict
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'more than 5 digits fails' do
|
149
|
+
expect do
|
150
|
+
setup_parser('KSEE 181947Z 000000KT 10SM SKC 22/10 A2999')
|
151
|
+
end.to raise_error(Metar::ParseError, /Unparsable/)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'in loose mode' do
|
156
|
+
it 'more than 5 digits is parsed' do
|
157
|
+
parser = setup_parser('KSEE 181947Z 000000KT 10SM SKC 22/10 A2999')
|
158
|
+
expect(parser.wind.direction.value).to eq(0.0)
|
159
|
+
expect(parser.visibility.distance.value).to be_within(1).of(16093)
|
160
|
+
end
|
161
|
+
end
|
140
162
|
end
|
141
163
|
|
142
164
|
it 'variable_wind' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metar-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Yates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|