vatsim_online_redux 1.0.1 → 2.0.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/lib/vatsim_online/callsign_parser.rb +13 -7
- 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/spec/callsign_parser_spec.rb +13 -7
- 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 +21 -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
data/spec/vatsim_online_spec.rb
CHANGED
@@ -1,54 +1,58 @@
|
|
1
1
|
require 'spec_helper.rb'
|
2
|
-
require '
|
2
|
+
require 'data_downloader_spec_helper'
|
3
3
|
|
4
4
|
describe VatsimOnline do
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
6
|
+
before(:each) do
|
7
|
+
delete_local_files
|
8
|
+
stub_request(:get, 'https://status.vatsim.net/status.json').
|
9
|
+
to_return(body: File.read(File.join(File.dirname(__FILE__), 'support', 'vatsim_status.json')), status: :ok)
|
10
|
+
stub_request(:get, 'https://data.vatsim.net:443/v3/vatsim-data.json').
|
11
|
+
to_return(body: File.read(File.join(File.dirname(__FILE__), 'support', 'vatsim_data.json')), status: :ok)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'vatsim_online' do
|
15
|
+
it 'should work :)' do
|
16
|
+
'ZGGG'.vatsim_online.class.should eq(Hash)
|
17
|
+
'LO'.vatsim_online.class.should eq(Hash)
|
18
|
+
'ED'.vatsim_online[:atc].size.should eq(4)
|
19
|
+
'EG'.vatsim_online[:pilots].size.should eq(1)
|
20
|
+
'EG'.vatsim_online(:pilots => true, :atc => true).class.should eq(Hash)
|
21
|
+
'EG'.vatsim_online(:pilots => true, :atc => true)[:atc].size.should eq(1)
|
22
|
+
'EG'.vatsim_online(:pilots => true, :atc => true)[:pilots].size.should eq(1)
|
23
|
+
'EG'.vatsim_online(:atc => false)[:atc].size.should eq(0)
|
24
|
+
'EG'.vatsim_online(:atc => false)[:pilots].size.should eq(1)
|
25
|
+
'EG'.vatsim_online(:pilots => false)[:atc].size.should eq(1)
|
26
|
+
'EG'.vatsim_online(:pilots => false)[:pilots].size.should eq(0)
|
27
|
+
|
28
|
+
'LO'.vatsim_online[:pilots].first.callsign.should eq('VFE1625')
|
29
|
+
'EG'.vatsim_online[:atc].first.callsign.should eq('EGAC_APP')
|
30
|
+
'LO'.vatsim_online(:gcmap_width => '400', :gcmap_height => '400')[:pilots].first.gcmap.should eq('http://www.gcmap.com/map?P=LOWS-N50.69043+E5.15406-EGBB%2C+"VFE1625%5Cn35669+ft%5Cn386+kts"%2B%40N50.69043+E5.15406%0d%0a&MS=wls&MR=120&MX=400x400&PM=b:disc7%2b"%25U%25+%28N"')
|
31
|
+
'LO'.vatsim_online(:gcmap_width => 400, :gcmap_height => 400)[:pilots].first.gcmap.should eq('http://www.gcmap.com/map?P=LOWS-N50.69043+E5.15406-EGBB%2C+"VFE1625%5Cn35669+ft%5Cn386+kts"%2B%40N50.69043+E5.15406%0d%0a&MS=wls&MR=120&MX=400x400&PM=b:disc7%2b"%25U%25+%28N"')
|
25
32
|
end
|
26
33
|
|
27
|
-
it
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
"lo".vatsim_online(:pilots => true, :atc => true)[:pilots].size.should eq(12)
|
34
|
+
it 'should be case insensitive' do
|
35
|
+
'eg'.vatsim_online[:atc].size.should eq(1)
|
36
|
+
'eg'.vatsim_online[:pilots].size.should eq(1)
|
37
|
+
'eg'.vatsim_online(:pilots => true, :atc => true)[:atc].size.should eq(1)
|
38
|
+
'eg'.vatsim_online(:pilots => true, :atc => true)[:pilots].size.should eq(1)
|
33
39
|
end
|
34
40
|
end
|
35
41
|
|
36
|
-
describe
|
37
|
-
it
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
"BAW, QFA".vatsim_callsign.size.should eq(21)
|
42
|
+
describe 'vatsim_callsign' do
|
43
|
+
it 'should work :)' do
|
44
|
+
'VFE1625'.vatsim_callsign.class.should eq(Array)
|
45
|
+
'VFE1625'.vatsim_callsign.size.should eq(1)
|
46
|
+
'VFE1625'.vatsim_callsign.first.callsign.should eq('VFE1625')
|
47
|
+
'DAL'.vatsim_callsign.size.should eq(1)
|
48
|
+
'DAL'.vatsim_callsign.last.callsign.should eq('DAL2136')
|
49
|
+
'DAL, ARG1458'.vatsim_callsign.size.should eq(2)
|
50
|
+
'DAL, SX'.vatsim_callsign.size.should eq(2)
|
46
51
|
|
47
52
|
end
|
48
53
|
|
49
|
-
it
|
50
|
-
|
51
|
-
"amz1105".vatsim_callsign.first.callsign.should eq("AMZ1105")
|
54
|
+
it 'should be case insensitive' do
|
55
|
+
'vfe1625'.vatsim_callsign.first.callsign.should eq('VFE1625')
|
52
56
|
end
|
53
57
|
end
|
54
58
|
|
@@ -57,100 +61,101 @@ end
|
|
57
61
|
|
58
62
|
describe VatsimTools::Station do
|
59
63
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
+
before(:each) do
|
65
|
+
delete_local_files
|
66
|
+
stub_request(:get, 'https://status.vatsim.net/status.json').
|
67
|
+
to_return(body: File.read(File.join(File.dirname(__FILE__), 'support', 'vatsim_status.json')), status: :ok)
|
68
|
+
stub_request(:get, 'https://data.vatsim.net:443/v3/vatsim-data.json').
|
69
|
+
to_return(body: File.read(File.join(File.dirname(__FILE__), 'support', 'vatsim_data.json')), status: :ok)
|
70
|
+
end
|
71
|
+
|
72
|
+
describe 'new object' do
|
73
|
+
it 'should return proper attributes' do
|
74
|
+
icao = 'EGAC'
|
64
75
|
station = VatsimTools::StationParser.new(icao).stations.first
|
65
76
|
new_object = VatsimTools::Station.new(station)
|
66
|
-
new_object.callsign.should eq(
|
67
|
-
new_object.name.should eq(
|
68
|
-
new_object.role.should eq(
|
69
|
-
new_object.frequency.should eq(
|
70
|
-
new_object.rating.should eq(
|
71
|
-
new_object.facility.should eq(
|
72
|
-
new_object.logon.should eq(
|
73
|
-
new_object.latitude.should eq(
|
74
|
-
new_object.latitude_humanized.should eq(
|
75
|
-
new_object.longitude.should eq(
|
76
|
-
new_object.longitude_humanized.should eq(
|
77
|
+
new_object.callsign.should eq('EGAC_APP')
|
78
|
+
new_object.name.should eq('Daniel Button')
|
79
|
+
new_object.role.should eq('controller')
|
80
|
+
new_object.frequency.should eq('130.850')
|
81
|
+
new_object.rating.should eq('C1')
|
82
|
+
new_object.facility.should eq('5')
|
83
|
+
new_object.logon.should eq('2021-01-29T19:11:14.4846565Z')
|
84
|
+
new_object.latitude.should eq('')
|
85
|
+
new_object.latitude_humanized.should eq(nil)
|
86
|
+
new_object.longitude.should eq('')
|
87
|
+
new_object.longitude_humanized.should eq(nil)
|
77
88
|
end
|
78
89
|
|
79
|
-
it
|
80
|
-
|
81
|
-
icao = "LBWN"
|
90
|
+
it 'should parse Ruby time with online_since attr' do
|
91
|
+
icao = 'UMMS'
|
82
92
|
station = VatsimTools::StationParser.new(icao).sorted_station_objects[:atc].first
|
83
|
-
station.logon.should eq(
|
93
|
+
station.logon.should eq('2021-01-29T19:11:13.0906448Z')
|
84
94
|
station.online_since.class.should eq(Time)
|
85
95
|
station.online_since.utc?.should eq(true)
|
86
|
-
station.online_since.should eq(
|
87
|
-
station.rating.should eq(
|
96
|
+
station.online_since.should eq('2021-01-29T19:11:13.0906448Z')
|
97
|
+
station.rating.should eq('S2')
|
88
98
|
end
|
89
99
|
end
|
90
100
|
|
91
|
-
describe
|
92
|
-
it
|
93
|
-
|
94
|
-
icao = "EGLL"
|
101
|
+
describe 'pilot object' do
|
102
|
+
it 'should contain all attributes' do
|
103
|
+
icao = 'LSGG'
|
95
104
|
station = VatsimTools::StationParser.new(icao).stations.first
|
96
105
|
new_object = VatsimTools::Station.new(station)
|
97
|
-
new_object.callsign.should eq(
|
98
|
-
new_object.name.should eq(
|
99
|
-
new_object.role.should eq(
|
100
|
-
new_object.latitude.should eq(
|
101
|
-
new_object.latitude_humanized.should eq(
|
102
|
-
new_object.longitude.should eq(
|
103
|
-
new_object.longitude_humanized.should eq(
|
104
|
-
new_object.planned_altitude.should eq(
|
105
|
-
new_object.transponder.should eq(
|
106
|
-
new_object.heading.should eq(
|
107
|
-
new_object.qnh_in.should eq(
|
108
|
-
new_object.qnh_mb.should eq(
|
109
|
-
new_object.flight_type.should eq(
|
110
|
-
new_object.cid.should eq(
|
106
|
+
new_object.callsign.should eq('AFR352')
|
107
|
+
new_object.name.should eq('Michel Matalon LSZH')
|
108
|
+
new_object.role.should eq('pilot')
|
109
|
+
new_object.latitude.should eq('44.99953')
|
110
|
+
new_object.latitude_humanized.should eq('N44.99953')
|
111
|
+
new_object.longitude.should eq('9.47403')
|
112
|
+
new_object.longitude_humanized.should eq('E9.47403')
|
113
|
+
new_object.planned_altitude.should eq('38000')
|
114
|
+
new_object.transponder.should eq('4107')
|
115
|
+
new_object.heading.should eq('300')
|
116
|
+
new_object.qnh_in.should eq('29.64')
|
117
|
+
new_object.qnh_mb.should eq('1004')
|
118
|
+
new_object.flight_type.should eq('I')
|
119
|
+
new_object.cid.should eq('1379490')
|
111
120
|
end
|
112
121
|
|
113
|
-
it
|
114
|
-
|
115
|
-
icao = "EGLL"
|
122
|
+
it 'should generate gcmap link' do
|
123
|
+
icao = 'LSGG'
|
116
124
|
station = VatsimTools::StationParser.new(icao).stations.first
|
117
125
|
new_object = VatsimTools::Station.new(station)
|
118
|
-
new_object.gcmap.should eq(
|
126
|
+
new_object.gcmap.should eq('http://www.gcmap.com/map?P=EDUU-N44.99953+E9.47403-LSGG%2C+"AFR352%5Cn37729+ft%5Cn425+kts"%2B%40N44.99953+E9.47403%0d%0a&MS=wls&MR=120&MX=720x360&PM=b:disc7%2b"%25U%25+%28N"')
|
119
127
|
end
|
120
128
|
|
121
|
-
it
|
122
|
-
|
123
|
-
icao = "EGLL"
|
129
|
+
it 'should handle resized gcmap' do
|
130
|
+
icao = 'LSGG'
|
124
131
|
args = {}
|
125
|
-
args[:gcmap_width] =
|
126
|
-
args[:gcmap_height] =
|
132
|
+
args[:gcmap_width] = '400'
|
133
|
+
args[:gcmap_height] = '400'
|
127
134
|
station = VatsimTools::StationParser.new(icao).stations.first
|
128
135
|
new_object = VatsimTools::Station.new(station, args)
|
129
136
|
new_object.gcmap_width.should eq(400)
|
130
137
|
new_object.gcmap_height.should eq(400)
|
131
|
-
new_object.gcmap.should eq(
|
138
|
+
new_object.gcmap.should eq('http://www.gcmap.com/map?P=EDUU-N44.99953+E9.47403-LSGG%2C+"AFR352%5Cn37729+ft%5Cn425+kts"%2B%40N44.99953+E9.47403%0d%0a&MS=wls&MR=120&MX=400x400&PM=b:disc7%2b"%25U%25+%28N"')
|
132
139
|
|
133
140
|
end
|
134
141
|
|
135
142
|
end
|
136
143
|
|
137
|
-
describe
|
138
|
-
it
|
139
|
-
|
140
|
-
icao = "LBWN"
|
144
|
+
describe 'atc object' do
|
145
|
+
it 'should handle regular and humanized atis' do
|
146
|
+
icao = 'EDBB'
|
141
147
|
station = VatsimTools::StationParser.new(icao).sorted_station_objects[:atc].first
|
142
|
-
station.logon.should eq(
|
143
|
-
station.rating.should eq(
|
144
|
-
station.atis.should eq(
|
145
|
-
station.atis_message.should eq(
|
148
|
+
station.logon.should eq('2021-01-29T19:11:13.2762054Z')
|
149
|
+
station.rating.should eq('C1')
|
150
|
+
station.atis.should eq('BERLIN DIRECTOR ON INTIAL CONTACT, STATE YOUR CALLSIGN ONLY')
|
151
|
+
station.atis_message.should eq('No published remark')
|
146
152
|
end
|
147
153
|
|
148
|
-
it
|
149
|
-
|
150
|
-
icao = "NZAA"
|
154
|
+
it 'should handle no ATC remark' do
|
155
|
+
icao = 'EDBB'
|
151
156
|
station = VatsimTools::StationParser.new(icao).sorted_station_objects[:atc].first
|
152
|
-
station.atis.should eq(
|
153
|
-
station.atis_message.should eq(
|
157
|
+
station.atis.should eq('BERLIN DIRECTOR ON INTIAL CONTACT, STATE YOUR CALLSIGN ONLY')
|
158
|
+
station.atis_message.should eq('No published remark')
|
154
159
|
end
|
155
160
|
end
|
156
161
|
|
data/vatsim_online_redux.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.add_development_dependency "rake"
|
21
21
|
gem.add_development_dependency "libnotify"
|
22
22
|
gem.add_development_dependency "rb-inotify"
|
23
|
+
gem.add_development_dependency "webmock"
|
23
24
|
gem.add_dependency "time_diff", "~> 0.3.0"
|
24
25
|
gem.add_dependency "gcmapper", "~> 0.4.0"
|
25
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vatsim_online_redux
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Svilen Vassilev
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-01-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -67,6 +67,20 @@ dependencies:
|
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: webmock
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
70
84
|
- !ruby/object:Gem::Dependency
|
71
85
|
name: time_diff
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,15 +136,14 @@ files:
|
|
122
136
|
- lib/vatsim_online/station_parser.rb
|
123
137
|
- lib/vatsim_online/version.rb
|
124
138
|
- spec/callsign_parser_spec.rb
|
125
|
-
- spec/callsign_parser_spec_helper.rb
|
126
139
|
- spec/data_downloader_spec.rb
|
127
140
|
- spec/data_downloader_spec_helper.rb
|
128
141
|
- spec/spec_helper.rb
|
129
142
|
- spec/station_parser_spec.rb
|
130
|
-
- spec/
|
143
|
+
- spec/support/vatsim_data.json
|
144
|
+
- spec/support/vatsim_status.json
|
131
145
|
- spec/vatsim_data.txt
|
132
146
|
- spec/vatsim_online_spec.rb
|
133
|
-
- spec/vatsim_online_spec_helper.rb
|
134
147
|
- vatsim_online_redux.gemspec
|
135
148
|
homepage: https://github.com/aldent95/vatsim_online_redux
|
136
149
|
licenses:
|
@@ -151,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
164
|
- !ruby/object:Gem::Version
|
152
165
|
version: '0'
|
153
166
|
requirements: []
|
154
|
-
rubygems_version: 3.
|
167
|
+
rubygems_version: 3.1.2
|
155
168
|
signing_key:
|
156
169
|
specification_version: 4
|
157
170
|
summary: Updated version of original gem by Svilen Vassilev. Selectively pulls and
|
@@ -161,12 +174,11 @@ summary: Updated version of original gem by Svilen Vassilev. Selectively pulls a
|
|
161
174
|
on preset intervals and cached locally to avoid flooding the servers.
|
162
175
|
test_files:
|
163
176
|
- spec/callsign_parser_spec.rb
|
164
|
-
- spec/callsign_parser_spec_helper.rb
|
165
177
|
- spec/data_downloader_spec.rb
|
166
178
|
- spec/data_downloader_spec_helper.rb
|
167
179
|
- spec/spec_helper.rb
|
168
180
|
- spec/station_parser_spec.rb
|
169
|
-
- spec/
|
181
|
+
- spec/support/vatsim_data.json
|
182
|
+
- spec/support/vatsim_status.json
|
170
183
|
- spec/vatsim_data.txt
|
171
184
|
- spec/vatsim_online_spec.rb
|
172
|
-
- spec/vatsim_online_spec_helper.rb
|
@@ -1,10 +0,0 @@
|
|
1
|
-
def gem_data_file
|
2
|
-
path = File.realpath("spec/vatsim_data.txt")
|
3
|
-
data_file = File.open(path, :encoding => 'iso-8859-15')
|
4
|
-
gem_data = data_file.read
|
5
|
-
data_file.close
|
6
|
-
data = Tempfile.new('vatsim_data', :encoding => 'iso-8859-15')
|
7
|
-
data.write(gem_data.gsub(/["]/, '\s').force_encoding('iso-8859-15'))
|
8
|
-
data.close
|
9
|
-
File.rename data.path, "#{Dir.tmpdir}/vatsim_data.txt"
|
10
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
def gem_data_file
|
2
|
-
path = File.realpath("spec/vatsim_data.txt")
|
3
|
-
data_file = File.open(path, :encoding => 'iso-8859-15')
|
4
|
-
gem_data = data_file.read
|
5
|
-
data_file.close
|
6
|
-
data = Tempfile.new('vatsim_data', :encoding => 'iso-8859-15')
|
7
|
-
data.write(gem_data.gsub(/["]/, '\s').force_encoding('iso-8859-15'))
|
8
|
-
data.close
|
9
|
-
File.rename data.path, "#{Dir.tmpdir}/vatsim_data.txt"
|
10
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
def gem_data_file
|
2
|
-
path = File.realpath("spec/vatsim_data.txt")
|
3
|
-
data_file = File.open(path, :encoding => 'iso-8859-15')
|
4
|
-
gem_data = data_file.read
|
5
|
-
data_file.close
|
6
|
-
data = Tempfile.new('vatsim_data', :encoding => 'iso-8859-15')
|
7
|
-
data.write(gem_data.gsub(/["]/, '\s').force_encoding('iso-8859-15'))
|
8
|
-
data.close
|
9
|
-
File.rename data.path, "#{Dir.tmpdir}/vatsim_data.txt"
|
10
|
-
end
|