cinc 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9c2928e6ef48aa239557a092667aedaccb2e87cad9f12bbbeb9a02e1f7c93ca5
4
+ data.tar.gz: 75a9d7c898051045a1ee483f80de46eb911d77fee01ee7ad155ba0c339cf59af
5
+ SHA512:
6
+ metadata.gz: a7e9d1dc0306e6394066500c0302e8763a815591124893453e770da86c3675ab4eeeb073876766c9a82dc0c014f526e7707dd981413d7d0c29fc396cb10c2efd
7
+ data.tar.gz: 7a4101f7fc9ce8731c62226e41e474719a7bf9b69dea6838c3ae40ed58cf16e99e29e300babb4bab23a8b9b92fd074f7b5602f7e3722ab8bfd5c0d05d71ad0b4
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
@@ -0,0 +1 @@
1
+ cinc
@@ -0,0 +1 @@
1
+ ruby-2.7
@@ -0,0 +1,10 @@
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
+ ### Added
10
+ - Basic client with `get_airbases` method that returns details of all airbases on map
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in cinc.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "minitest", "~> 5.0"
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Jeffrey Jones
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,54 @@
1
+ # Cinc
2
+
3
+ A ruby client for the "Commander In Chief" (Cinc) 3rd party RCP server that
4
+ runs on an instance of the Digital Combat Simulator (DCS) game.
5
+
6
+ See https://gitlab.com/cinc/cinc-server/tree/master/src for more information on
7
+ the Cinc server.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'cinc'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle install
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install cinc
24
+
25
+ ## Usage
26
+
27
+ ```
28
+ require 'cinc'
29
+
30
+ client = Cinc::Client.new("hostname", 9001)
31
+
32
+ array_of_airbase_hashes = client.get_airbases
33
+
34
+ ```
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
39
+ `rake test` to run the tests. You can also run `bin/console` for an interactive
40
+ prompt that will allow you to experiment.
41
+
42
+ To install this gem onto your local machine, run `bundle exec rake install`. To
43
+ release a new version, update the version number in `version.rb`, and then run
44
+ `bundle exec rake release`, which will create a git tag for the version, push
45
+ git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
46
+
47
+ ## Contributing
48
+
49
+ Bug reports and pull requests are welcome on Gitlab at https://gitlab.com/cinc/cinc-ruby-client
50
+
51
+
52
+ ## License
53
+
54
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cinc"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,27 @@
1
+ require_relative 'lib/cinc/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "cinc"
5
+ spec.version = Cinc::VERSION
6
+ spec.authors = ["Jeffrey Jones"]
7
+ spec.email = ["jeff@jones.be"]
8
+
9
+ spec.summary = %q{CinC (Commander-In-Chief) is an 3rd RPC system for Eagle Dynamics's DigitalCombatSimulator}
10
+ spec.homepage = "https://gitlab.com/cinc/cinc-ruby-client"
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata["source_code_uri"] = "https://gitlab.com/cinc/cinc-ruby-client"
16
+ spec.metadata["changelog_uri"] = "https://gitlab.com/cinc/cinc-ruby-client/-/blob/master/CHANGELOG.md"
17
+ spec.metadata["bug_tracker_uri"] = "https://gitlab.com/cinc/cinc-ruby-client/-/issues"
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+ end
@@ -0,0 +1,6 @@
1
+ require "cinc/version"
2
+ require "cinc/client"
3
+
4
+ module Cinc
5
+ class ConnectionError < StandardError; end
6
+ end
@@ -0,0 +1,46 @@
1
+ require 'socket'
2
+ require 'json'
3
+
4
+ module Cinc
5
+ class Client
6
+
7
+ def initialize(server = 'localhost', port = 9001)
8
+ @socket = TCPSocket.new(server, port)
9
+ rescue StandardError => e
10
+ raise ConnectionError.new(e.message)
11
+ end
12
+
13
+ def get_airbases
14
+ command = Command.new('get_airbases', {})
15
+
16
+ return process_command(command)
17
+ end
18
+
19
+ private
20
+
21
+ def process_command(command)
22
+ @socket.puts command.to_json
23
+ return JSON.parse @socket.gets
24
+ rescue StandardError => e
25
+ raise ConnectionError.new(e.message)
26
+ end
27
+
28
+ class Command
29
+
30
+ attr_accessor :name, :arguments
31
+
32
+ def initialize(name, arguments)
33
+ @name = name
34
+ @arguments = arguments
35
+ end
36
+
37
+ def to_json
38
+ {
39
+ name: name,
40
+ arguments: arguments
41
+ }.to_json
42
+ end
43
+
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,3 @@
1
+ module Cinc
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cinc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jeffrey Jones
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-08-08 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - jeff@jones.be
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".ruby-gemset"
22
+ - ".ruby-version"
23
+ - CHANGELOG.md
24
+ - Gemfile
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - bin/console
29
+ - bin/setup
30
+ - cinc.gemspec
31
+ - lib/cinc.rb
32
+ - lib/cinc/client.rb
33
+ - lib/cinc/version.rb
34
+ homepage: https://gitlab.com/cinc/cinc-ruby-client
35
+ licenses:
36
+ - MIT
37
+ metadata:
38
+ homepage_uri: https://gitlab.com/cinc/cinc-ruby-client
39
+ source_code_uri: https://gitlab.com/cinc/cinc-ruby-client
40
+ changelog_uri: https://gitlab.com/cinc/cinc-ruby-client/-/blob/master/CHANGELOG.md
41
+ bug_tracker_uri: https://gitlab.com/cinc/cinc-ruby-client/-/issues
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 2.3.0
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubygems_version: 3.1.2
58
+ signing_key:
59
+ specification_version: 4
60
+ summary: CinC (Commander-In-Chief) is an 3rd RPC system for Eagle Dynamics's DigitalCombatSimulator
61
+ test_files: []