metar-parser 0.9.9 → 0.9.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,25 +1,47 @@
1
- = metar - Downloads and parses weather status
1
+ metar - Downloads and parses weather status
2
+ ===========================================
2
3
 
3
4
  The information comes from the National Oceanic and Atmospheric Association's raw data source.
4
5
 
5
- = Implementation
6
+ Implementation
7
+ ==============
6
8
 
7
9
  * Parses METAR strings using a state machine.
8
10
 
9
- = Example
11
+ Usage
12
+ =====
13
+
14
+ ```ruby
15
+ require 'rubygems' if RUBY_VERSION < '1.9'
16
+ require 'metar'
17
+ ```
18
+
19
+ Examples
20
+ ========
21
+
22
+ Hello World
23
+ -----------
10
24
 
11
25
  This prints the latest weather report for Portland International Airport:
12
26
 
13
- require 'rubygems'
14
- require 'metar'
27
+ ```ruby
28
+ station = Metar::Station.find_by_cccc( 'KPDX' )
29
+ puts station.report.to_s
30
+ ```
31
+
32
+ Countries
33
+ ---------
15
34
 
16
- raw = Metar::Raw.new( 'KPDX' )
17
- parser = Metar::Parser.new( raw )
18
- report = Metar::Report.new( parser )
35
+ ```ruby
36
+ # List countries:
37
+ puts Metar::Station.countries
19
38
 
20
- puts report.to_s
39
+ # Find a country's weather stations:
40
+ spanish = Metar::Station.find_all_by_country( 'Spain' )
41
+ ```
21
42
 
22
- = Data format descrition
43
+ The METAR Data Format
44
+ =====================
23
45
 
24
46
  * WMO
25
47
  * http://www.wmo.int/pages/prog/www/WMOCodes/Manual/Volume-I-selection/Sel2.pdf (pages 27-38)
@@ -32,7 +54,11 @@ puts report.to_s
32
54
  * http://weather.cod.edu/notes/metar.html
33
55
  * http://www.met.tamu.edu/class/METAR/metar-pg3.html - incomplete
34
56
 
35
- = Other software
57
+ Alternative Software
58
+ ====================
59
+
60
+ Ruby
61
+ ----
36
62
 
37
63
  Other Ruby libraries offering METAR parsing:
38
64
  * ruby-metar - http://github.com/brandonh/ruby-metar
@@ -46,8 +72,10 @@ There are two gems which read the National Oceanic and Atmospheric Association's
46
72
  Interactive map:
47
73
  * http://www.spatiality.at/metarr/frontend/
48
74
 
49
- = Testing
75
+ Testing
76
+ =======
50
77
 
51
78
  The tests use a local copy of the weather stations list: data/nsd_cccc.txt
52
79
 
53
80
  If missing, the file gets downloaded before running tests.
81
+
data/lib/metar/station.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'rubygems' if RUBY_VERSION < '1.9'
2
2
  require 'open-uri'
3
+ require 'set'
3
4
 
4
5
  # A Station can be created without downloading data from the Internet.
5
6
  # The class downloads and caches the NOAA station list when it is first requested.
@@ -31,11 +32,15 @@ module Metar
31
32
  end
32
33
  end
33
34
 
35
+ def countries
36
+ all_structures.reduce( Set.new ) { |a, s| a.add( s[ :country ] ); a }
37
+ end
38
+
34
39
  def all
35
40
  all_structures.collect do |h|
36
41
  options = h.clone
37
- cccc = options.delete(:cccc)
38
- new(cccc, h)
42
+ cccc = options.delete(:cccc)
43
+ new(cccc, options)
39
44
  end
40
45
  end
41
46
 
@@ -44,6 +49,10 @@ module Metar
44
49
  not find_data_by_cccc(cccc).nil?
45
50
  end
46
51
 
52
+ def find_all_by_country( country )
53
+ all.select { | s | s.country == country }
54
+ end
55
+
47
56
  def find_by_cccc(cccc)
48
57
  all.find { |station| station.cccc == cccc }
49
58
  end
@@ -114,6 +123,12 @@ module Metar
114
123
  Station.exist?(@cccc)
115
124
  end
116
125
 
126
+ def report
127
+ raw = Metar::Raw.new( @cccc )
128
+ parser = Metar::Parser.new( raw )
129
+ Metar::Report.new( parser )
130
+ end
131
+
117
132
  private
118
133
 
119
134
  class << self
data/lib/metar/version.rb CHANGED
@@ -3,7 +3,7 @@ module Metar
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = 0
5
5
  MINOR = 9
6
- TINY = 9
6
+ TINY = 10
7
7
 
8
8
  STRING = [ MAJOR, MINOR, TINY ].join( '.' )
9
9
  end
metadata CHANGED
@@ -1,113 +1,148 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: metar-parser
3
- version: !ruby/object:Gem::Version
4
- version: 0.9.9
3
+ version: !ruby/object:Gem::Version
4
+ hash: 47
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 9
9
+ - 10
10
+ version: 0.9.10
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Joe Yates
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2011-12-08 00:00:00.000000000 +00:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-05-11 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ prerelease: false
16
22
  name: rake
17
- requirement: &2156238740 !ruby/object:Gem::Requirement
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
18
24
  none: false
19
- requirements:
20
- - - ! '>='
21
- - !ruby/object:Gem::Version
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 49
29
+ segments:
30
+ - 0
31
+ - 8
32
+ - 7
22
33
  version: 0.8.7
34
+ requirement: *id001
23
35
  type: :runtime
36
+ - !ruby/object:Gem::Dependency
24
37
  prerelease: false
25
- version_requirements: *2156238740
26
- - !ruby/object:Gem::Dependency
27
38
  name: i18n
28
- requirement: &2156237980 !ruby/object:Gem::Requirement
39
+ version_requirements: &id002 !ruby/object:Gem::Requirement
29
40
  none: false
30
- requirements:
31
- - - ! '>='
32
- - !ruby/object:Gem::Version
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 25
45
+ segments:
46
+ - 0
47
+ - 3
48
+ - 5
33
49
  version: 0.3.5
50
+ requirement: *id002
34
51
  type: :runtime
52
+ - !ruby/object:Gem::Dependency
35
53
  prerelease: false
36
- version_requirements: *2156237980
37
- - !ruby/object:Gem::Dependency
38
54
  name: aasm
39
- requirement: &2156237220 !ruby/object:Gem::Requirement
55
+ version_requirements: &id003 !ruby/object:Gem::Requirement
40
56
  none: false
41
- requirements:
42
- - - ! '>='
43
- - !ruby/object:Gem::Version
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 1
61
+ segments:
62
+ - 2
63
+ - 1
64
+ - 5
44
65
  version: 2.1.5
66
+ requirement: *id003
45
67
  type: :runtime
68
+ - !ruby/object:Gem::Dependency
46
69
  prerelease: false
47
- version_requirements: *2156237220
48
- - !ruby/object:Gem::Dependency
49
70
  name: m9t
50
- requirement: &2156236000 !ruby/object:Gem::Requirement
71
+ version_requirements: &id004 !ruby/object:Gem::Requirement
51
72
  none: false
52
- requirements:
73
+ requirements:
53
74
  - - ~>
54
- - !ruby/object:Gem::Version
75
+ - !ruby/object:Gem::Version
76
+ hash: 17
77
+ segments:
78
+ - 0
79
+ - 2
80
+ - 3
55
81
  version: 0.2.3
82
+ requirement: *id004
56
83
  type: :runtime
57
- prerelease: false
58
- version_requirements: *2156236000
59
- description: A Ruby library which handle METAR weather reports. Provides weather station
60
- listings and info. Downloads and parses reports. Presents localized full text reports
84
+ description: A Ruby library which handle METAR weather reports. Provides weather station listings and info. Downloads and parses reports. Presents localized full text reports
61
85
  email: joe.g.yates@gmail.com
62
86
  executables: []
87
+
63
88
  extensions: []
89
+
64
90
  extra_rdoc_files: []
65
- files:
66
- - README.rdoc
91
+
92
+ files:
93
+ - README.md
67
94
  - COPYING
68
95
  - Rakefile
69
96
  - bin/download_raw.rb
70
97
  - bin/parse_raw.rb
98
+ - lib/metar.rb
71
99
  - lib/metar/data.rb
100
+ - lib/metar/station.rb
72
101
  - lib/metar/parser.rb
73
- - lib/metar/raw.rb
74
102
  - lib/metar/report.rb
75
- - lib/metar/station.rb
76
103
  - lib/metar/version.rb
77
- - lib/metar.rb
78
- - test/all_tests.rb
104
+ - lib/metar/raw.rb
79
105
  - test/metar_test_helper.rb
80
106
  - test/unit/data_test.rb
81
107
  - test/unit/parser_test.rb
82
- - test/unit/raw_test.rb
83
108
  - test/unit/report_test.rb
84
109
  - test/unit/station_test.rb
85
- - locales/en.yml
110
+ - test/unit/raw_test.rb
111
+ - test/all_tests.rb
86
112
  - locales/it.yml
87
- has_rdoc: true
113
+ - locales/en.yml
88
114
  homepage: http://github.com/joeyates/metar-parser
89
115
  licenses: []
116
+
90
117
  post_install_message:
91
118
  rdoc_options: []
92
- require_paths:
119
+
120
+ require_paths:
93
121
  - lib
94
- required_ruby_version: !ruby/object:Gem::Requirement
122
+ required_ruby_version: !ruby/object:Gem::Requirement
95
123
  none: false
96
- requirements:
97
- - - ! '>='
98
- - !ruby/object:Gem::Version
99
- version: '0'
100
- required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ hash: 3
128
+ segments:
129
+ - 0
130
+ version: "0"
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
132
  none: false
102
- requirements:
103
- - - ! '>='
104
- - !ruby/object:Gem::Version
105
- version: '0'
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ hash: 3
137
+ segments:
138
+ - 0
139
+ version: "0"
106
140
  requirements: []
141
+
107
142
  rubyforge_project: nowarning
108
- rubygems_version: 1.6.2
143
+ rubygems_version: 1.8.24
109
144
  signing_key:
110
145
  specification_version: 3
111
146
  summary: A Ruby library for METAR weather reports
112
- test_files:
147
+ test_files:
113
148
  - test/all_tests.rb