vatsim_online 0.7.2 → 0.7.3
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/LICENSE +1 -1
- data/lib/vatsim_online/data_downloader.rb +41 -4
- data/lib/vatsim_online/version.rb +1 -1
- data/spec/vatsim_status.txt +37 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b46af2eca79ef3d6cb4f281199a14991037a52b8
|
4
|
+
data.tar.gz: 5d3108071c3b9178cc2f866bcc090f247a7ad9e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc2d0a9332b50fbdd92cfbf4b67dd6c8c30c593c487528aba643451eaea71968bb8ae211e1e721256c19edd39b6c3cc79385d4ec623325c06aa40425475eab51
|
7
|
+
data.tar.gz: 8329dd17c86981339eadf161a3ad22ba3203c09681570f6099c96dbd4d9127a3a2d3cead17b70401f08f482ea4deba1fe7bb27f033b6d18e541776097fc4a2fb
|
data/LICENSE
CHANGED
@@ -13,10 +13,19 @@ module VatsimTools
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def create_status_tempfile
|
16
|
+
curl = Curl::Easy.new(STATUS_URL)
|
17
|
+
curl.timeout = 5
|
18
|
+
curl.perform
|
19
|
+
curl = curl.body_str
|
16
20
|
status = Tempfile.new('vatsim_status')
|
17
21
|
File.rename status.path, LOCAL_STATUS
|
18
|
-
File.open(LOCAL_STATUS, "w+") {|f| f.write(
|
22
|
+
File.open(LOCAL_STATUS, "w+") {|f| f.write(curl) }
|
19
23
|
File.chmod(0777, LOCAL_STATUS)
|
24
|
+
dummy_status if curl.include? "<html><head>"
|
25
|
+
rescue Curl::Err::HostResolutionError
|
26
|
+
dummy_status
|
27
|
+
rescue Curl::Err::TimeoutError
|
28
|
+
dummy_status
|
20
29
|
end
|
21
30
|
|
22
31
|
def read_status_tempfile
|
@@ -37,11 +46,20 @@ module VatsimTools
|
|
37
46
|
end
|
38
47
|
|
39
48
|
def create_local_data_file
|
49
|
+
curl = Curl::Easy.new(servers.sample)
|
50
|
+
curl.timeout = 5
|
51
|
+
curl.perform
|
52
|
+
curl = curl.body_str
|
40
53
|
data = Tempfile.new('vatsim_data', :encoding => 'utf-8')
|
41
54
|
File.rename data.path, LOCAL_DATA
|
42
|
-
data =
|
55
|
+
data = curl.gsub(/["]/, '\s').encode!('UTF-16', 'UTF-8', :invalid => :replace, :replace => '').encode!('UTF-8', 'UTF-16')
|
43
56
|
File.open(LOCAL_DATA, "w+") {|f| f.write(data)}
|
44
57
|
File.chmod(0777, LOCAL_DATA)
|
58
|
+
gem_data_file if curl.include? "<html><head>"
|
59
|
+
rescue Curl::Err::HostResolutionError
|
60
|
+
gem_data_file
|
61
|
+
rescue Curl::Err::TimeoutError
|
62
|
+
gem_data_file
|
45
63
|
end
|
46
64
|
|
47
65
|
def read_local_datafile
|
@@ -50,11 +68,30 @@ module VatsimTools
|
|
50
68
|
difference > 2 ? create_local_data_file : data.read
|
51
69
|
end
|
52
70
|
|
53
|
-
def data_file
|
71
|
+
def data_file
|
54
72
|
File.exists?(LOCAL_DATA) ? read_local_datafile : create_local_data_file
|
55
|
-
LOCAL_DATA
|
73
|
+
LOCAL_DATA
|
56
74
|
end
|
57
75
|
|
76
|
+
def gem_data_file
|
77
|
+
path = File.realpath("spec/vatsim_data.txt")
|
78
|
+
gem_data = File.open(path, :encoding => 'iso-8859-15').read
|
79
|
+
data = Tempfile.new('vatsim_data', :encoding => 'iso-8859-15')
|
80
|
+
data.write(gem_data.gsub(/["]/, '\s').force_encoding('iso-8859-15'))
|
81
|
+
File.rename data.path, "#{Dir.tmpdir}/vatsim_data.txt"
|
82
|
+
File.chmod(0777, LOCAL_DATA)
|
83
|
+
end
|
84
|
+
|
85
|
+
def dummy_status
|
86
|
+
path = File.realpath("spec/vatsim_status.txt")
|
87
|
+
gem_data = File.open(path, :encoding => 'iso-8859-15').read
|
88
|
+
data = Tempfile.new('vatsim_status', :encoding => 'iso-8859-15')
|
89
|
+
data.write(gem_data.gsub(/["]/, '\s').force_encoding('iso-8859-15'))
|
90
|
+
File.rename data.path, "#{Dir.tmpdir}/vatsim_status.txt"
|
91
|
+
File.chmod(0777, LOCAL_STATUS)
|
92
|
+
end
|
93
|
+
|
94
|
+
|
58
95
|
end
|
59
96
|
|
60
97
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
; IMPORTANT NOTE: to use less bandwidth, please download this file ONE TIME ONLY when
|
2
|
+
; your application starts, and load it locally
|
3
|
+
;
|
4
|
+
; Data formats are:
|
5
|
+
;
|
6
|
+
; 120128:NOTCP - used by WhazzUp only
|
7
|
+
; msg0 - message to be displayed at application startup
|
8
|
+
; url0 - URLs where complete data files are available. Please choose one randomly every time
|
9
|
+
; url1 - URLs where servers list data files are available. Please choose one randomly every time
|
10
|
+
; moveto0 - URL where to retrieve a more updated status.txt file that overrides this one
|
11
|
+
; metar0 - URL where to retrieve metar. Invoke it passing a parameter like for example: http://data.satita.net/metar.html?id=KBOS
|
12
|
+
; atis0 - URL where to retrieve atis. Invoke it passing a parameter like for example: http://data.satita.net/atis.html?callsign=BOS_CTR
|
13
|
+
; WARNING: please don't abuse it. Requests take network bandwidth. If possibile please use atis that are present into satnet-data.txt file
|
14
|
+
; user0 - URL where to retrieve statistics web pages
|
15
|
+
;
|
16
|
+
;
|
17
|
+
120218:NOTCP
|
18
|
+
;
|
19
|
+
url0=http://www.pcflyer.net/DataFeed/vatsim-data.txt
|
20
|
+
url0=http://www.klain.net/sidata/vatsim-data.txt
|
21
|
+
url0=http://fsproshop.com/servinfo/vatsim-data.txt
|
22
|
+
url0=http://info.vroute.net/vatsim-data.txt
|
23
|
+
url0=http://data.vattastic.com/vatsim-data.txt
|
24
|
+
;
|
25
|
+
url1=http://www.net-flyer.net/DataFeed/vatsim-servers.txt
|
26
|
+
url1=http://www.klain.net/sidata/vatsim-servers.txt
|
27
|
+
url1=http://fsproshop.com/servinfo/vatsim-servers.txt
|
28
|
+
url1=http://info.vroute.net/vatsim-servers.txt
|
29
|
+
url1=http://data.vattastic.com/vatsim-servers.txt
|
30
|
+
;
|
31
|
+
metar0=http://metar.vatsim.net/metar.php
|
32
|
+
;
|
33
|
+
atis0=http://stats.vatsim.net/atis.html
|
34
|
+
;
|
35
|
+
user0=http://stats.vatsim.net/search_id.php
|
36
|
+
;
|
37
|
+
; END
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vatsim_online
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Svilen Vassilev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- spec/station_parser_spec_helper.rb
|
169
169
|
- spec/vatsim_data.txt
|
170
170
|
- spec/vatsim_online_spec.rb
|
171
|
+
- spec/vatsim_status.txt
|
171
172
|
- vatsim_online.gemspec
|
172
173
|
homepage: https://github.com/tarakanbg/vatsim_online
|
173
174
|
licenses:
|
@@ -205,3 +206,4 @@ test_files:
|
|
205
206
|
- spec/station_parser_spec_helper.rb
|
206
207
|
- spec/vatsim_data.txt
|
207
208
|
- spec/vatsim_online_spec.rb
|
209
|
+
- spec/vatsim_status.txt
|