metar-parser 1.3.2 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/metar/data/distance.rb +3 -3
- data/lib/metar/data/visibility.rb +3 -3
- data/lib/metar/version.rb +2 -2
- data/spec/data/distance_spec.rb +11 -2
- metadata +19 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebd55121470cf007f6d6207ab7776f73204fa97c
|
4
|
+
data.tar.gz: 3a05ca5f33b2f3dc93e57395a5a25e8b897fee54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6cd33e83acff74785d9031c3d660bbedc2f719f2a923e790f647018877dfcc6f57a38923dfa37a06845a5f79231774bb57561a755025380c73dd1ad82a28d4c
|
7
|
+
data.tar.gz: 63be9536d437979c6ccaf5274ef3f98d4fdd7496d1a6ddb810bc516e80ed1c466f0d829be75688c8018848fe3727286723590c648c63f178470dfd0082dcb59b
|
data/lib/metar/data/distance.rb
CHANGED
@@ -2,11 +2,11 @@ require "i18n"
|
|
2
2
|
require "m9t"
|
3
3
|
|
4
4
|
class Metar::Data::Distance < M9t::Distance
|
5
|
-
attr_accessor :
|
5
|
+
attr_accessor :serialization_units
|
6
6
|
|
7
7
|
# nil is taken to mean 'data unavailable'
|
8
8
|
def initialize(meters = nil)
|
9
|
-
@
|
9
|
+
@serialization_units = :meters
|
10
10
|
if meters
|
11
11
|
super
|
12
12
|
else
|
@@ -17,7 +17,7 @@ class Metar::Data::Distance < M9t::Distance
|
|
17
17
|
# Handles nil case differently to M9t::Distance
|
18
18
|
def to_s(options = {})
|
19
19
|
options = {
|
20
|
-
units:
|
20
|
+
units: serialization_units,
|
21
21
|
precision: 0,
|
22
22
|
abbreviated: true,
|
23
23
|
}.merge(options)
|
@@ -17,20 +17,20 @@ class Metar::Data::Visibility < Metar::Data::Base
|
|
17
17
|
if m2
|
18
18
|
miles = m2[1].to_f + m2[3].to_f / m2[4].to_f
|
19
19
|
distance = Metar::Data::Distance.miles(miles)
|
20
|
-
distance.
|
20
|
+
distance.serialization_units = :miles
|
21
21
|
return new(raw, distance: distance)
|
22
22
|
end
|
23
23
|
|
24
24
|
m3 = raw.match(/^(\d+)SM$/) # US
|
25
25
|
if m3
|
26
26
|
distance = Metar::Data::Distance.miles(m3[1].to_f)
|
27
|
-
distance.
|
27
|
+
distance.serialization_units = :miles
|
28
28
|
return new(raw, distance: distance)
|
29
29
|
end
|
30
30
|
|
31
31
|
if raw == 'M1/4SM' # US
|
32
32
|
distance = Metar::Data::Distance.miles(0.25)
|
33
|
-
distance.
|
33
|
+
distance.serialization_units = :miles
|
34
34
|
return new(raw, distance: distance, comparator: :less_than)
|
35
35
|
end
|
36
36
|
|
data/lib/metar/version.rb
CHANGED
data/spec/data/distance_spec.rb
CHANGED
@@ -8,14 +8,23 @@ describe Metar::Data::Distance do
|
|
8
8
|
|
9
9
|
context '#value' do
|
10
10
|
it 'treats the parameter as meters' do
|
11
|
-
expect(subject.units).to eq(:meters)
|
12
11
|
expect(subject.value).to eq(12_345.6789)
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
16
15
|
context '#to_s' do
|
17
16
|
it 'should default to meters' do
|
18
|
-
expect(subject.to_s).to match(
|
17
|
+
expect(subject.to_s).to match(/\A\d+m\z/)
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when overriding the serialization_units' do
|
21
|
+
subject do
|
22
|
+
super().tap { |d| d.serialization_units = :miles }
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'uses the override' do
|
26
|
+
expect(subject.to_s).to match(/\A\d+mi\z/)
|
27
|
+
end
|
19
28
|
end
|
20
29
|
|
21
30
|
context 'when <= 0.5' 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
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Yates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -229,7 +229,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
229
229
|
requirements:
|
230
230
|
- - ">="
|
231
231
|
- !ruby/object:Gem::Version
|
232
|
-
version: 2.
|
232
|
+
version: 2.2.0
|
233
233
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
234
234
|
requirements:
|
235
235
|
- - ">="
|
@@ -237,28 +237,28 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
237
|
version: '0'
|
238
238
|
requirements: []
|
239
239
|
rubyforge_project: nowarning
|
240
|
-
rubygems_version: 2.5
|
240
|
+
rubygems_version: 2.4.5
|
241
241
|
signing_key:
|
242
242
|
specification_version: 4
|
243
243
|
summary: A Ruby gem for worldwide weather reports
|
244
244
|
test_files:
|
245
|
-
- spec/
|
246
|
-
- spec/parser_spec.rb
|
247
|
-
- spec/data/runway_visible_range_spec.rb
|
248
|
-
- spec/data/weather_phenomenon_spec.rb
|
249
|
-
- spec/data/temperature_spec.rb
|
250
|
-
- spec/data/pressure_spec.rb
|
251
|
-
- spec/data/remark_spec.rb
|
245
|
+
- spec/station_spec.rb
|
252
246
|
- spec/data/speed_spec.rb
|
253
|
-
- spec/data/
|
254
|
-
- spec/data/
|
255
|
-
- spec/data/visibility_spec.rb
|
247
|
+
- spec/data/density_altitude_spec.rb
|
248
|
+
- spec/data/sky_condition_spec.rb
|
256
249
|
- spec/data/distance_spec.rb
|
257
|
-
- spec/data/
|
250
|
+
- spec/data/remark_spec.rb
|
251
|
+
- spec/data/temperature_spec.rb
|
252
|
+
- spec/data/weather_phenomenon_spec.rb
|
258
253
|
- spec/data/lightning_spec.rb
|
259
|
-
- spec/data/sky_condition_spec.rb
|
260
|
-
- spec/data/density_altitude_spec.rb
|
261
254
|
- spec/data/variable_wind_spec.rb
|
262
|
-
- spec/
|
255
|
+
- spec/data/visibility_remark_spec.rb
|
256
|
+
- spec/data/wind_spec.rb
|
257
|
+
- spec/data/pressure_spec.rb
|
258
|
+
- spec/data/runway_visible_range_spec.rb
|
259
|
+
- spec/data/vertical_visibility_spec.rb
|
260
|
+
- spec/data/visibility_spec.rb
|
261
|
+
- spec/i18n_spec.rb
|
263
262
|
- spec/raw_spec.rb
|
264
|
-
- spec/
|
263
|
+
- spec/parser_spec.rb
|
264
|
+
- spec/report_spec.rb
|