tac_scribe 0.1.1 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 982a3d54dbd52c5d2bc541f58d09b6c0343f522a8d3b4ddcb399d9c575969043
4
- data.tar.gz: f4bb78f70f1993b5b427f7330f2be7b9621045edcc6875496a3e386ad0471c6e
3
+ metadata.gz: fbfc0be279d9733cd25267ab92c6becbf892281fb24900093e05d3b85c624777
4
+ data.tar.gz: 56a214ae80a0c7d1bfc52183a02bb3e0529eaf076648d04e1b63ae6f20f804f5
5
5
  SHA512:
6
- metadata.gz: 70d21673d4f39172e609a807d96c7caf9b74f1fd68361e659ab43e2c1a993b169cf05aaef71654c5f08971d69c7e582196f3eb9c41876d0666b8c6eba9b241ca
7
- data.tar.gz: d89e9d38ca8a73285316aac94067d251f28023634c3d10a5e8d2b651a98bac6a80c365281f4f66873350519cc65d98c6d15d7d246e9dddb213482ab653d937f8
6
+ metadata.gz: 5c5cfc5ad13980e00c54cf39ce499fdc77733454be1499594a55e4acfac42b9f4ea738c4f05144a3db21778eb71c8747c7d1813771e808684b8048c4564b71d5
7
+ data.tar.gz: 643fc7c958b7d2e5452651700d83ca677e8b56987bcd6a253697ccd39f9d1ef774e6971486acea9f2b97960d67616e911dd34e801f5a3377a8f6700d0720e06f
data/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.2.0] - 2019-10-13
10
+ ### Added
11
+ - JRuby support
12
+
13
+ ### Changed
14
+ - Improve logging of events with number of events processed.
15
+
16
+
17
+ ## [0.1.1] - 2019-09-05
18
+ ### Added
19
+ - Added Net::HTTP error handling
20
+
data/README.md CHANGED
@@ -41,6 +41,13 @@ See the `db` folder for information on running the database migrations.
41
41
 
42
42
  Bug reports and pull requests are welcome on GitLab at https://gitlab.com/overlord-bot/tac-scribe.
43
43
 
44
+ ### Adding Data
45
+
46
+ There are incomplete data-files for this project whose completion would
47
+ be very helpful. See the `data` folder. Current tasks needed are:
48
+
49
+ * Complete the list of all airfields in DCS with their position information
50
+
44
51
  ## License
45
52
 
46
53
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,121 @@
1
+ [{
2
+ "lon": 45.01909093846007,
3
+ "lat": 41.637735936261556,
4
+ "alt": 464.5004577636719,
5
+ "name": "Vaziani"
6
+ },
7
+ {
8
+ "lon": 44.94687659192431,
9
+ "lat": 41.67471935873423,
10
+ "alt": 479.69482421875,
11
+ "name": "Tbilisi-Lochini"
12
+ },
13
+ {
14
+ "lon": 43.62488628801948,
15
+ "lat": 43.50998473505967,
16
+ "alt": 430.01043701171875,
17
+ "name": "Nalchik"
18
+ },
19
+ {
20
+ "lon": 38.92520230077506,
21
+ "lat": 45.087429883845076,
22
+ "alt": 30.010032653808594,
23
+ "name": "Krasnodar-Center"
24
+ },
25
+ {
26
+ "lon": 37.35978347755592,
27
+ "lat": 45.01317473377168,
28
+ "alt": 43.00004196166992,
29
+ "name": "Anapa-Vityazevo"
30
+ },
31
+ {
32
+ "lon": 41.876483823101026,
33
+ "lat": 41.93210535345338,
34
+ "alt": 18.01001739501953,
35
+ "name": "Kobuleti"
36
+ },
37
+ {
38
+ "lon": 43.100679733081456,
39
+ "lat": 44.21864682380681,
40
+ "alt": 320.01031494140625,
41
+ "name": "Mineralnye Vody"
42
+ },
43
+ {
44
+ "lon": 44.62032726210201,
45
+ "lat": 43.79130325093825,
46
+ "alt": 154.61184692382812,
47
+ "name": "Mozdok"
48
+ },
49
+ {
50
+ "lon": 44.94718306531669,
51
+ "lat": 41.64116326678661,
52
+ "alt": 449.4102478027344,
53
+ "name": "Soganlug"
54
+ },
55
+ {
56
+ "lon": 44.588922553542936,
57
+ "lat": 43.20850098738094,
58
+ "alt": 524.0057983398438,
59
+ "name": "Beslan"
60
+ },
61
+ {
62
+ "lon": 42.49568635853585,
63
+ "lat": 42.179154028210135,
64
+ "alt": 45.010047912597656,
65
+ "name": "Kutaisi"
66
+ },
67
+ {
68
+ "lon": 37.786226060479564,
69
+ "lat": 44.6733296041269,
70
+ "alt": 40.010040283203125,
71
+ "name": "Novorossiysk"
72
+ },
73
+ {
74
+ "lon": 40.021427482235985,
75
+ "lat": 44.67144025735508,
76
+ "alt": 180.01019287109375,
77
+ "name": "Maykop-Khanskaya"
78
+ },
79
+ {
80
+ "lon": 39.924231880466095,
81
+ "lat": 43.43937843405085,
82
+ "alt": 30.010034561157227,
83
+ "name": "Sochi-Adler"
84
+ },
85
+ {
86
+ "lon": 41.142447588488196,
87
+ "lat": 42.852741071634995,
88
+ "alt": 13.339526176452637,
89
+ "name": "Sukhumi-Babushara"
90
+ },
91
+ {
92
+ "lon": 42.061021312855914,
93
+ "lat": 42.23872808157328,
94
+ "alt": 13.23994255065918,
95
+ "name": "Senaki-Kolkhi"
96
+ },
97
+ {
98
+ "lon": 40.56417576840064,
99
+ "lat": 43.124233340197144,
100
+ "alt": 21.01003074645996,
101
+ "name": "Gudauta"
102
+ },
103
+ {
104
+ "lon": 37.985886938697085,
105
+ "lat": 44.961383022734175,
106
+ "alt": 20.010303497314453,
107
+ "name": "Krymsk"
108
+ },
109
+ {
110
+ "lon": 38.0041463505281,
111
+ "lat": 44.56767458600406,
112
+ "alt": 22.00992202758789,
113
+ "name": "Gelendzhik"
114
+ },
115
+ {
116
+ "lon": 39.20306690632454,
117
+ "lat": 45.0460996415433,
118
+ "alt": 34.01003646850586,
119
+ "name": "Krasnodar-Pashkovsky"
120
+ }
121
+ ]
data/exe/start_scribe CHANGED
@@ -14,7 +14,8 @@ options = {
14
14
  db_port: 5432,
15
15
  db_name: 'tac_scribe',
16
16
  verbose_logging: false,
17
- threads: 1
17
+ threads: 1,
18
+ populate_airfields: false
18
19
  }
19
20
 
20
21
  OptionParser.new do |opts|
@@ -63,6 +64,10 @@ OptionParser.new do |opts|
63
64
  options[:db_name] = v
64
65
  end
65
66
  opts.separator "\nMisc options"
67
+ opts.on('-f', '--populate-airfields',
68
+ 'Populate DCS airfield locations') do |_v|
69
+ options[:populate_airfields] = true
70
+ end
66
71
  opts.on('-t', '--threads=threads',
67
72
  'Thread Count (Default: 1)') do |v|
68
73
  options[:threads] = v
@@ -93,5 +98,6 @@ TacScribe::Daemon.new(
93
98
  db_user: options[:db_user],
94
99
  db_password: options[:db_password],
95
100
  verbose_logging: options[:verbose],
96
- thread_count: options[:threads].to_i
101
+ thread_count: options[:threads].to_i,
102
+ populate_airfields: options[:populate_airfields]
97
103
  ).start_processing
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'json'
3
4
  require 'tacview_client'
4
5
  require_relative 'datastore'
5
6
  require_relative 'event_queue'
@@ -11,7 +12,8 @@ module TacScribe
11
12
  class Daemon
12
13
  def initialize(db_host:, db_port:, db_name:, db_user:, db_password:,
13
14
  tacview_host:, tacview_port:, tacview_password:,
14
- tacview_client_name:, verbose_logging:, thread_count:)
15
+ tacview_client_name:, verbose_logging:, thread_count:,
16
+ populate_airfields:)
15
17
  Datastore.instance.configure do |config|
16
18
  config.host = db_host
17
19
  config.port = db_port
@@ -23,6 +25,7 @@ module TacScribe
23
25
 
24
26
  @event_queue = EventQueue.new verbose_logging: verbose_logging
25
27
 
28
+ @populate_airfields = populate_airfields
26
29
  @thread_count = thread_count
27
30
  @processing_threads = []
28
31
 
@@ -46,6 +49,7 @@ module TacScribe
46
49
  @event_queue.events.clear
47
50
  Datastore.instance.truncate_table
48
51
  start_processing_threads
52
+ populate_airfields if @populate_airfields
49
53
  @client.connect
50
54
  sleep 30
51
55
  # Rescuing reliably from Net::HTTP is a complete bear so rescue
@@ -74,5 +78,21 @@ module TacScribe
74
78
  end
75
79
  end
76
80
  end
81
+
82
+ def populate_airfields
83
+ json = File.read(File.join(File.dirname(__FILE__), '../../data/airfields.json'))
84
+ airfields = JSON.parse(json)
85
+ airfields.each_with_index do |airfield, i|
86
+ @event_queue.update_object({
87
+ object_id: (45_000_000 + i).to_s,
88
+ latitude: BigDecimal(airfield['lat'].to_s),
89
+ longitude: BigDecimal(airfield['lon'].to_s),
90
+ altitude: BigDecimal(airfield['alt'].to_s),
91
+ type: 'Ground+Static+Aerodrome',
92
+ name: airfield['name'],
93
+ coalition: 2
94
+ })
95
+ end
96
+ end
77
97
  end
78
98
  end
@@ -75,9 +75,15 @@ module TacScribe
75
75
  private
76
76
 
77
77
  def connection_string
78
- "postgres://#{@configuration.username}:#{@configuration.password}@" \
79
- "#{@configuration.host}:#{@configuration.port}" \
80
- "/#{@configuration.database}"
78
+ if RUBY_PLATFORM == 'java'
79
+ "jdbc:postgresql://#{@configuration.host}:#{@configuration.port}/" \
80
+ "#{@configuration.database}?user=#{@configuration.username}&" \
81
+ "password=#{configuration.password}"
82
+ else
83
+ "postgres://#{@configuration.username}:#{@configuration.password}@" \
84
+ "#{@configuration.host}:#{@configuration.port}" \
85
+ "/#{@configuration.database}"
86
+ end
81
87
  end
82
88
 
83
89
  def get_unit(id)
@@ -11,12 +11,14 @@ module TacScribe
11
11
  def initialize(verbose_logging:)
12
12
  @verbose_logging = verbose_logging
13
13
  @events = Queue.new
14
+ @event_count = 0
14
15
 
15
16
  return unless verbose_logging == true
16
17
 
17
18
  Thread.new do
18
19
  loop do
19
- puts "Queue Size: #{@events.size}"
20
+ puts "#{Time.now.strftime("%FT%T")} - Queue Size: #{@events.size} \t Events Processed: #{@event_count}"
21
+ @event_count = 0
20
22
  sleep 1
21
23
  end
22
24
  end
@@ -40,6 +42,7 @@ module TacScribe
40
42
  # @option event [BigDecimal] :altitude The object altitude above sea level
41
43
  # in meters to 1 decimal place.
42
44
  def update_object(event)
45
+ @event_count += 1
43
46
  events << { type: :update_object, event: event, time: @time }
44
47
  end
45
48
 
@@ -48,6 +51,7 @@ module TacScribe
48
51
  # @param object_id [String] A hexadecimal number representing the object
49
52
  # ID
50
53
  def delete_object(object_id)
54
+ @event_count += 1
51
55
  events << { type: :delete_object, object_id: object_id }
52
56
  end
53
57
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TacScribe
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  end
data/tac_scribe.gemspec CHANGED
@@ -24,8 +24,14 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.metadata['yard.run'] = 'yri'
26
26
 
27
+ if RUBY_PLATFORM == 'java'
28
+ # TODO: Specifying a verison chokes bundler for some reason
29
+ spec.add_dependency 'activerecord-jdbcpostgresql-adapter'
30
+ else
31
+ spec.add_dependency 'pg', '~>1.1'
32
+ end
33
+
27
34
  spec.add_dependency 'georuby', '~>2.5'
28
- spec.add_dependency 'pg', '~>1.1'
29
35
  spec.add_dependency 'sequel', '~>5.22'
30
36
  # The following gem is newish and not heavily updated so the chances
31
37
  # of an API breaking change are higher then normal. Therefore lock the
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tac_scribe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeffrey Jones
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-05 00:00:00.000000000 Z
11
+ date: 2019-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: georuby
14
+ name: pg
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.5'
19
+ version: '1.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.5'
26
+ version: '1.1'
27
27
  - !ruby/object:Gem::Dependency
28
- name: pg
28
+ name: georuby
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.1'
33
+ version: '2.5'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.1'
40
+ version: '2.5'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sequel
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -179,12 +179,14 @@ files:
179
179
  - ".ruby-gemset"
180
180
  - ".ruby-version"
181
181
  - ".travis.yml"
182
+ - CHANGELOG.md
182
183
  - Gemfile
183
184
  - LICENSE.txt
184
185
  - README.md
185
186
  - Rakefile
186
187
  - bin/console
187
188
  - bin/setup
189
+ - data/airfields.json
188
190
  - db/001_create_unit_table.rb
189
191
  - db/README.md
190
192
  - exe/start_scribe