vatsim_online_redux 1.0.0

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.
@@ -0,0 +1,157 @@
1
+ require 'spec_helper.rb'
2
+ require 'vatsim_online_spec_helper.rb'
3
+
4
+ describe VatsimOnline do
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\"")
25
+ end
26
+
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)
33
+ end
34
+ end
35
+
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)
46
+
47
+ end
48
+
49
+ it "should be case insensitive" do
50
+ gem_data_file
51
+ "amz1105".vatsim_callsign.first.callsign.should eq("AMZ1105")
52
+ end
53
+ end
54
+
55
+ end
56
+
57
+
58
+ describe VatsimTools::Station do
59
+
60
+ describe "new object" do
61
+ it "should return proper attributes" do
62
+ gem_data_file
63
+ icao = "WMKK"
64
+ station = VatsimTools::StationParser.new(icao).stations.first
65
+ 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
+ end
78
+
79
+ it "should parse Ruby time with online_since attr" do
80
+ gem_data_file
81
+ icao = "LBWN"
82
+ station = VatsimTools::StationParser.new(icao).sorted_station_objects[:atc].first
83
+ station.logon.should eq("20120722091954")
84
+ station.online_since.class.should eq(Time)
85
+ 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")
88
+ end
89
+ end
90
+
91
+ describe "pilot object" do
92
+ it "should contain all attributes" do
93
+ gem_data_file
94
+ icao = "EGLL"
95
+ station = VatsimTools::StationParser.new(icao).stations.first
96
+ 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")
111
+ end
112
+
113
+ it "should generate gcmap link" do
114
+ gem_data_file
115
+ icao = "EGLL"
116
+ station = VatsimTools::StationParser.new(icao).stations.first
117
+ 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\"")
119
+ end
120
+
121
+ it "should handle resized gcmap" do
122
+ gem_data_file
123
+ icao = "EGLL"
124
+ args = {}
125
+ args[:gcmap_width] = "400"
126
+ args[:gcmap_height] = "400"
127
+ station = VatsimTools::StationParser.new(icao).stations.first
128
+ new_object = VatsimTools::Station.new(station, args)
129
+ new_object.gcmap_width.should eq(400)
130
+ 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\"")
132
+
133
+ end
134
+
135
+ end
136
+
137
+ describe "atc object" do
138
+ it "should handle regular and humanized atis" do
139
+ gem_data_file
140
+ icao = "LBWN"
141
+ 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")
146
+ end
147
+
148
+ it "should handle no ATC remark" do
149
+ gem_data_file
150
+ icao = "NZAA"
151
+ 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")
154
+ end
155
+ end
156
+
157
+ end
@@ -0,0 +1,10 @@
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
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/vatsim_online/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Svilen Vassilev", "Alex Dent"]
6
+ gem.email = ["alex@flightleveltech.co.nz"]
7
+ gem.description = %q{Updated version of original gem by Svilen Vassilev. Selectively pulls and parses Vatsim online stations data. Essentially it's a 'who's online' library, capable of displaying online ATC and/or pilots for given airports, areas or globally. Stations are returned as objects, exposing a rich set of attributes. Vatsim data is pulled on preset intervals and cached locally to avoid flooding the servers.}
8
+ gem.summary = %q{Updated version of original gem by Svilen Vassilev. Selectively pulls and parses Vatsim online stations data. Essentially it's a 'who's online' library, capable of displaying online ATC and/or pilots for given airports, areas or globally. Stations are returned as objects, exposing a rich set of attributes. Vatsim data is pulled on preset intervals and cached locally to avoid flooding the servers.}
9
+ gem.homepage = "https://github.com/tarakanbg/vatsim_online"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "vatsim_online_redux"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = VatsimOnline::VERSION
17
+ gem.license = 'MIT'
18
+
19
+ gem.add_development_dependency "rspec"
20
+ gem.add_development_dependency "rake"
21
+ gem.add_development_dependency "libnotify"
22
+ gem.add_development_dependency "rb-inotify"
23
+ gem.add_dependency "time_diff", "~> 0.3.0"
24
+ gem.add_dependency "gcmapper", "~> 0.4.0"
25
+ end
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vatsim_online_redux
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Svilen Vassilev
8
+ - Alex Dent
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2020-03-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: libnotify
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rb-inotify
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: time_diff
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: 0.3.0
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: 0.3.0
84
+ - !ruby/object:Gem::Dependency
85
+ name: gcmapper
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: 0.4.0
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: 0.4.0
98
+ description: Updated version of original gem by Svilen Vassilev. Selectively pulls
99
+ and parses Vatsim online stations data. Essentially it's a 'who's online' library,
100
+ capable of displaying online ATC and/or pilots for given airports, areas or globally.
101
+ Stations are returned as objects, exposing a rich set of attributes. Vatsim data
102
+ is pulled on preset intervals and cached locally to avoid flooding the servers.
103
+ email:
104
+ - alex@flightleveltech.co.nz
105
+ executables: []
106
+ extensions: []
107
+ extra_rdoc_files: []
108
+ files:
109
+ - ".gitignore"
110
+ - ".rspec"
111
+ - ".travis.yml"
112
+ - CHANGELOG.md
113
+ - CONTRIBUTING.md
114
+ - Gemfile
115
+ - LICENSE
116
+ - README.md
117
+ - Rakefile
118
+ - lib/vatsim_online.rb
119
+ - lib/vatsim_online/callsign_parser.rb
120
+ - lib/vatsim_online/data_downloader.rb
121
+ - lib/vatsim_online/station.rb
122
+ - lib/vatsim_online/station_parser.rb
123
+ - lib/vatsim_online/version.rb
124
+ - spec/callsign_parser_spec.rb
125
+ - spec/callsign_parser_spec_helper.rb
126
+ - spec/data_downloader_spec.rb
127
+ - spec/data_downloader_spec_helper.rb
128
+ - spec/spec_helper.rb
129
+ - spec/station_parser_spec.rb
130
+ - spec/station_parser_spec_helper.rb
131
+ - spec/vatsim_data.txt
132
+ - spec/vatsim_online_spec.rb
133
+ - spec/vatsim_online_spec_helper.rb
134
+ - vatsim_online_redux.gemspec
135
+ homepage: https://github.com/tarakanbg/vatsim_online
136
+ licenses:
137
+ - MIT
138
+ metadata: {}
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubygems_version: 3.0.3
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: Updated version of original gem by Svilen Vassilev. Selectively pulls and
158
+ parses Vatsim online stations data. Essentially it's a 'who's online' library, capable
159
+ of displaying online ATC and/or pilots for given airports, areas or globally. Stations
160
+ are returned as objects, exposing a rich set of attributes. Vatsim data is pulled
161
+ on preset intervals and cached locally to avoid flooding the servers.
162
+ test_files:
163
+ - spec/callsign_parser_spec.rb
164
+ - spec/callsign_parser_spec_helper.rb
165
+ - spec/data_downloader_spec.rb
166
+ - spec/data_downloader_spec_helper.rb
167
+ - spec/spec_helper.rb
168
+ - spec/station_parser_spec.rb
169
+ - spec/station_parser_spec_helper.rb
170
+ - spec/vatsim_data.txt
171
+ - spec/vatsim_online_spec.rb
172
+ - spec/vatsim_online_spec_helper.rb