vatsim_online_redux 1.0.1 → 2.1.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +16 -135
- data/lib/vatsim_online/callsign_parser.rb +13 -7
- data/lib/vatsim_online/callsign_regex_parser.rb +60 -0
- data/lib/vatsim_online/data_downloader.rb +131 -127
- data/lib/vatsim_online/station.rb +37 -16
- data/lib/vatsim_online/station_parser.rb +28 -19
- data/lib/vatsim_online/version.rb +3 -3
- data/lib/vatsim_online.rb +9 -1
- data/spec/callsign_parser_spec.rb +13 -7
- data/spec/callsign_regex_parser_spec.rb +43 -0
- data/spec/data_downloader_spec.rb +16 -9
- data/spec/data_downloader_spec_helper.rb +6 -4
- data/spec/spec_helper.rb +1 -0
- data/spec/station_parser_spec.rb +51 -53
- data/spec/support/vatsim_data.json +796 -0
- data/spec/support/vatsim_status.json +13 -0
- data/spec/vatsim_online_spec.rb +106 -101
- data/vatsim_online_redux.gemspec +1 -0
- metadata +24 -9
- data/spec/callsign_parser_spec_helper.rb +0 -10
- data/spec/station_parser_spec_helper.rb +0 -10
- data/spec/vatsim_online_spec_helper.rb +0 -10
@@ -12,27 +12,44 @@ module VatsimTools
|
|
12
12
|
|
13
13
|
def initialize(station, args = nil)
|
14
14
|
|
15
|
-
@callsign
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
@callsign = station['callsign']
|
16
|
+
@cid = station['cid'].to_s
|
17
|
+
@name = station['name']
|
18
|
+
@role = station['role']
|
19
|
+
@frequency = station['frequency']
|
20
|
+
@latitude = station['latitude'].to_s
|
21
|
+
@longitude = station['longitude'].to_s
|
22
|
+
@altitude = station['altitude']
|
23
|
+
@groundspeed = station['groundspeed']
|
24
|
+
@aircraft = station['flight_plan']['aircraft'] rescue ''
|
25
|
+
@origin = station['flight_plan']['departure'] rescue ''
|
26
|
+
@planned_altitude = station['flight_plan']['altitude'] rescue ''
|
27
|
+
@destination = station['flight_plan']['arrival'] rescue ''
|
28
|
+
@transponder = station['transponder']
|
29
|
+
@facility = station['facility'].to_s
|
30
|
+
@flight_type = station['flight_plan']['flight_rules'] rescue ''
|
31
|
+
@remarks = station['flight_plan']['remarks'] rescue ''
|
32
|
+
@route = station['flight_plan']['route'] rescue ''
|
33
|
+
@logon = station['logon_time']
|
34
|
+
@heading = station['heading'].to_s
|
35
|
+
@qnh_in = station['qnh_i_hg'].to_s
|
36
|
+
@qnh_mb = station['qnh_mb'].to_s
|
20
37
|
|
21
|
-
@atis = atis_cleaner(station[
|
22
|
-
@rating = humanized_rating(station[
|
23
|
-
@latitude_humanized = latitude_parser(station[
|
24
|
-
@longitude_humanized = longitude_parser(station[
|
38
|
+
@atis = atis_cleaner(station['text_atis']) if station['text_atis']
|
39
|
+
@rating = humanized_rating(station['rating'].to_s)
|
40
|
+
@latitude_humanized = latitude_parser(station['latitude'])
|
41
|
+
@longitude_humanized = longitude_parser(station['longitude'])
|
25
42
|
@online_since = utc_logon_time if @logon
|
26
43
|
@gcmap_width = args[:gcmap_width].to_i if args && args[:gcmap_width]
|
27
44
|
@gcmap_height = args[:gcmap_height].to_i if args && args[:gcmap_height]
|
28
45
|
@gcmap = gcmap_generator
|
29
|
-
@atis_message = construct_atis_message(station[
|
46
|
+
@atis_message = construct_atis_message(station['text_atis']) if station['text_atis']
|
30
47
|
end
|
31
48
|
|
32
49
|
private
|
33
50
|
|
34
51
|
def gcmap_generator
|
35
|
-
return "No map for ATC stations" if @role != "
|
52
|
+
return "No map for ATC stations" if @role != "pilot"
|
36
53
|
construct_gcmap_url.gcmap(:width => @gcmap_width, :height => @gcmap_height)
|
37
54
|
end
|
38
55
|
|
@@ -47,22 +64,26 @@ module VatsimTools
|
|
47
64
|
route
|
48
65
|
end
|
49
66
|
|
50
|
-
def latitude_parser(
|
67
|
+
def latitude_parser(lat_s)
|
68
|
+
return nil if lat_s == nil
|
69
|
+
lat = lat_s.to_f
|
51
70
|
lat > 0 ? hemisphere = "N" : hemisphere = "S"
|
52
71
|
hemisphere + lat.abs.to_s
|
53
72
|
end
|
54
73
|
|
55
|
-
def longitude_parser(
|
74
|
+
def longitude_parser(lon_s)
|
75
|
+
return nil if lon_s == nil
|
76
|
+
lon = lon_s.to_f
|
56
77
|
lon > 0 ? hemisphere = "E" : hemisphere = "W"
|
57
78
|
hemisphere + lon.abs.to_s
|
58
79
|
end
|
59
80
|
|
60
81
|
def atis_cleaner(raw_atis)
|
61
|
-
raw_atis.gsub(/[\^]/, '. ')
|
82
|
+
raw_atis.join(' ').gsub(/[\^]/, '. ')
|
62
83
|
end
|
63
84
|
|
64
85
|
def utc_logon_time
|
65
|
-
Time.parse
|
86
|
+
Time.parse(@logon)
|
66
87
|
end
|
67
88
|
|
68
89
|
def humanized_rating(rating_number)
|
@@ -84,7 +105,7 @@ module VatsimTools
|
|
84
105
|
end
|
85
106
|
|
86
107
|
def construct_atis_message(raw_atis)
|
87
|
-
message = raw_atis.gsub(/[\^]/, '<br />')
|
108
|
+
message = raw_atis.join(' ').gsub(/[\^]/, '<br />')
|
88
109
|
message.index('>') ? message = message[message.index('>')+1...message.length] : message = "No published remark"
|
89
110
|
end
|
90
111
|
|
@@ -7,9 +7,9 @@ module VatsimTools
|
|
7
7
|
require_relative "station"
|
8
8
|
|
9
9
|
attributes = %w{role icao excluded gcmap_width gcmap_height}
|
10
|
-
attributes.each {|attribute| attr_accessor attribute.to_sym }
|
10
|
+
attributes.each { |attribute| attr_accessor attribute.to_sym }
|
11
11
|
|
12
|
-
LOCAL_DATA = "#{Dir.tmpdir}/vatsim_online/vatsim_data.
|
12
|
+
LOCAL_DATA = "#{Dir.tmpdir}/vatsim_online/vatsim_data.json"
|
13
13
|
|
14
14
|
def initialize(icao, args = nil)
|
15
15
|
VatsimTools::DataDownloader.new
|
@@ -17,7 +17,7 @@ module VatsimTools
|
|
17
17
|
if icao == "ALL"
|
18
18
|
@icao = nil
|
19
19
|
else
|
20
|
-
@icao = icao.upcase.split(',').each {|s| s.strip!}
|
20
|
+
@icao = icao.upcase.split(',').each { |s| s.strip! }
|
21
21
|
end
|
22
22
|
@excluded = args[:exclude].upcase if args && args[:exclude]
|
23
23
|
@gcmap_width = args[:gcmap_width] if args && args[:gcmap_width]
|
@@ -32,44 +32,53 @@ module VatsimTools
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def stations
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
matching_stations = []
|
36
|
+
raw_data = File.read(LOCAL_DATA)
|
37
|
+
data = JSON.parse(raw_data)
|
38
|
+
pilots = data['pilots'].each { |p| p['role'] = 'pilot' }
|
39
|
+
controllers = data['controllers'].each { |p| p['role'] = 'controller' }
|
40
|
+
atis = data['atis'].each { |p| p['role'] = 'atis' }
|
41
|
+
stations = pilots + controllers + atis
|
42
|
+
stations.each do |station|
|
43
|
+
callsign = station['callsign']
|
44
|
+
destination = station['flight_plan']['arrival'] rescue ''
|
45
|
+
origin = station['flight_plan']['departure'] rescue ''
|
46
|
+
client = station['role']
|
38
47
|
unless @icao
|
39
|
-
|
40
|
-
|
48
|
+
matching_stations << station if (client == "controller") unless @role == "pilot"
|
49
|
+
matching_stations << station if (client == "pilot") unless @role == "atc"
|
41
50
|
else
|
42
|
-
|
43
|
-
|
44
|
-
|
51
|
+
@icao.each do |icao|
|
52
|
+
matching_stations << station if (callsign[0...icao.length] == icao && client == "controller") unless @role == "pilot"
|
53
|
+
matching_stations << station if (origin[0...icao.length] == icao || destination[0...icao.length] == icao) unless @role == "atc"
|
45
54
|
end
|
46
55
|
end
|
47
56
|
end
|
48
|
-
|
57
|
+
matching_stations
|
49
58
|
end
|
50
59
|
|
51
60
|
def station_objects
|
52
|
-
station_objects= []
|
61
|
+
station_objects = []
|
53
62
|
args = {}
|
54
63
|
args[:gcmap_width] = @gcmap_width if @gcmap_width
|
55
64
|
args[:gcmap_height] = @gcmap_height if @gcmap_height
|
56
|
-
stations.each {|station| station_objects << VatsimTools::Station.new(station, args) }
|
65
|
+
stations.each { |station| station_objects << VatsimTools::Station.new(station, args) }
|
57
66
|
station_objects
|
58
67
|
end
|
59
68
|
|
60
69
|
def sorted_station_objects
|
61
70
|
atc = []; pilots = []; arrivals = []; departures = []
|
62
|
-
station_objects.each {|sobj| sobj.role == "
|
71
|
+
station_objects.each { |sobj| sobj.role == "controller" ? atc << sobj : pilots << sobj }
|
63
72
|
if @icao
|
64
|
-
|
65
|
-
|
73
|
+
@icao.each do |icao|
|
74
|
+
pilots.each do |pilot|
|
66
75
|
departures << pilot if pilot.origin[0...icao.length] == icao
|
67
76
|
arrivals << pilot if pilot.destination[0...icao.length] == icao
|
68
77
|
end
|
69
78
|
end
|
70
79
|
end
|
71
|
-
atc.delete_if {|a| @excluded && a.callsign[0...@excluded.length] == @excluded }
|
72
|
-
{:atc => atc, :pilots => pilots, :arrivals => arrivals, :departures => departures}
|
80
|
+
atc.delete_if { |a| @excluded && a.callsign[0...@excluded.length] == @excluded }
|
81
|
+
{ :atc => atc, :pilots => pilots, :arrivals => arrivals, :departures => departures }
|
73
82
|
end
|
74
83
|
|
75
84
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module VatsimOnline
|
2
|
-
VERSION = "1.
|
3
|
-
end
|
1
|
+
module VatsimOnline
|
2
|
+
VERSION = "2.1.1"
|
3
|
+
end
|
data/lib/vatsim_online.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
%w{vatsim_online/version vatsim_online/station vatsim_online/data_downloader
|
2
|
-
vatsim_online/station_parser vatsim_online/callsign_parser}.each { |lib| require lib }
|
2
|
+
vatsim_online/station_parser vatsim_online/callsign_parser vatsim_online/callsign_regex_parser}.each { |lib| require lib }
|
3
3
|
|
4
4
|
class String
|
5
5
|
def vatsim_online(args={})
|
@@ -9,6 +9,10 @@ class String
|
|
9
9
|
def vatsim_callsign(args={})
|
10
10
|
VatsimOnline.vatsim_callsign(self, args)
|
11
11
|
end
|
12
|
+
|
13
|
+
def vatsim_regex_callsign(args={})
|
14
|
+
VatsimOnline.vatsim_regex_callsign(self, args)
|
15
|
+
end
|
12
16
|
end
|
13
17
|
|
14
18
|
module VatsimOnline
|
@@ -21,4 +25,8 @@ module VatsimOnline
|
|
21
25
|
VatsimTools::CallsignParser.new(callsign,args).station_objects
|
22
26
|
end
|
23
27
|
|
28
|
+
def self.vatsim_regex_callsign(callsign, args)
|
29
|
+
VatsimTools::CallsignRegexParser.new(callsign, args).station_objects
|
30
|
+
end
|
31
|
+
|
24
32
|
end
|
@@ -1,27 +1,33 @@
|
|
1
1
|
require 'vatsim_online'
|
2
|
-
require '
|
2
|
+
require 'data_downloader_spec_helper'
|
3
3
|
|
4
4
|
describe VatsimTools::CallsignParser do
|
5
5
|
|
6
6
|
target = VatsimTools::CallsignParser
|
7
7
|
|
8
|
+
before(:each) do
|
9
|
+
delete_local_files
|
10
|
+
stub_request(:get, 'https://status.vatsim.net/status.json').
|
11
|
+
to_return(body: File.read(File.join(File.dirname(__FILE__), 'support', 'vatsim_status.json')), status: :ok)
|
12
|
+
stub_request(:get, 'https://data.vatsim.net/v3/vatsim-data.json').
|
13
|
+
to_return(body: File.read(File.join(File.dirname(__FILE__), 'support', 'vatsim_data.json')), status: :ok)
|
14
|
+
end
|
15
|
+
|
8
16
|
describe "stations" do
|
9
17
|
it "should return an expected result" do
|
10
|
-
|
11
|
-
callsign
|
12
|
-
target.new(callsign).stations.first[0].should eq("WMKK_APP")
|
18
|
+
callsign = "EGAC"
|
19
|
+
target.new(callsign).stations.first['callsign'].should eq("EGAC_APP")
|
13
20
|
target.new(callsign).stations.class.should eq(Array)
|
14
21
|
end
|
15
22
|
end
|
16
23
|
|
17
24
|
describe "station_objects" do
|
18
25
|
it "should return an array of Station objects" do
|
19
|
-
|
20
|
-
callsign = "LO"
|
26
|
+
callsign = "VFE"
|
21
27
|
target.new(callsign).station_objects.class.should eq(Array)
|
22
28
|
target.new(callsign).station_objects.size.should eq(2)
|
23
29
|
target.new(callsign).station_objects.first.class.should eq(VatsimTools::Station)
|
24
|
-
target.new(callsign).station_objects.first.callsign.should eq("
|
30
|
+
target.new(callsign).station_objects.first.callsign.should eq("VFE1625")
|
25
31
|
end
|
26
32
|
end
|
27
33
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'vatsim_online'
|
2
|
+
require 'data_downloader_spec_helper'
|
3
|
+
|
4
|
+
describe VatsimTools::CallsignRegexParser do
|
5
|
+
|
6
|
+
target = VatsimTools::CallsignRegexParser
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
delete_local_files
|
10
|
+
stub_request(:get, 'https://status.vatsim.net/status.json').
|
11
|
+
to_return(body: File.read(File.join(File.dirname(__FILE__), 'support', 'vatsim_status.json')), status: :ok)
|
12
|
+
stub_request(:get, 'https://data.vatsim.net/v3/vatsim-data.json').
|
13
|
+
to_return(body: File.read(File.join(File.dirname(__FILE__), 'support', 'vatsim_data.json')), status: :ok)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "stations" do
|
17
|
+
it "should return an expected result" do
|
18
|
+
callsign = "EGAC.*_APP"
|
19
|
+
target.new(callsign).stations.first['callsign'].should eq("EGAC_APP")
|
20
|
+
target.new(callsign).stations.class.should eq(Array)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "station_objects" do
|
25
|
+
it "should return an array of Station objects" do
|
26
|
+
callsign = "VFE.*"
|
27
|
+
target.new(callsign).station_objects.class.should eq(Array)
|
28
|
+
target.new(callsign).station_objects.size.should eq(2)
|
29
|
+
target.new(callsign).station_objects.first.class.should eq(VatsimTools::Station)
|
30
|
+
target.new(callsign).station_objects.first.callsign.should eq("VFE1625")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should return an array of Station objects" do
|
34
|
+
callsign = "\\w{3}21\\d{2}"
|
35
|
+
target.new(callsign).station_objects.class.should eq(Array)
|
36
|
+
target.new(callsign).station_objects.size.should eq(2)
|
37
|
+
target.new(callsign).station_objects.first.class.should eq(VatsimTools::Station)
|
38
|
+
target.new(callsign).station_objects.first.callsign.should eq("VFE2157")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
end
|
@@ -4,8 +4,15 @@ require 'data_downloader_spec_helper.rb'
|
|
4
4
|
describe VatsimTools::DataDownloader do
|
5
5
|
|
6
6
|
target = VatsimTools::DataDownloader
|
7
|
-
LOCAL_STATUS = "#{Dir.tmpdir}/vatsim_status.
|
8
|
-
LOCAL_DATA = "#{Dir.tmpdir}/vatsim_data.
|
7
|
+
LOCAL_STATUS = "#{Dir.tmpdir}/vatsim_online/vatsim_status.json"
|
8
|
+
LOCAL_DATA = "#{Dir.tmpdir}/vatsim_online/vatsim_data.json"
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
stub_request(:get, 'https://status.vatsim.net/status.json').
|
12
|
+
to_return(body: File.read(File.join(File.dirname(__FILE__), 'support', 'vatsim_status.json')), status: :ok)
|
13
|
+
stub_request(:get, 'https://data.vatsim.net:443/v3/vatsim-data.json').
|
14
|
+
to_return(body: File.read(File.join(File.dirname(__FILE__), 'support', 'vatsim_data.json')), status: :ok)
|
15
|
+
end
|
9
16
|
|
10
17
|
describe "create_status_tempfile" do
|
11
18
|
it "should create a file" do
|
@@ -14,7 +21,7 @@ describe VatsimTools::DataDownloader do
|
|
14
21
|
target.new.create_status_tempfile
|
15
22
|
File.exists?(LOCAL_STATUS).should be true
|
16
23
|
status = File.open(LOCAL_STATUS)
|
17
|
-
status.path.should eq("#{Dir.tmpdir}/vatsim_status.
|
24
|
+
status.path.should eq("#{Dir.tmpdir}/vatsim_online/vatsim_status.json")
|
18
25
|
status.size.should be > 100
|
19
26
|
status.close
|
20
27
|
end
|
@@ -35,9 +42,9 @@ describe VatsimTools::DataDownloader do
|
|
35
42
|
delete_local_files
|
36
43
|
File.exists?(LOCAL_STATUS).should be false
|
37
44
|
target.new.status_file.class.should eq(String)
|
38
|
-
target.new.status_file.should include("vatsim_status.
|
45
|
+
target.new.status_file.should include("vatsim_status.json")
|
39
46
|
target.new.status_file.should eq(LOCAL_STATUS)
|
40
|
-
target.new.status_file.should eq("#{Dir.tmpdir}/vatsim_status.
|
47
|
+
target.new.status_file.should eq("#{Dir.tmpdir}/vatsim_online/vatsim_status.json")
|
41
48
|
File.exists?(LOCAL_STATUS).should be true
|
42
49
|
end
|
43
50
|
end
|
@@ -46,7 +53,7 @@ describe VatsimTools::DataDownloader do
|
|
46
53
|
it "should contain an array of server URLs" do
|
47
54
|
File.exists?(LOCAL_STATUS).should be true
|
48
55
|
target.new.servers.class.should eq(Array)
|
49
|
-
target.new.servers.size.should eq(
|
56
|
+
target.new.servers.size.should eq(1)
|
50
57
|
end
|
51
58
|
end
|
52
59
|
|
@@ -57,7 +64,7 @@ describe VatsimTools::DataDownloader do
|
|
57
64
|
target.new.create_local_data_file
|
58
65
|
File.exists?(LOCAL_DATA).should be true
|
59
66
|
data = File.open(LOCAL_DATA)
|
60
|
-
data.path.should eq("#{Dir.tmpdir}/vatsim_data.
|
67
|
+
data.path.should eq("#{Dir.tmpdir}/vatsim_online/vatsim_data.json")
|
61
68
|
data.size.should be > 100
|
62
69
|
data.close
|
63
70
|
end
|
@@ -78,9 +85,9 @@ describe VatsimTools::DataDownloader do
|
|
78
85
|
delete_local_files
|
79
86
|
File.exists?(LOCAL_DATA).should be false
|
80
87
|
target.new.data_file.class.should eq(String)
|
81
|
-
target.new.data_file.should include("vatsim_data.
|
88
|
+
target.new.data_file.should include("vatsim_data.json")
|
82
89
|
target.new.data_file.should eq(LOCAL_DATA)
|
83
|
-
target.new.data_file.should eq("#{Dir.tmpdir}/vatsim_data.
|
90
|
+
target.new.data_file.should eq("#{Dir.tmpdir}/vatsim_online/vatsim_data.json")
|
84
91
|
File.exists?(LOCAL_DATA).should be true
|
85
92
|
end
|
86
93
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
def delete_local_files
|
2
|
-
|
3
|
-
|
2
|
+
local_Status = "#{Dir.tmpdir}/vatsim_online/vatsim_status.json"
|
3
|
+
lOCAL_DATA = "#{Dir.tmpdir}/vatsim_online/vatsim_data.json"
|
4
|
+
if File.exists?(local_Status)
|
5
|
+
File.delete(local_Status)
|
4
6
|
end
|
5
|
-
if File.exists?(
|
6
|
-
File.delete(
|
7
|
+
if File.exists?(lOCAL_DATA)
|
8
|
+
File.delete(lOCAL_DATA)
|
7
9
|
end
|
8
10
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/station_parser_spec.rb
CHANGED
@@ -1,10 +1,18 @@
|
|
1
1
|
require 'vatsim_online'
|
2
|
-
require '
|
2
|
+
require 'data_downloader_spec_helper'
|
3
3
|
|
4
4
|
describe VatsimTools::StationParser do
|
5
5
|
|
6
6
|
target = VatsimTools::StationParser
|
7
7
|
|
8
|
+
before(:each) do
|
9
|
+
delete_local_files
|
10
|
+
stub_request(:get, 'https://status.vatsim.net/status.json').
|
11
|
+
to_return(body: File.read(File.join(File.dirname(__FILE__), 'support', 'vatsim_status.json')), status: :ok)
|
12
|
+
stub_request(:get, 'https://data.vatsim.net:443/v3/vatsim-data.json').
|
13
|
+
to_return(body: File.read(File.join(File.dirname(__FILE__), 'support', 'vatsim_data.json')), status: :ok)
|
14
|
+
end
|
15
|
+
|
8
16
|
describe "determine role" do
|
9
17
|
it "should return a role" do
|
10
18
|
args = {:pilots => true, :atc => true}
|
@@ -35,68 +43,62 @@ describe VatsimTools::StationParser do
|
|
35
43
|
describe "stations" do
|
36
44
|
args = {:pilots => true, :atc => true}
|
37
45
|
it "should return an expected result" do
|
38
|
-
|
39
|
-
icao
|
40
|
-
target.new(icao, args).stations.first[0].should eq("WMKK_APP")
|
46
|
+
icao = "EGAC"
|
47
|
+
target.new(icao, args).stations.first['callsign'].should eq("EGAC_APP")
|
41
48
|
target.new(icao, args).stations.class.should eq(Array)
|
42
49
|
end
|
43
50
|
|
44
51
|
it "should distinguish roles" do
|
45
|
-
|
46
|
-
icao = "WMKK"
|
52
|
+
icao = "EGAC"
|
47
53
|
args = {:pilots => false, :atc => true}
|
48
|
-
target.new(icao, args).stations.first[
|
54
|
+
target.new(icao, args).stations.first['callsign'].should eq("EGAC_APP")
|
49
55
|
target.new(icao, args).stations.class.should eq(Array)
|
50
56
|
args = {:pilots => true, :atc => false}
|
51
57
|
target.new(icao, args).stations.length.should be(0)
|
52
58
|
end
|
53
59
|
|
54
60
|
it "should combine all stations" do
|
55
|
-
|
56
|
-
icao = "LO"
|
61
|
+
icao = "EDU"
|
57
62
|
args = {:pilots => true, :atc => true}
|
58
|
-
target.new(icao, args).stations.first[
|
59
|
-
target.new(icao, args).stations.last[
|
60
|
-
target.new(icao, args).stations.
|
61
|
-
target.new(icao, args).stations.
|
63
|
+
target.new(icao, args).stations.first['callsign'].should eq("AFR352")
|
64
|
+
target.new(icao, args).stations.last['callsign'].should eq("EDUU_W_CTR")
|
65
|
+
target.new(icao, args).stations.first['flight_plan']['departure'].should eq("EDUU")
|
66
|
+
target.new(icao, args).stations.first['flight_plan']['arrival'].should eq("LSGG")
|
62
67
|
target.new(icao, args).stations.class.should eq(Array)
|
63
|
-
target.new(icao, args).stations.count.should eq(
|
68
|
+
target.new(icao, args).stations.count.should eq(2)
|
64
69
|
args = {:pilots => false, :atc => true}
|
65
|
-
target.new(icao, args).stations.count.should eq(
|
70
|
+
target.new(icao, args).stations.count.should eq(1)
|
66
71
|
end
|
67
72
|
end
|
68
73
|
|
69
74
|
describe "station_objects" do
|
70
75
|
it "should return an array of Station objects" do
|
71
|
-
gem_data_file
|
72
76
|
icao = "LO"
|
73
77
|
target.new(icao).station_objects.class.should eq(Array)
|
74
|
-
target.new(icao).station_objects.size.should eq(
|
78
|
+
target.new(icao).station_objects.size.should eq(1)
|
75
79
|
args = {:pilots => false}
|
76
80
|
target.new(icao, args).station_objects.size.should eq(0)
|
77
81
|
args = {:atc => false}
|
78
|
-
target.new(icao, args).station_objects.size.should eq(
|
82
|
+
target.new(icao, args).station_objects.size.should eq(1)
|
79
83
|
target.new(icao, args).station_objects.first.class.should eq(VatsimTools::Station)
|
80
|
-
target.new(icao, args).station_objects.first.callsign.should eq("
|
84
|
+
target.new(icao, args).station_objects.first.callsign.should eq("VFE1625")
|
81
85
|
end
|
82
86
|
end
|
83
87
|
|
84
88
|
describe "sorted_station_objects" do
|
85
89
|
it "should return an hash with arrays of Station objects" do
|
86
|
-
|
87
|
-
icao = "WM"
|
90
|
+
icao = "ED"
|
88
91
|
target.new(icao).sorted_station_objects.class.should eq(Hash)
|
89
92
|
target.new(icao).sorted_station_objects.size.should eq(4)
|
90
93
|
target.new(icao).sorted_station_objects[:atc].class.should eq(Array)
|
91
94
|
target.new(icao).sorted_station_objects[:pilots].class.should eq(Array)
|
92
|
-
target.new(icao).sorted_station_objects[:pilots].size.should eq(
|
95
|
+
target.new(icao).sorted_station_objects[:pilots].size.should eq(1)
|
93
96
|
target.new(icao).sorted_station_objects[:atc].size.should eq(4)
|
94
97
|
target.new(icao).sorted_station_objects[:atc].first.class.should eq(VatsimTools::Station)
|
95
98
|
end
|
96
99
|
|
97
100
|
it "should handle roles" do
|
98
|
-
|
99
|
-
icao = "WM"
|
101
|
+
icao = "ED"
|
100
102
|
atc = {:pilots => false}
|
101
103
|
pilots = {:atc => false}
|
102
104
|
target.new(icao, atc).sorted_station_objects.class.should eq(Hash)
|
@@ -107,53 +109,49 @@ describe VatsimTools::StationParser do
|
|
107
109
|
target.new(icao, atc).sorted_station_objects[:pilots].size.should eq(0)
|
108
110
|
target.new(icao, atc).sorted_station_objects[:atc].size.should eq(4)
|
109
111
|
target.new(icao, pilots).sorted_station_objects[:atc].size.should eq(0)
|
110
|
-
target.new(icao, pilots).sorted_station_objects[:pilots].size.should eq(
|
111
|
-
target.new(icao, atc).sorted_station_objects[:atc].first.callsign.should eq("
|
112
|
+
target.new(icao, pilots).sorted_station_objects[:pilots].size.should eq(1)
|
113
|
+
target.new(icao, atc).sorted_station_objects[:atc].first.callsign.should eq("EDUU_W_CTR")
|
112
114
|
end
|
113
115
|
|
114
116
|
it "should recognize arrivals and departures" do
|
115
|
-
gem_data_file
|
116
117
|
icao = "LO"
|
117
|
-
target.new(icao).sorted_station_objects[:pilots].size.should eq(
|
118
|
+
target.new(icao).sorted_station_objects[:pilots].size.should eq(1)
|
118
119
|
target.new(icao).sorted_station_objects[:pilots].size.should eq(target.new(icao).sorted_station_objects[:arrivals].size + target.new(icao).sorted_station_objects[:departures].size)
|
119
|
-
target.new(icao).sorted_station_objects[:arrivals].size.should eq(
|
120
|
-
target.new(icao).sorted_station_objects[:departures].size.should eq(
|
120
|
+
target.new(icao).sorted_station_objects[:arrivals].size.should eq(0)
|
121
|
+
target.new(icao).sorted_station_objects[:departures].size.should eq(1)
|
121
122
|
end
|
122
123
|
|
123
124
|
it "should recognize exclusions" do
|
124
|
-
|
125
|
-
icao = "LB"
|
125
|
+
icao = "ED"
|
126
126
|
target.new(icao).sorted_station_objects[:atc].size.should eq(4)
|
127
|
-
args = {:exclude => "
|
128
|
-
target.new(icao, args).excluded.should eq("
|
127
|
+
args = {:exclude => "EDBB"}
|
128
|
+
target.new(icao, args).excluded.should eq("EDBB")
|
129
129
|
target.new(icao, args).excluded.length.should eq(4)
|
130
130
|
target.new(icao, args).sorted_station_objects[:atc].size.should eq(3)
|
131
|
-
args = {:exclude => "
|
131
|
+
args = {:exclude => "EDGG"}
|
132
132
|
target.new(icao, args).sorted_station_objects[:atc].size.should eq(2)
|
133
|
-
args = {:exclude => "
|
133
|
+
args = {:exclude => "edgg"}
|
134
134
|
target.new(icao, args).sorted_station_objects[:atc].size.should eq(2)
|
135
135
|
end
|
136
136
|
|
137
137
|
it "should support multiple icaos" do
|
138
|
-
|
139
|
-
icao = "LB"
|
138
|
+
icao = "ED"
|
140
139
|
target.new(icao).sorted_station_objects[:atc].size.should eq(4)
|
140
|
+
target.new(icao).sorted_station_objects[:pilots].size.should eq(1)
|
141
|
+
icao = "EG"
|
142
|
+
target.new(icao).sorted_station_objects[:pilots].size.should eq(1)
|
143
|
+
target.new(icao).sorted_station_objects[:atc].size.should eq(1)
|
144
|
+
icao = "ED,EG"
|
141
145
|
target.new(icao).sorted_station_objects[:pilots].size.should eq(2)
|
142
|
-
icao
|
143
|
-
|
144
|
-
target.new(icao).sorted_station_objects[:
|
145
|
-
|
146
|
-
icao = "
|
147
|
-
target.new(icao).sorted_station_objects[:pilots].size.should eq(
|
148
|
-
target.new(icao).sorted_station_objects[:
|
149
|
-
icao
|
150
|
-
target.new(icao).sorted_station_objects[:
|
151
|
-
target.new(icao).sorted_station_objects[:atc].size.should eq(4)
|
152
|
-
icao = "LO , LB"
|
153
|
-
target.new(icao).sorted_station_objects[:pilots].size.should eq(14)
|
154
|
-
target.new(icao).sorted_station_objects[:arrivals].size.should eq(7)
|
155
|
-
target.new(icao).sorted_station_objects[:departures].size.should eq(7)
|
156
|
-
target.new(icao).sorted_station_objects[:atc].size.should eq(4)
|
146
|
+
target.new(icao).sorted_station_objects[:atc].size.should eq(5)
|
147
|
+
icao = "ED, EG"
|
148
|
+
target.new(icao).sorted_station_objects[:pilots].size.should eq(2)
|
149
|
+
target.new(icao).sorted_station_objects[:atc].size.should eq(5)
|
150
|
+
icao = "ED , EG"
|
151
|
+
target.new(icao).sorted_station_objects[:pilots].size.should eq(2)
|
152
|
+
target.new(icao).sorted_station_objects[:arrivals].size.should eq(1)
|
153
|
+
target.new(icao).sorted_station_objects[:departures].size.should eq(1)
|
154
|
+
target.new(icao).sorted_station_objects[:atc].size.should eq(5)
|
157
155
|
end
|
158
156
|
|
159
157
|
end
|