vatsim_online_redux 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +16 -135
- data/lib/vatsim_online.rb +9 -1
- data/lib/vatsim_online/callsign_regex_parser.rb +60 -0
- data/lib/vatsim_online/data_downloader.rb +2 -2
- data/lib/vatsim_online/version.rb +1 -1
- data/spec/callsign_regex_parser_spec.rb +43 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d505183669064d084f065ca8c896f478f3a354c6dafaadb122247a6fe3046994
|
4
|
+
data.tar.gz: a5d677876441ce1dd4d9767f5b67e148d8d83debf31ed0305b772fe743b6b0ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92484572574fd1601e71a1fd1459bc7b098a3fa9dfc256167e49d2c3f0994ad13e527f24aad2687c6896e186ef7b0ca24731843edb05617e1fd504cd04713bf4
|
7
|
+
data.tar.gz: 8e25ae33b56267319781102c633ebff20dffb3ec8e4207c7c8319f5866214b457f96ea538aa139e18b8d3918c301c3366f484d2ebe3ed22a8e5ee1ef80bcc17a
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,23 @@
|
|
2
2
|
|
3
3
|
## Changelog
|
4
4
|
|
5
|
+
### v. 2.1.0 - 20 Apr 2021
|
6
|
+
|
7
|
+
* Added the new vatsim_regex_callsign method
|
8
|
+
* Updated refresh time for data from 3 minutes to 60 seconds
|
9
|
+
|
10
|
+
### v. 2.0.1 - 30 Jan 2021
|
11
|
+
|
12
|
+
* Updated the code to use the new VATSIM Json data feed
|
13
|
+
|
14
|
+
### v. 1.0.1 - 30 Mar 2020
|
15
|
+
|
16
|
+
* Small bugfix to the 1.0.0 release
|
17
|
+
|
18
|
+
### v. 1.0.0 - 30 Mar 2020
|
19
|
+
|
20
|
+
* Updating code to work better with Windows environments
|
21
|
+
|
5
22
|
### v. 0.9.1 - 31 Dec 2016
|
6
23
|
|
7
24
|
* Maintenance release, updated dependencies
|
data/README.md
CHANGED
@@ -11,10 +11,7 @@ online ATC and/or pilots for given airports, areas or globally and to filter by
|
|
11
11
|
returned as objects, exposing a rich set of attributes. Vatsim data is pulled
|
12
12
|
on preset intervals and cached locally to avoid flooding the servers.
|
13
13
|
|
14
|
-
[![
|
15
|
-
[![Gemnasium](https://gemnasium.com/tarakanbg/vatsim_online.png?travis)](https://gemnasium.com/tarakanbg/vatsim_online)
|
16
|
-
[![Gem Version](https://badge.fury.io/rb/vatsim_online.png)](http://badge.fury.io/rb/vatsim_online)
|
17
|
-
[![Code Climate](https://codeclimate.com/github/tarakanbg/vatsim_online.png)](https://codeclimate.com/github/tarakanbg/vatsim_online)
|
14
|
+
[![Gem Version](https://badge.fury.io/rb/vatsim_online_redux.png)](http://badge.fury.io/rb/vatsim_online_redux)
|
18
15
|
|
19
16
|
## Requirements
|
20
17
|
|
@@ -48,6 +45,11 @@ any string (or variable containing a string) representing a full or partial pilo
|
|
48
45
|
callsign or a comma-separated list of callsigns. The provided callsign or fragment
|
49
46
|
will be used as a search criteria and matched against the current vatsim data.
|
50
47
|
|
48
|
+
* `vatsim_regex_callsign`, which can be applied to
|
49
|
+
any string (or variable containing a string) representing a regular expression or
|
50
|
+
a comma-separated list of regular expressions.
|
51
|
+
The provided regex will be used as a search criteria and matched against the current vatsim data.
|
52
|
+
|
51
53
|
### Filter by ICAO code examples
|
52
54
|
|
53
55
|
For example if you want to retrieve all active stations (ATC positions and pilots)
|
@@ -103,6 +105,13 @@ callsign = "BAW, RYR"
|
|
103
105
|
callsign.vatsim_callsign # => returns an array of all Speedbird and Ryanair flights as station objects
|
104
106
|
```
|
105
107
|
|
108
|
+
### Filter by regex examples
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
# Attaching the method directly to a string:
|
112
|
+
'BAW\d{3}'.vatsim_regex_callsign # => returns an array of all Speedbird flights with a 3 digit flight number as station objects
|
113
|
+
```
|
114
|
+
|
106
115
|
|
107
116
|
### Anatomy of method returns
|
108
117
|
|
@@ -142,7 +151,7 @@ p1.remarks #=> "/V/ RMK/CHARTS"
|
|
142
151
|
want to loop through them separately. The `pilots` array contains all arrivals
|
143
152
|
and departures.
|
144
153
|
|
145
|
-
The `vatsim_callsign`
|
154
|
+
The `vatsim_callsign` and `vatsim_regex_callsign` methods return an **array** of all matching stations.
|
146
155
|
|
147
156
|
### Station attributes
|
148
157
|
|
@@ -320,7 +329,7 @@ end
|
|
320
329
|
|
321
330
|
* Vatsim status and data files are cached locally to reduce the load on vatsim
|
322
331
|
servers. Random server is chosen to retrieve the data each time. By default the
|
323
|
-
status file is updated once every 4 hours and the data file once every
|
332
|
+
status file is updated once every 4 hours and the data file once every minute
|
324
333
|
regardless of the number of incoming requests.
|
325
334
|
* The data is cached in your default TEMP directory (OS specific)
|
326
335
|
* All the data retrieval and caching logic is encapsulated in a separate class
|
@@ -335,134 +344,6 @@ front or after the identifiers or the commas, i.e. you can use
|
|
335
344
|
`"LO,LB".vatsim_online` or `"LO, LB".vatsim_online` or `"LO , LB".vatsim_online` with
|
336
345
|
the same result.
|
337
346
|
|
338
|
-
## Changelog
|
339
|
-
|
340
|
-
### v. 0.9.1 - 31 Dec 2016
|
341
|
-
|
342
|
-
* Maintenance release, updated dependencies
|
343
|
-
|
344
|
-
### v. 0.9 - 20 June 2015
|
345
|
-
|
346
|
-
* Fixed nil String bug, can select "ALL" (thanks to Pierre Ferran and Florian Rimoli)
|
347
|
-
|
348
|
-
### v. 0.8.3 - 10 April 2014
|
349
|
-
|
350
|
-
* Fix stale data bug, change data fallback logic
|
351
|
-
|
352
|
-
### v. 0.8.2 - 5 October 2013
|
353
|
-
|
354
|
-
* Handle undetermined position when drawing gcmap
|
355
|
-
|
356
|
-
### v. 0.8.1 - 5 October 2013
|
357
|
-
|
358
|
-
* Ignore prefile data
|
359
|
-
|
360
|
-
### v. 0.8 - 5 October 2013
|
361
|
-
|
362
|
-
* search by callsign implemented
|
363
|
-
|
364
|
-
### v. 0.7.4 - 2 August 2013
|
365
|
-
|
366
|
-
* fallback scenarios for offline data servers
|
367
|
-
|
368
|
-
### v. 0.7.2 - 15 July 2013
|
369
|
-
|
370
|
-
* added gemspec license declaration
|
371
|
-
|
372
|
-
### v. 0.7.1 - 15 July 2013
|
373
|
-
|
374
|
-
* more comprehensive ATC ratings list
|
375
|
-
* dependencies updated
|
376
|
-
|
377
|
-
### v. 0.7.0 - 26 February 2013
|
378
|
-
|
379
|
-
* added Ruby 2.0 support
|
380
|
-
|
381
|
-
### v. 0.6.2 - 4 January 2013
|
382
|
-
|
383
|
-
* updated gem dependencies
|
384
|
-
* refactored `Station` class for simplicity
|
385
|
-
|
386
|
-
### v. 0.6.1 - 08 October 2012
|
387
|
-
|
388
|
-
* Fixed pilot station duplication issue when using multiple ICAOs
|
389
|
-
|
390
|
-
### v. 0.6.0 - 08 October 2012
|
391
|
-
|
392
|
-
* The `vatsim_online` method now also supports a comma-separated list of full or
|
393
|
-
partial ICAO codes like this: `"LO,LB".vatsim_online`. This allows you to pull the
|
394
|
-
information for multiple airports or FIRs in a single request
|
395
|
-
* The comma-seprated list is not sensitive to whitespace, meaning you can use
|
396
|
-
`"LO,LB".vatsim_online` or `"LO, LB".vatsim_online` or `"LO , LB".vatsim_online` with
|
397
|
-
the same result
|
398
|
-
|
399
|
-
### v. 0.5.3 - 30 September 2012
|
400
|
-
|
401
|
-
* fixed bug with exceptions on missing ATC remark
|
402
|
-
|
403
|
-
### v. 0.5.2 - 29 September 2012
|
404
|
-
|
405
|
-
* fixed permissions bug on UNIX systems
|
406
|
-
|
407
|
-
### v. 0.5.1 - 23 September 2012
|
408
|
-
|
409
|
-
* bugfixes
|
410
|
-
|
411
|
-
### v. 0.5 - 23 September 2012
|
412
|
-
|
413
|
-
* New option `:exclude => "ICAO"` allowing further request customization by
|
414
|
-
excluding a matching subset of ATC stations from the listing. Read the documentation
|
415
|
-
for detailed explanation and examples
|
416
|
-
* New customized station attribute: `online_since`. Returns the station login time
|
417
|
-
parsed as a Ruby Time object in UTC (zulu time). As opposed to the `logon` attribute
|
418
|
-
which returns an unformatted, unparsed string such as `20120722091954`
|
419
|
-
* The `rating` station attribute is now humanized not to return just an integer,
|
420
|
-
but a readable version of the VATSIM rating, i.e. S1, S2, S3, C1, C3, I1, I3, etc...
|
421
|
-
* Added the possibility of customizing the great circle maps by optionally passing
|
422
|
-
parameters for width and height: `icao.vatsim_online(:gcmap_width => 400, :gcmap_height => 400)`.
|
423
|
-
Read the documentation for detailed explanation and examples
|
424
|
-
* New customized station attribute `atis_message`. It will return a humanized web safe
|
425
|
-
version of the ATC atis without the voice server info and with lines split with
|
426
|
-
`<br />` tags. As opposed to the original `atis` attribute, which returns raw atis,
|
427
|
-
as reported from VATSIM, including voice server as first line
|
428
|
-
|
429
|
-
### v. 0.4 - 27 August 2012
|
430
|
-
|
431
|
-
* GCMapper integration: this library now plays nicely with [gcmapper](https://rubygems.org/gems/gcmapper).
|
432
|
-
A new attribute is provided for the pilot stations: `.gcmap` which returns a great
|
433
|
-
circle map image url, depicting the GC route of the aircraft, its origin and destination,
|
434
|
-
its current position on the route, together with its current altitude and groundspeed.
|
435
|
-
Look at the example in the README section above.
|
436
|
-
* New station attributes: planned_altitude, transponder, heading, qnh_in, qnh_mb,
|
437
|
-
flight_type, cid, latitude_humanized, longitude_humanized
|
438
|
-
|
439
|
-
|
440
|
-
### v. 0.3 - 22 July 2012
|
441
|
-
|
442
|
-
* The hash returned by the `vatsim_online` method now includes 2 new arrays:
|
443
|
-
`arrivals` and `departures`. These two are returned separately for convenience,
|
444
|
-
in case you want to loop through them separately. The `pilots` array return is
|
445
|
-
unchanged and contains all arrivals and departures.
|
446
|
-
* New station attributes: latitude, longitude
|
447
|
-
* Improved UTF-8 conversion process
|
448
|
-
|
449
|
-
### v. 0.2 - 21 July 2012
|
450
|
-
|
451
|
-
* Station attribute `departure` is now renamed to `origin`
|
452
|
-
* UTF-8 is now enforced for all local caching and file/string manipulations, the
|
453
|
-
original Vatsim data is re-encoded
|
454
|
-
* Station ATIS is now cleaned of invalid and obscure characters
|
455
|
-
* Improved documentation
|
456
|
-
|
457
|
-
## Contributing
|
458
|
-
|
459
|
-
1. Fork it
|
460
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
461
|
-
3. Commit your changes (`git commit -am 'Added some feature'`)
|
462
|
-
4. Make sure all tests are passing!
|
463
|
-
5. Push to the branch (`git push origin my-new-feature`)
|
464
|
-
6. Create new Pull Request
|
465
|
-
|
466
347
|
## Credits
|
467
348
|
|
468
349
|
Copyright © 2016 [Svilen Vassilev](http://svilen.rubystudio.net)
|
@@ -473,6 +354,6 @@ Copyright © 2020 [Alex Dent](https://github.com/aldent95)
|
|
473
354
|
* [Florian Rimoli](https://github.com/Flox06)
|
474
355
|
* [Pierre Ferran](https://github.com/pierr3)
|
475
356
|
|
476
|
-
Released under the [MIT LICENSE](https://github.com/tarakanbg/
|
357
|
+
Released under the [MIT LICENSE](https://github.com/tarakanbg/vatsim_online_redux/blob/master/LICENSE)
|
477
358
|
|
478
359
|
Maps generated by the [Great Circle Mapper](http://www.gcmap.com/), copyright Karl L. Swartz
|
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
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module VatsimTools
|
2
|
+
|
3
|
+
class CallsignRegexParser
|
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_online/vatsim_data.json"
|
13
|
+
|
14
|
+
def initialize(callsign, args = nil)
|
15
|
+
VatsimTools::DataDownloader.new
|
16
|
+
# args.class == Hash ? @role = determine_role(args) : @role = "all"
|
17
|
+
@callsign = callsign.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
|
+
matching_stations = []
|
33
|
+
raw_data = File.read(LOCAL_DATA)
|
34
|
+
data = JSON.parse(raw_data)
|
35
|
+
pilots = data['pilots'].each {|p| p['role'] = 'pilot'}
|
36
|
+
controllers = data['controllers'].each {|p| p['role'] = 'controller'}
|
37
|
+
atis = data['atis'].each {|p| p['role'] = 'atis'}
|
38
|
+
stations = pilots + controllers + atis
|
39
|
+
stations.each do |station|
|
40
|
+
callsign = station['callsign']
|
41
|
+
@callsign.each do |cs|
|
42
|
+
matching_stations << station if Regexp.new(cs) =~ callsign[0...cs.length] # && client == "ATC") unless @role == "pilot"
|
43
|
+
# stations << row if (origin[0...icao.length] == icao || destination[0...icao.length] == icao) unless @role == "atc"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
matching_stations
|
47
|
+
end
|
48
|
+
|
49
|
+
def station_objects
|
50
|
+
station_objects= []
|
51
|
+
args = {}
|
52
|
+
args[:gcmap_width] = @gcmap_width if @gcmap_width
|
53
|
+
args[:gcmap_height] = @gcmap_height if @gcmap_height
|
54
|
+
stations.each {|station| station_objects << VatsimTools::Station.new(station, args) }
|
55
|
+
station_objects
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -94,8 +94,8 @@ require 'fileutils'
|
|
94
94
|
|
95
95
|
def read_local_datafile
|
96
96
|
data = File.open(LOCAL_DATA)
|
97
|
-
difference = Time.diff(data.ctime, Time.now)[:minute]
|
98
|
-
if difference >
|
97
|
+
difference = Time.diff(data.ctime, Time.now)[:second] + (Time.diff(data.ctime, Time.now)[:minute] * 60)
|
98
|
+
if difference > 60
|
99
99
|
d = create_local_data_file
|
100
100
|
else
|
101
101
|
d = data.read
|
@@ -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
|
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: 2.0
|
4
|
+
version: 2.1.0
|
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: 2021-
|
12
|
+
date: 2021-04-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -131,11 +131,13 @@ files:
|
|
131
131
|
- Rakefile
|
132
132
|
- lib/vatsim_online.rb
|
133
133
|
- lib/vatsim_online/callsign_parser.rb
|
134
|
+
- lib/vatsim_online/callsign_regex_parser.rb
|
134
135
|
- lib/vatsim_online/data_downloader.rb
|
135
136
|
- lib/vatsim_online/station.rb
|
136
137
|
- lib/vatsim_online/station_parser.rb
|
137
138
|
- lib/vatsim_online/version.rb
|
138
139
|
- spec/callsign_parser_spec.rb
|
140
|
+
- spec/callsign_regex_parser_spec.rb
|
139
141
|
- spec/data_downloader_spec.rb
|
140
142
|
- spec/data_downloader_spec_helper.rb
|
141
143
|
- spec/spec_helper.rb
|
@@ -174,6 +176,7 @@ summary: Updated version of original gem by Svilen Vassilev. Selectively pulls a
|
|
174
176
|
on preset intervals and cached locally to avoid flooding the servers.
|
175
177
|
test_files:
|
176
178
|
- spec/callsign_parser_spec.rb
|
179
|
+
- spec/callsign_regex_parser_spec.rb
|
177
180
|
- spec/data_downloader_spec.rb
|
178
181
|
- spec/data_downloader_spec_helper.rb
|
179
182
|
- spec/spec_helper.rb
|