vatsim_online 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +23 -13
- data/lib/vatsim_online/data_downloader.rb +2 -2
- data/lib/vatsim_online/station.rb +14 -3
- data/lib/vatsim_online/station_parser.rb +1 -1
- data/lib/vatsim_online/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -71,13 +71,13 @@ stations and pilots stations. Each of those is an **array**, cosnsisting of
|
|
71
71
|
station **objects**. Each of these objects includes a number of **attributes**:
|
72
72
|
|
73
73
|
```ruby
|
74
|
-
|
74
|
+
icao.vatsim_online # => {:atc => [a1, a2, a3 ...], :pilots => [p1, p2, p3 ...]}
|
75
75
|
|
76
|
-
|
77
|
-
|
76
|
+
icao.vatsim_online[:atc] #=> [a1, a2, a3 ...]
|
77
|
+
icao.vatsim_online[:pilots] #=> [p1, p2, p3 ...]
|
78
78
|
|
79
|
-
|
80
|
-
|
79
|
+
icao.vatsim_online[:atc].first #=> a1
|
80
|
+
icao.vatsim_online[:pilots].first #=> p1
|
81
81
|
|
82
82
|
a1.callsign #=> "LQSA_TWR"
|
83
83
|
a1.frequency #=> "118.25"
|
@@ -102,7 +102,7 @@ Here's a complete list of the station object attributes that can be accessed:
|
|
102
102
|
* altitude
|
103
103
|
* groundspeed
|
104
104
|
* aircraft
|
105
|
-
*
|
105
|
+
* origin
|
106
106
|
* destination
|
107
107
|
* rating
|
108
108
|
* facility
|
@@ -169,13 +169,13 @@ end
|
|
169
169
|
- for pilot in @pilots
|
170
170
|
%li
|
171
171
|
= pilot.callsign
|
172
|
-
=
|
173
|
-
=
|
174
|
-
=
|
175
|
-
=
|
176
|
-
=
|
177
|
-
=
|
178
|
-
=
|
172
|
+
= pilot.name
|
173
|
+
= pilot.origin
|
174
|
+
= pilot.destination
|
175
|
+
= pilot.route
|
176
|
+
= pilot.altitude
|
177
|
+
= pilot.groundspeed
|
178
|
+
= pilot.remarks
|
179
179
|
```
|
180
180
|
|
181
181
|
### Notes
|
@@ -192,6 +192,16 @@ libraries too.
|
|
192
192
|
* Pilot stations returned are based on origin and destination airports, the
|
193
193
|
current algorithm does not evaluate enroute flights.
|
194
194
|
|
195
|
+
## Changelog
|
196
|
+
|
197
|
+
### v. 0.2 - 21 July 2012
|
198
|
+
|
199
|
+
* Station attribute `departure` is now renamed to `origin`
|
200
|
+
* UTF-8 is now enforced for all local caching and file/string manipulations, the
|
201
|
+
original Vatsim data is re-encoded
|
202
|
+
* Station ATIS is now cleaned of invalid and obscure characters
|
203
|
+
* Improved documentation
|
204
|
+
|
195
205
|
## Contributing
|
196
206
|
|
197
207
|
1. Fork it
|
@@ -36,9 +36,9 @@ module VatsimTools
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def create_local_data_file
|
39
|
-
data = Tempfile.new('vatsim_data', :encoding => '
|
39
|
+
data = Tempfile.new('vatsim_data', :encoding => 'utf-8')
|
40
40
|
File.rename data.path, LOCAL_DATA
|
41
|
-
data = Curl::Easy.perform(servers.sample).body_str.gsub(/["]/, '\s').force_encoding('
|
41
|
+
data = Curl::Easy.perform(servers.sample).body_str.gsub(/["]/, '\s').mb_chars.force_encoding('utf-8')
|
42
42
|
File.open(LOCAL_DATA, "w+") {|f| f.write(data)}
|
43
43
|
end
|
44
44
|
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
module VatsimTools
|
2
3
|
class Station
|
3
4
|
attributes = %w{callsign name role frequency altitude groundspeed aircraft
|
4
|
-
|
5
|
+
origin destination rating facility remarks route atis logon}
|
5
6
|
attributes.each {|attribute| attr_accessor attribute.to_sym }
|
6
7
|
|
7
8
|
|
@@ -13,15 +14,25 @@ module VatsimTools
|
|
13
14
|
@altitude = station[7]
|
14
15
|
@groundspeed = station[8]
|
15
16
|
@aircraft = station[9]
|
16
|
-
@
|
17
|
+
@origin = station[11]
|
17
18
|
@destination = station[13]
|
18
19
|
@rating = station[16]
|
19
20
|
@facility = station[18]
|
20
21
|
@remarks = station[29]
|
21
22
|
@route = station[30]
|
22
|
-
@atis = station[35]
|
23
|
+
@atis = atis_cleaner(station[35]) if station[35]
|
23
24
|
@logon = station[37]
|
24
25
|
end
|
25
26
|
|
27
|
+
def atis_cleaner(raw_atis)
|
28
|
+
while raw_atis.index('^') != nil
|
29
|
+
raw_atis.insert(raw_atis.index('^'), '. ')
|
30
|
+
index = raw_atis.index('^')
|
31
|
+
raw_atis.slice!(index..index + 1)
|
32
|
+
end
|
33
|
+
raw_atis
|
34
|
+
end
|
35
|
+
|
36
|
+
|
26
37
|
end
|
27
38
|
end
|
@@ -26,7 +26,7 @@ module VatsimTools
|
|
26
26
|
|
27
27
|
def stations
|
28
28
|
stations = []
|
29
|
-
CSV.foreach(LOCAL_DATA, :col_sep =>':'
|
29
|
+
CSV.foreach(LOCAL_DATA, :col_sep =>':') do |row|
|
30
30
|
callsign, origin, destination, client = row[0].to_s, row[11].to_s, row[13].to_s, row[3].to_s
|
31
31
|
stations << row if (callsign[0...@icao.length] == @icao && client == "ATC") unless @role == "pilot"
|
32
32
|
stations << row if (origin[0...@icao.length] == @icao || destination[0...@icao.length] == @icao) unless @role == "atc"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vatsim_online
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.2'
|
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: 2012-07-
|
12
|
+
date: 2012-07-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|