vatsim_online_redux 1.0.1 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,13 @@
1
+ {
2
+ "data": {
3
+ "v3": [
4
+ "https://data.vatsim.net/v3/vatsim-data.json"
5
+ ]
6
+ },
7
+ "user": [
8
+ "https://stats.vatsim.net/search_id.php"
9
+ ],
10
+ "metar": [
11
+ "http://metar.vatsim.net/metar.php"
12
+ ]
13
+ }
@@ -1,54 +1,58 @@
1
1
  require 'spec_helper.rb'
2
- require 'vatsim_online_spec_helper.rb'
2
+ require 'data_downloader_spec_helper'
3
3
 
4
4
  describe VatsimOnline do
5
5
 
6
- describe "vatsim_online" do
7
- it "should work :)" do
8
- gem_data_file
9
- "ZGGG".vatsim_online.class.should eq(Hash)
10
- "LO".vatsim_online.class.should eq(Hash)
11
- "WM".vatsim_online[:atc].size.should eq(4)
12
- "LO".vatsim_online[:pilots].size.should eq(12)
13
- "LO".vatsim_online(:pilots => true, :atc => true).class.should eq(Hash)
14
- "LO".vatsim_online(:pilots => true, :atc => true)[:atc].size.should eq(0)
15
- "LO".vatsim_online(:pilots => true, :atc => true)[:pilots].size.should eq(12)
16
- "LO".vatsim_online(:atc => false)[:atc].size.should eq(0)
17
- "LO".vatsim_online(:atc => false)[:pilots].size.should eq(12)
18
- "WM".vatsim_online(:pilots => false)[:atc].size.should eq(4)
19
- "LO".vatsim_online(:pilots => false)[:pilots].size.should eq(0)
20
-
21
- "LO".vatsim_online[:pilots].first.callsign.should eq("AMZ1105")
22
- "WM".vatsim_online[:atc].first.callsign.should eq("WMKK_APP")
23
- "LO".vatsim_online(:gcmap_width => "400", :gcmap_height => "400")[:pilots].first.gcmap.should eq("http://www.gcmap.com/map?P=LOWW-N45.45676+E12.28972-LIPZ%2C+\"AMZ1105%5Cn1007+ft%5Cn128+kts\"%2B%40N45.45676+E12.28972%0d%0a&MS=wls&MR=120&MX=400x400&PM=b:disc7%2b\"%25U%25+%28N\"")
24
- "LO".vatsim_online(:gcmap_width => 400, :gcmap_height => 400)[:pilots].first.gcmap.should eq("http://www.gcmap.com/map?P=LOWW-N45.45676+E12.28972-LIPZ%2C+\"AMZ1105%5Cn1007+ft%5Cn128+kts\"%2B%40N45.45676+E12.28972%0d%0a&MS=wls&MR=120&MX=400x400&PM=b:disc7%2b\"%25U%25+%28N\"")
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 "should be case insensitive" do
28
- gem_data_file
29
- "wm".vatsim_online[:atc].size.should eq(4)
30
- "lo".vatsim_online[:pilots].size.should eq(12)
31
- "wm".vatsim_online(:pilots => true, :atc => true)[:atc].size.should eq(4)
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 "vatsim_callsign" do
37
- it "should work :)" do
38
- gem_data_file
39
- "AMZ1105".vatsim_callsign.class.should eq(Array)
40
- "AMZ1105".vatsim_callsign.size.should eq(1)
41
- "AMZ1105".vatsim_callsign.first.callsign.should eq("AMZ1105")
42
- "BAW".vatsim_callsign.size.should eq(15)
43
- "BAW".vatsim_callsign.last.callsign.should eq("BAW9DV")
44
- "BAW, AMZ1105".vatsim_callsign.size.should eq(16)
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 "should be case insensitive" do
50
- gem_data_file
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
- describe "new object" do
61
- it "should return proper attributes" do
62
- gem_data_file
63
- icao = "WMKK"
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("WMKK_APP")
67
- new_object.name.should eq("Adriel Loke")
68
- new_object.role.should eq("ATC")
69
- new_object.frequency.should eq("124.200")
70
- new_object.rating.should eq("S2")
71
- new_object.facility.should eq("5")
72
- new_object.logon.should eq("20120722092836")
73
- new_object.latitude.should eq("2.93968")
74
- new_object.latitude_humanized.should eq("N2.93968")
75
- new_object.longitude.should eq("101.39812")
76
- new_object.longitude_humanized.should eq("E101.39812")
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 "should parse Ruby time with online_since attr" do
80
- gem_data_file
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("20120722091954")
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("2012-07-22 09:19:54 UTC")
87
- station.rating.should eq("INS")
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 "pilot object" do
92
- it "should contain all attributes" do
93
- gem_data_file
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("AAL026")
98
- new_object.name.should eq("Manuel Santillan MMCU")
99
- new_object.role.should eq("PILOT")
100
- new_object.latitude.should eq("44.09780")
101
- new_object.latitude_humanized.should eq("N44.0978")
102
- new_object.longitude.should eq("-58.41483")
103
- new_object.longitude_humanized.should eq("W58.41483")
104
- new_object.planned_altitude.should eq("370")
105
- new_object.transponder.should eq("4122")
106
- new_object.heading.should eq("73")
107
- new_object.qnh_in.should eq("30.12")
108
- new_object.qnh_mb.should eq("1019")
109
- new_object.flight_type.should eq("I")
110
- new_object.cid.should eq("1210329")
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 "should generate gcmap link" do
114
- gem_data_file
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("http://www.gcmap.com/map?P=KDFW-N44.0978+W58.41483-EGLL%2C+\"AAL026%5Cn37210+ft%5Cn543+kts\"%2B%40N44.0978+W58.41483%0d%0a&MS=wls&MR=120&MX=720x360&PM=b:disc7%2b\"%25U%25+%28N\"")
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 "should handle resized gcmap" do
122
- gem_data_file
123
- icao = "EGLL"
129
+ it 'should handle resized gcmap' do
130
+ icao = 'LSGG'
124
131
  args = {}
125
- args[:gcmap_width] = "400"
126
- args[:gcmap_height] = "400"
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("http://www.gcmap.com/map?P=KDFW-N44.0978+W58.41483-EGLL%2C+\"AAL026%5Cn37210+ft%5Cn543+kts\"%2B%40N44.0978+W58.41483%0d%0a&MS=wls&MR=120&MX=400x400&PM=b:disc7%2b\"%25U%25+%28N\"")
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 "atc object" do
138
- it "should handle regular and humanized atis" do
139
- gem_data_file
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("20120722091954")
143
- station.rating.should eq("INS")
144
- station.atis.should eq("$ voice2.vacc-sag.org/lfmn_app. Nice Approach. Charts at www.tinyurl.com/chartsfr. Visit www.vatfrance.org")
145
- station.atis_message.should eq("Nice Approach<br />Charts at www.tinyurl.com/chartsfr<br />Visit www.vatfrance.org")
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 "should handle no ATC remark" do
149
- gem_data_file
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("$ rw1.vatpac.org/nzaa_twr")
153
- station.atis_message.should eq("No published remark")
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
 
@@ -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: 1.0.1
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: 2020-03-30 00:00:00.000000000 Z
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/station_parser_spec_helper.rb
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.0.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/station_parser_spec_helper.rb
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