metar-parser 0.1.2 → 0.1.3

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/Rakefile CHANGED
@@ -9,7 +9,6 @@ require 'metar'
9
9
 
10
10
  RDOC_OPTS = ['--quiet', '--title', 'METAR Weather Report Parser', '--main', 'README.rdoc', '--inline-source']
11
11
  RDOC_PATH = 'doc/rdoc'
12
- CLEAN.include RDOC_PATH
13
12
 
14
13
  task :default => :test
15
14
 
data/lib/metar/data.rb CHANGED
@@ -76,6 +76,8 @@ module Metar
76
76
  hectopascals($1.to_f)
77
77
  when pressure =~ /^A(\d{4})$/
78
78
  inches_of_mercury($1.to_f / 100.0)
79
+ else
80
+ nil
79
81
  end
80
82
  end
81
83
 
@@ -226,6 +228,8 @@ module Metar
226
228
  visibility1 = Visibility.new(distance1, nil, comparator1)
227
229
  visibility2 = Visibility.new(distance2, nil, comparator2)
228
230
  new(designator, visibility1, visibility2, tendency)
231
+ else
232
+ nil
229
233
  end
230
234
  end
231
235
 
@@ -340,17 +344,22 @@ module Metar
340
344
  when sky_condition =~ /^(BKN|FEW|OVC|SCT)(\d+)(CB|TCU|\/{3})?$/
341
345
  quantity = QUANTITY[$1]
342
346
  height = Distance.new($2.to_i * 30.0, { :units => :meters })
343
- type = case $3
344
- when nil
345
- nil
346
- when 'CB'
347
- 'cumulonimbus'
348
- when 'TCU'
349
- 'towering cumulus'
350
- when '///'
351
- ''
352
- end
347
+ type =
348
+ case $3
349
+ when 'CB'
350
+ 'cumulonimbus'
351
+ when 'TCU'
352
+ 'towering cumulus'
353
+ when nil
354
+ nil
355
+ when '///'
356
+ nil
357
+ else
358
+ raise MetarParserError.new("Unexpected sky condition type: #$3")
359
+ end
353
360
  new(quantity, height, type)
361
+ else
362
+ nil
354
363
  end
355
364
  end
356
365
 
@@ -378,6 +387,8 @@ module Metar
378
387
  Distance.new($1.to_f * 30.0, { :units => :meters })
379
388
  when vertical_visibility == '///'
380
389
  Distance.new
390
+ else
391
+ nil
381
392
  end
382
393
  end
383
394
 
data/lib/metar/parser.rb CHANGED
@@ -177,6 +177,8 @@ module Metar
177
177
  when @chunks[0] == 'COR'
178
178
  @chunks.shift
179
179
  @observer = :corrected
180
+ else
181
+ nil
180
182
  end
181
183
  end
182
184
 
data/lib/metar.rb CHANGED
@@ -8,9 +8,17 @@ module Metar
8
8
  module VERSION #:nodoc:
9
9
  MAJOR = 0
10
10
  MINOR = 1
11
- TINY = 2
11
+ TINY = 3
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY].join('.')
14
14
  end
15
15
 
16
+ # Base class for all Metar exceptions
17
+ class MetarError < StandardError
18
+ end
19
+
20
+ # Raised when an unrecognized value is found
21
+ class MetarParserError < MetarError
22
+ end
23
+
16
24
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 2
9
- version: 0.1.2
8
+ - 3
9
+ version: 0.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Joe Yates