vatsim_online 0.7.4.2 → 0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +36 -2
- data/lib/vatsim_online.rb +9 -1
- data/lib/vatsim_online/callsign_parser.rb +54 -0
- data/lib/vatsim_online/data_downloader.rb +1 -0
- data/lib/vatsim_online/version.rb +1 -1
- data/spec/callsign_parser_spec.rb +29 -0
- data/spec/callsign_parser_spec_helper.rb +7 -0
- data/spec/vatsim_data.txt +1 -7
- data/spec/vatsim_online_spec.rb +19 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaa2f18f60a9b48067065d398a31713df9fb5417
|
4
|
+
data.tar.gz: c074d77a202f76faf0d9626a7e42620e8d9e8c57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 513e26e2992fcd07a6a9ba7997a92f7411275bc83217b375a503c89f2d6b04d2c21986682f7819da420cbe485ea21592436b8bfa0240bb11b945a8176854a464
|
7
|
+
data.tar.gz: d4edd8ed2ab1534a855fbbbaf90546918f6ee09be4d8dff76497c75a43da2916ec1edcd4279dc4611f9d505156259a0ed28b0bd62bf9cd25720dafc1996d0060
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
A Ruby gem for selectively pulling, parsing and displaying Vatsim online
|
4
4
|
stations data. Essentially it's a "Who's online" library, capable of displaying
|
5
|
-
online ATC and/or pilots for given airports, areas or globally. Stations are
|
5
|
+
online ATC and/or pilots for given airports, areas or globally and to filter by callsign. Stations are
|
6
6
|
returned as objects, exposing a rich set of attributes. Vatsim data is pulled
|
7
7
|
on preset intervals and cached locally to avoid flooding the servers.
|
8
8
|
|
@@ -31,11 +31,20 @@ Or install it yourself as:
|
|
31
31
|
|
32
32
|
## Usage
|
33
33
|
|
34
|
-
This gem provides
|
34
|
+
This gem provides two public methods:
|
35
|
+
|
36
|
+
* `vatsim_online`, which can be applied to
|
35
37
|
any string (or variable containing a string) representing a full or partial ICAO
|
36
38
|
code or a comma-separated list of ICAO codes. The provided ICAO code or fragment
|
37
39
|
will be used as a search criteria and matched against the current vatsim data.
|
38
40
|
|
41
|
+
* `vatsim_callsign`, which can be applied to
|
42
|
+
any string (or variable containing a string) representing a full or partial pilot or ATC
|
43
|
+
callsign or a comma-separated list of callsigns. The provided callsign or fragment
|
44
|
+
will be used as a search criteria and matched against the current vatsim data.
|
45
|
+
|
46
|
+
### Filter by ICAO code examples
|
47
|
+
|
39
48
|
For example if you want to retrieve all active stations (ATC positions and pilots)
|
40
49
|
for Vienna airport (ICAO: LOWW), then you can use:
|
41
50
|
|
@@ -74,6 +83,21 @@ return the pilots that are flying **to or from** the given area or airport,
|
|
74
83
|
not the current enroute stations. The discovery algorithm is based on **origin
|
75
84
|
and destination**.
|
76
85
|
|
86
|
+
### Filter by callsign examples
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
# Attaching the method directly to a string:
|
90
|
+
"BAW".vatsim_callsign # => returns an array of all Speedbird flights as station objects
|
91
|
+
|
92
|
+
# Attaching the method to a variable containing a string:
|
93
|
+
callsign = "BAW"
|
94
|
+
callsign.vatsim_callsign # => returns an array of all Speedbird flights as station objects
|
95
|
+
|
96
|
+
# Attaching the method to a list of callsigns:
|
97
|
+
callsign = "BAW, RYR"
|
98
|
+
callsign.vatsim_callsign # => returns an array of all Speedbird and Ryanair flights as station objects
|
99
|
+
```
|
100
|
+
|
77
101
|
|
78
102
|
### Anatomy of method returns
|
79
103
|
|
@@ -113,6 +137,8 @@ p1.remarks #=> "/V/ RMK/CHARTS"
|
|
113
137
|
want to loop through them separately. The `pilots` array contains all arrivals
|
114
138
|
and departures.
|
115
139
|
|
140
|
+
The `vatsim_callsign` method returns an **array** of all matching stations.
|
141
|
+
|
116
142
|
### Station attributes
|
117
143
|
|
118
144
|
Here's a complete list of the station object attributes that can be accessed:
|
@@ -306,6 +332,14 @@ the same result.
|
|
306
332
|
|
307
333
|
## Changelog
|
308
334
|
|
335
|
+
### v. 0.8 - 5 October 2013
|
336
|
+
|
337
|
+
* search by callsign implemented
|
338
|
+
|
339
|
+
### v. 0.7.4 - 2 August 2013
|
340
|
+
|
341
|
+
* fallback scenarios for offline data servers
|
342
|
+
|
309
343
|
### v. 0.7.2 - 15 July 2013
|
310
344
|
|
311
345
|
* added gemspec license declaration
|
data/lib/vatsim_online.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
%w{vatsim_online/version vatsim_online/station vatsim_online/data_downloader
|
2
|
-
vatsim_online/station_parser}.each { |lib| require lib }
|
2
|
+
vatsim_online/station_parser vatsim_online/callsign_parser}.each { |lib| require lib }
|
3
3
|
|
4
4
|
class String
|
5
5
|
def vatsim_online(args={})
|
6
6
|
VatsimOnline.vatsim_online(self, args)
|
7
7
|
end
|
8
|
+
|
9
|
+
def vatsim_callsign(args={})
|
10
|
+
VatsimOnline.vatsim_callsign(self, args)
|
11
|
+
end
|
8
12
|
end
|
9
13
|
|
10
14
|
module VatsimOnline
|
@@ -13,4 +17,8 @@ module VatsimOnline
|
|
13
17
|
VatsimTools::StationParser.new(icao,args).sorted_station_objects
|
14
18
|
end
|
15
19
|
|
20
|
+
def self.vatsim_callsign(callsign, args)
|
21
|
+
VatsimTools::CallsignParser.new(callsign,args).station_objects
|
22
|
+
end
|
23
|
+
|
16
24
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module VatsimTools
|
2
|
+
|
3
|
+
class CallsignParser
|
4
|
+
|
5
|
+
%w{tmpdir csv}.each { |lib| require lib }
|
6
|
+
require_relative "data_downloader"
|
7
|
+
require_relative "station"
|
8
|
+
|
9
|
+
attributes = %w{role callsign gcmap_width gcmap_height}
|
10
|
+
attributes.each {|attribute| attr_accessor attribute.to_sym }
|
11
|
+
|
12
|
+
LOCAL_DATA = "#{Dir.tmpdir}/vatsim_data.txt"
|
13
|
+
|
14
|
+
def initialize(callsign, args = nil)
|
15
|
+
VatsimTools::DataDownloader.new
|
16
|
+
# args.class == Hash ? @role = determine_role(args) : @role = "all"
|
17
|
+
@callsign = callsign.upcase.split(',').each {|s| s.strip!}
|
18
|
+
# @excluded = args[:exclude].upcase if args && args[:exclude]
|
19
|
+
@gcmap_width = args[:gcmap_width] if args && args[:gcmap_width]
|
20
|
+
@gcmap_height = args[:gcmap_height] if args && args[:gcmap_height]
|
21
|
+
end
|
22
|
+
|
23
|
+
# def determine_role(args)
|
24
|
+
# args[:atc] == false ? role = "pilot" : role = "all"
|
25
|
+
# args[:pilots] == false ? role = "atc" : role = role
|
26
|
+
# role = "all" if args[:pilots] == false && args[:atc] == false
|
27
|
+
# role
|
28
|
+
# end
|
29
|
+
|
30
|
+
|
31
|
+
def stations
|
32
|
+
stations = []
|
33
|
+
CSV.foreach(LOCAL_DATA, :col_sep =>':') do |row|
|
34
|
+
callsign, origin, destination, client = row[0].to_s, row[11].to_s, row[13].to_s, row[3].to_s
|
35
|
+
for cs in @callsign
|
36
|
+
stations << row if callsign[0...cs.length] == cs # && client == "ATC") unless @role == "pilot"
|
37
|
+
# stations << row if (origin[0...icao.length] == icao || destination[0...icao.length] == icao) unless @role == "atc"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
stations
|
41
|
+
end
|
42
|
+
|
43
|
+
def station_objects
|
44
|
+
station_objects= []
|
45
|
+
args = {}
|
46
|
+
args[:gcmap_width] = @gcmap_width if @gcmap_width
|
47
|
+
args[:gcmap_height] = @gcmap_height if @gcmap_height
|
48
|
+
stations.each {|station| station_objects << VatsimTools::Station.new(station, args) }
|
49
|
+
station_objects
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -60,6 +60,7 @@ module VatsimTools
|
|
60
60
|
File.open(LOCAL_DATA, "w+") {|f| f.write(data)}
|
61
61
|
File.chmod(0777, LOCAL_DATA)
|
62
62
|
gem_data_file if curl.include? "<html><head>"
|
63
|
+
gem_data_file if File.open(LOCAL_DATA).size == 0
|
63
64
|
rescue Curl::Err::HostResolutionError
|
64
65
|
gem_data_file
|
65
66
|
rescue Curl::Err::TimeoutError
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'vatsim_online'
|
2
|
+
require 'callsign_parser_spec_helper.rb'
|
3
|
+
|
4
|
+
describe VatsimTools::CallsignParser do
|
5
|
+
|
6
|
+
target = VatsimTools::CallsignParser
|
7
|
+
|
8
|
+
describe "stations" do
|
9
|
+
it "should return an expected result" do
|
10
|
+
gem_data_file
|
11
|
+
callsign = "WMKK"
|
12
|
+
target.new(callsign).stations.first[0].should eq("WMKK_APP")
|
13
|
+
target.new(callsign).stations.class.should eq(Array)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "station_objects" do
|
18
|
+
it "should return an array of Station objects" do
|
19
|
+
gem_data_file
|
20
|
+
callsign = "LO"
|
21
|
+
target.new(callsign).station_objects.class.should eq(Array)
|
22
|
+
target.new(callsign).station_objects.size.should eq(2)
|
23
|
+
target.new(callsign).station_objects.first.class.should eq(VatsimTools::Station)
|
24
|
+
target.new(callsign).station_objects.first.callsign.should eq("LOT282")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
def gem_data_file
|
2
|
+
path = File.realpath("spec/vatsim_data.txt")
|
3
|
+
gem_data = File.open(path, :encoding => 'iso-8859-15').read
|
4
|
+
data = Tempfile.new('vatsim_data', :encoding => 'iso-8859-15')
|
5
|
+
data.write(gem_data.gsub(/["]/, '\s').force_encoding('iso-8859-15'))
|
6
|
+
File.rename data.path, "#{Dir.tmpdir}/vatsim_data.txt"
|
7
|
+
end
|
data/spec/vatsim_data.txt
CHANGED
@@ -511,11 +511,5 @@ UK:109.169.48.148:London, UK:UK:1:
|
|
511
511
|
USA-E:173.45.78.10:Ohio, USA:USA East:1:
|
512
512
|
USA-N:204.244.237.21:Vancouver, CANADA:USA North:1:
|
513
513
|
USA-W:64.151.108.52:San Francisco, USA:West USA:1:
|
514
|
-
|
515
|
-
;
|
516
|
-
!PREFILE:
|
517
|
-
BAW248:1216383:Raimo Ingland EETN:::::::H/B77W/Q:490:SBGL:FL310:EGLL:::::::0:I:1050:1050:11:10:12:40:EGKK:+VFPS+/V/TROPICALSIM/SBGL UK2000/EGLL PSS/77W AIRAC/1207 SEL/EKLQ RMK/CHARTS RMK/TCAS RMK/STEP CLIMB UP TO FL370 OPR/BAVIRTUAL:ESMAP UZ1 KIGOK UZ1 TROVA UN866 MSS UN866 DEKON UN866 APASO UN866 GOMER UN981 BIMBO DCT AGADO UN866 QPR UN472 JSY UN472 REVTU UP87 DOMUT:0:0:0:0:::::::
|
518
|
-
THY17:1216592:Can Acar:::::::H/B77W/S:490:LTBA:32000:CYYZ:::::::0:I:1030:1030:10:0:12:15:CYYR:+VFPS+/V/REG/TCJJN SEL/GLDM DOF/120722 OPR/THY RMK/ADSB TCAS EQUIPPED DAT/SV NAV/RNAV1 RNP5 RNVD1A1 RALT/EINN CYYR:N0490F320 IBLAL UP727 BGS UL622 NARKA UL867 TEPNI UL624 LABUK UY444 ELMEK UL602 TABAT/N0480F340 UL602 KEMAD DCT RAVLO UY70 OTBED UL26 PENIL UL70 BAGSO DCT RESNO/M083F340 DOLIP 52N015W/M08F360 52N020W 53N030W 53N040W 52N050W CRONO DOTTY STEAM/N0480F380 N230E YRI DCT POLTY/0942:0:0:0:0:::::::
|
519
|
-
VOZ894:1007572:James Kittelty - YMML:::::::B738/Q:441:YSSY:F380:YMML:::::::0:I:1100:1100:1:20:3:0:YMAV:+VFPS+/V/REG/VHYIG SEL/MRCP OPR/VOZ VIRTUAL PER/C NAV/RNP10 GPSRNAV RMK/ADSB TCAS EQUIPPED:DCT SY H65 RAZZI Q29 ML DCT:0:0:0:0:::::::
|
520
|
-
;
|
514
|
+
|
521
515
|
; END
|
data/spec/vatsim_online_spec.rb
CHANGED
@@ -32,6 +32,25 @@ describe VatsimOnline do
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
describe "vatsim_callsign" do
|
36
|
+
it "should work :)" do
|
37
|
+
gem_data_file
|
38
|
+
"AMZ1105".vatsim_callsign.class.should eq(Array)
|
39
|
+
"AMZ1105".vatsim_callsign.size.should eq(1)
|
40
|
+
"AMZ1105".vatsim_callsign.first.callsign.should eq("AMZ1105")
|
41
|
+
"BAW".vatsim_callsign.size.should eq(15)
|
42
|
+
"BAW".vatsim_callsign.last.callsign.should eq("BAW9DV")
|
43
|
+
"BAW, AMZ1105".vatsim_callsign.size.should eq(16)
|
44
|
+
"BAW, QFA".vatsim_callsign.size.should eq(21)
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should be case insensitive" do
|
49
|
+
gem_data_file
|
50
|
+
"amz1105".vatsim_callsign.first.callsign.should eq("AMZ1105")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
35
54
|
end
|
36
55
|
|
37
56
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vatsim_online
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.8'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Svilen Vassilev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -157,12 +157,15 @@ files:
|
|
157
157
|
- README.md
|
158
158
|
- Rakefile
|
159
159
|
- lib/vatsim_online.rb
|
160
|
+
- lib/vatsim_online/callsign_parser.rb
|
160
161
|
- lib/vatsim_online/data_downloader.rb
|
161
162
|
- lib/vatsim_online/station.rb
|
162
163
|
- lib/vatsim_online/station_parser.rb
|
163
164
|
- lib/vatsim_online/vatsim_data.txt
|
164
165
|
- lib/vatsim_online/vatsim_status.txt
|
165
166
|
- lib/vatsim_online/version.rb
|
167
|
+
- spec/callsign_parser_spec.rb
|
168
|
+
- spec/callsign_parser_spec_helper.rb
|
166
169
|
- spec/data_downloader_spec.rb
|
167
170
|
- spec/data_downloader_spec_helper.rb
|
168
171
|
- spec/spec_helper.rb
|
@@ -201,6 +204,8 @@ summary: Selectively pulls and parses Vatsim online stations data. Essentially i
|
|
201
204
|
of attributes. Vatsim data is pulled on preset intervals and cached locally to avoid
|
202
205
|
flooding the servers.
|
203
206
|
test_files:
|
207
|
+
- spec/callsign_parser_spec.rb
|
208
|
+
- spec/callsign_parser_spec_helper.rb
|
204
209
|
- spec/data_downloader_spec.rb
|
205
210
|
- spec/data_downloader_spec_helper.rb
|
206
211
|
- spec/spec_helper.rb
|