cinc 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c2928e6ef48aa239557a092667aedaccb2e87cad9f12bbbeb9a02e1f7c93ca5
4
- data.tar.gz: 75a9d7c898051045a1ee483f80de46eb911d77fee01ee7ad155ba0c339cf59af
3
+ metadata.gz: 4b8c996c55f9c96abd24c931e2707a2e7786e1e89460f29fe58eeac98baeac6d
4
+ data.tar.gz: f71bb233a5460c452a344482071e4475c9a55d24314618221b9332c8d6ddbdf1
5
5
  SHA512:
6
- metadata.gz: a7e9d1dc0306e6394066500c0302e8763a815591124893453e770da86c3675ab4eeeb073876766c9a82dc0c014f526e7707dd981413d7d0c29fc396cb10c2efd
7
- data.tar.gz: 7a4101f7fc9ce8731c62226e41e474719a7bf9b69dea6838c3ae40ed58cf16e99e29e300babb4bab23a8b9b92fd074f7b5602f7e3722ab8bfd5c0d05d71ad0b4
6
+ metadata.gz: 1118262aac872fd4a6723d541373ad546d714a25c7268101794185dfd1b803d65f5cac87aa8e993b609e1a59d5e1b2b2b7bdfcc9ac5644488716e7a45b2a663d
7
+ data.tar.gz: b2bb73467a5fafbedbd1e3c15cd5b4d9aa8919e72d7d6fdc25afec89e7a28a46f1d2172d067addc722fa6650eec460d3e23c93c420398bd24e2cbd4d956202b6
@@ -6,5 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.2.0] - 2020-08-10
10
+ ### Changed
11
+ - Separate client initialization and connection
12
+
13
+ ## [0.1.0] - 2020-08-08
9
14
  ### Added
10
15
  - Basic client with `get_airbases` method that returns details of all airbases on map
data/README.md CHANGED
@@ -28,7 +28,7 @@ Or install it yourself as:
28
28
  require 'cinc'
29
29
 
30
30
  client = Cinc::Client.new("hostname", 9001)
31
-
31
+ client.connect
32
32
  array_of_airbase_hashes = client.get_airbases
33
33
 
34
34
  ```
@@ -4,8 +4,13 @@ require 'json'
4
4
  module Cinc
5
5
  class Client
6
6
 
7
- def initialize(server = 'localhost', port = 9001)
8
- @socket = TCPSocket.new(server, port)
7
+ def initialize(host: 'localhost', port: 9001)
8
+ @host = host
9
+ @port = port
10
+ end
11
+
12
+ def connect
13
+ @socket = Socket.tcp(@host, @port, connect_timeout: 10)
9
14
  rescue StandardError => e
10
15
  raise ConnectionError.new(e.message)
11
16
  end
@@ -20,7 +25,9 @@ module Cinc
20
25
 
21
26
  def process_command(command)
22
27
  @socket.puts command.to_json
23
- return JSON.parse @socket.gets
28
+ response = @socket.gets
29
+ raise ConnectionError.new("Connection terminated by server") unless response
30
+ JSON.parse(response)
24
31
  rescue StandardError => e
25
32
  raise ConnectionError.new(e.message)
26
33
  end
@@ -1,3 +1,3 @@
1
1
  module Cinc
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
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: 2020-08-08 00:00:00.000000000 Z
11
+ date: 2020-08-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: