metar-parser 1.1.5 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/metar/data.rb +1 -0
- data/lib/metar/version.rb +1 -1
- data/locales/en.yml +13 -3
- data/spec/unit/{locales_spec.rb → i18n_spec.rb} +8 -1
- data/spec/unit/sky_condition_spec.rb +30 -34
- metadata +6 -6
data/lib/metar/data.rb
CHANGED
@@ -5,6 +5,7 @@ require 'm9t'
|
|
5
5
|
module Metar
|
6
6
|
locales_path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'locales'))
|
7
7
|
I18n.load_path += Dir.glob("#{locales_path}/*.yml")
|
8
|
+
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
|
8
9
|
|
9
10
|
class Distance < M9t::Distance
|
10
11
|
attr_accessor :units
|
data/lib/metar/version.rb
CHANGED
data/locales/en.yml
CHANGED
@@ -52,14 +52,16 @@ en:
|
|
52
52
|
clear skies: clear skies
|
53
53
|
broken: broken cloud
|
54
54
|
broken cumulonimbus: broken cumulonimbus
|
55
|
-
broken towering cumulus: broken towering cumulus
|
55
|
+
broken towering cumulus: broken towering cumulus
|
56
56
|
few: few clouds
|
57
57
|
few cumulonimbus: few cumulonimbus
|
58
|
-
few towering cumulus: few towering cumulus
|
58
|
+
few towering cumulus: few towering cumulus
|
59
59
|
scattered: scattered cloud
|
60
60
|
scattered cumulonimbus: scattered cumulonimbus
|
61
|
-
scattered towering cumulus: scattered towering cumulus
|
61
|
+
scattered towering cumulus: scattered towering cumulus
|
62
62
|
overcast: overcast
|
63
|
+
overcast cumulonimbus: overcast cumulonimbus
|
64
|
+
overcast towering cumulus: overcast towering cumulus
|
63
65
|
runway_visible_range:
|
64
66
|
title: runway visible range
|
65
67
|
runway: runway
|
@@ -159,3 +161,11 @@ en:
|
|
159
161
|
remarks:
|
160
162
|
title: remarks
|
161
163
|
|
164
|
+
en-US:
|
165
|
+
metar:
|
166
|
+
sky_conditions:
|
167
|
+
clear skies: clear skies
|
168
|
+
broken: broken clouds
|
169
|
+
broken cumulonimbus: broken cumulonimbus clouds
|
170
|
+
broken towering cumulus: broken towering cumulus clouds
|
171
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe I18n do
|
4
4
|
it 'adds our locales to the load path' do
|
5
5
|
project_root = File.expand_path('../..', File.dirname(__FILE__))
|
6
6
|
english_path = File.join(project_root, 'locales', 'en.yml')
|
@@ -11,5 +11,12 @@ describe 'locales' do
|
|
11
11
|
expect(I18n.load_path).to include(italian_path)
|
12
12
|
expect(I18n.load_path).to include(german_path)
|
13
13
|
end
|
14
|
+
|
15
|
+
it 'falls back do the language translation when a region-specific translation is not available' do
|
16
|
+
old_locale = I18n.locale
|
17
|
+
I18n.locale = :'en-FOO'
|
18
|
+
expect(I18n.t('metar.altitude.at')).to eq('at')
|
19
|
+
I18n.locale = old_locale
|
20
|
+
end
|
14
21
|
end
|
15
22
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
load File.expand_path( '../spec_helper.rb', File.dirname(__FILE__) )
|
3
3
|
|
4
|
-
RSpec::Matchers.define :be_sky_condition do |
|
5
|
-
match do |
|
4
|
+
RSpec::Matchers.define :be_sky_condition do |quantity, height, type|
|
5
|
+
match do |sk|
|
6
6
|
if sk.nil? && quantity == :expect_nil
|
7
7
|
true
|
8
8
|
elsif sk.nil? && quantity != :expect_nil
|
@@ -20,56 +20,52 @@ RSpec::Matchers.define :be_sky_condition do | quantity, height, type |
|
|
20
20
|
end
|
21
21
|
|
22
22
|
describe Metar::SkyCondition do
|
23
|
-
|
24
23
|
context '.parse' do
|
25
|
-
|
26
24
|
[
|
27
|
-
[
|
28
|
-
[
|
29
|
-
[
|
30
|
-
[
|
31
|
-
[
|
32
|
-
[
|
33
|
-
[
|
34
|
-
].each do |
|
25
|
+
['understands clear skies codes', 'NSC', [nil, nil, nil]],
|
26
|
+
['quantity + height', 'BKN12', ['broken', 365.76, nil]],
|
27
|
+
['quantity + height + type', 'BKN12CB', ['broken', 365.76, 'cumulonimbus']],
|
28
|
+
['quantity + ///', 'BKN///', ['broken', nil, nil]],
|
29
|
+
['quantity + height + ///', 'FEW038///',['few', 1158.24, nil]],
|
30
|
+
['cumulonimbus only', 'CB', [nil, nil, 'cumulonimbus']], # seems non-standard, but occurs
|
31
|
+
['returns nil for unmatched', 'FUBAR', [:expect_nil, nil, nil]],
|
32
|
+
].each do |docstring, raw, expected|
|
35
33
|
example docstring do
|
36
|
-
Metar::SkyCondition.parse(
|
34
|
+
Metar::SkyCondition.parse(raw).should be_sky_condition(*expected)
|
37
35
|
end
|
38
36
|
end
|
39
|
-
|
40
37
|
end
|
41
38
|
|
42
39
|
context '.to_summary' do
|
43
|
-
|
44
40
|
[
|
45
|
-
[
|
46
|
-
[
|
47
|
-
[
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
41
|
+
['all values nil', [nil, nil, nil ], :en, 'clear skies' ],
|
42
|
+
['quantity', ['broken', nil, nil ], :en, 'broken cloud' ],
|
43
|
+
['quantity', ['broken', nil, nil ], :'en-US', 'broken clouds' ],
|
44
|
+
['quantity + type', ['broken', nil, 'cumulonimbus'], :en, 'broken cumulonimbus'],
|
45
|
+
['quantity + type', ['broken', nil, 'cumulonimbus'], :'en-US', 'broken cumulonimbus clouds'],
|
46
|
+
].each do |docstring, (quantity, height, type), locale, expected|
|
47
|
+
before { @old_locale = I18n.locale }
|
48
|
+
after { I18n.locale = @old_locale }
|
49
|
+
|
50
|
+
example "#{docstring} - #{locale}" do
|
51
|
+
condition = Metar::SkyCondition.new(quantity, height, type)
|
52
|
+
I18n.locale = locale
|
53
|
+
expect(condition.to_summary).to eq(expected)
|
53
54
|
end
|
54
55
|
end
|
55
|
-
|
56
56
|
end
|
57
57
|
|
58
58
|
context '.to_s' do
|
59
|
-
|
60
59
|
[
|
61
|
-
[
|
62
|
-
[
|
63
|
-
[
|
64
|
-
].each do |
|
60
|
+
['all values nil', [nil, nil, nil], 'clear skies' ],
|
61
|
+
['quantity', ['broken', 360, nil], 'broken cloud at 360' ],
|
62
|
+
['quantity + type', ['broken', 360, 'cumulonimbus'], 'broken cumulonimbus at 360'],
|
63
|
+
].each do |docstring, (quantity, height, type), expected|
|
65
64
|
example docstring do
|
66
|
-
|
67
|
-
|
68
|
-
sk.to_s. should == expected
|
65
|
+
condition = Metar::SkyCondition.new(quantity, height, type)
|
66
|
+
expect(condition.to_s).to eq(expected)
|
69
67
|
end
|
70
68
|
end
|
71
|
-
|
72
69
|
end
|
73
|
-
|
74
70
|
end
|
75
71
|
|
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.6
|
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-05-
|
12
|
+
date: 2013-05-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -169,10 +169,10 @@ files:
|
|
169
169
|
- spec/unit/wind_spec.rb
|
170
170
|
- spec/unit/distance_spec.rb
|
171
171
|
- spec/unit/temperature_spec.rb
|
172
|
+
- spec/unit/i18n_spec.rb
|
172
173
|
- spec/unit/vertical_visibility_spec.rb
|
173
174
|
- spec/unit/remark_spec.rb
|
174
175
|
- spec/unit/runway_visible_range_spec.rb
|
175
|
-
- spec/unit/locales_spec.rb
|
176
176
|
- spec/unit/weather_phenomenon_spec.rb
|
177
177
|
- spec/unit/raw_spec.rb
|
178
178
|
- spec/unit/parser_spec.rb
|
@@ -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: 4569733942927237109
|
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: 4569733942927237109
|
207
207
|
requirements: []
|
208
208
|
rubyforge_project: nowarning
|
209
209
|
rubygems_version: 1.8.23
|
@@ -220,10 +220,10 @@ test_files:
|
|
220
220
|
- spec/unit/wind_spec.rb
|
221
221
|
- spec/unit/distance_spec.rb
|
222
222
|
- spec/unit/temperature_spec.rb
|
223
|
+
- spec/unit/i18n_spec.rb
|
223
224
|
- spec/unit/vertical_visibility_spec.rb
|
224
225
|
- spec/unit/remark_spec.rb
|
225
226
|
- spec/unit/runway_visible_range_spec.rb
|
226
|
-
- spec/unit/locales_spec.rb
|
227
227
|
- spec/unit/weather_phenomenon_spec.rb
|
228
228
|
- spec/unit/raw_spec.rb
|
229
229
|
- spec/unit/parser_spec.rb
|