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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2221be718069fb9c9ed4791bf08348dd5faf5aaad09b1d3d0275cf74e2f3641
4
- data.tar.gz: 67b70702eb6cf48f4f8e1629c259728775dfb3a4a87aadee70f19951708aca01
3
+ metadata.gz: 8669ee0013495030113f9eedef95ba35eef327aff2ba3971bc0bab985a88a522
4
+ data.tar.gz: 4cfb87824178aff9b7ba87dd0cb461c4426adc94a99e7ef1ee683351695361d6
5
5
  SHA512:
6
- metadata.gz: 71168e1083737aab11b6af0bf0f8ecfd62109896805acc79aa8a15e7d78a217aca97902f657ae1c004f5047acfe478a185cd3c13ba23b034e35d62f7571390f3
7
- data.tar.gz: bea84d9351eaf9facc647b6ee78fc0fd964d224818af062dd729c3f7ad42b18bc56315d23a0d548b7585f35fcc19b0a5636470e78f512a179bbe77ce29464303
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.
@@ -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
- m1 = raw.match(/^(\d{3})(\d{2}(|MPS|KMH|KT))$/)
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(
@@ -191,7 +191,7 @@ module Metar
191
191
  end
192
192
 
193
193
  def seek_wind
194
- @wind = Metar::Data::Wind.parse(@chunks[0])
194
+ @wind = Metar::Data::Wind.parse(@chunks[0], strict: strict?)
195
195
  @chunks.shift if @wind
196
196
  @wind
197
197
  end
@@ -2,7 +2,7 @@ module Metar
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 4
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -132,11 +132,33 @@ describe Metar::Parser do
132
132
  end
133
133
  end
134
134
 
135
- it 'wind' do
136
- parser = setup_parser("PAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
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
- expect(parser.wind.direction.value).to be_within(0.0001).of(240)
139
- expect(parser.wind.speed.to_knots).to be_within(0.0001).of(6)
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.2
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-01-05 00:00:00.000000000 Z
11
+ date: 2019-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n