tcp-client 0.0.10 → 0.0.11

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: b04df2a87aaa1d7eea3322907e4f37c8ae228507474b6b59927617e12eb73d49
4
- data.tar.gz: 4454f0e6a53984627ffc3cb681a6b496f49306040d3a2bc0bfdabdf2405595a8
3
+ metadata.gz: afd4d9a8cc41724a9d20fbdf0794dd8d7d4ed7103728d749ee6d823a49e03866
4
+ data.tar.gz: f63e5da4f6cdcfb449d918bddc79a0826fc6cf9c35017a6f1762dcc881f37c79
5
5
  SHA512:
6
- metadata.gz: 48e6bae6c20b9335593ca20d45f03884fd11db4fe2ff97b35766f17444f414f4cf15d5e187b02f059001e1bc819ed442cb4abd715de44bffbcac53f01dcacba5
7
- data.tar.gz: 912f1716f2bdeeb3e9bbdff18a5232c015d15c461f4aa4ba1919af2d7836f8f56e7916ee3800e7a26633dfee3c05257849a255669f9cb6eaf1a87c475f12a459
6
+ metadata.gz: 8da7b4a3a87585b206341d1aa770ecf08ebc937fcd5117a594804d6bb8d0fd1a8f12cf3e29e2fa2d8841e78496fa7b48ee4041edd4bff15b12cd1ecd43399106
7
+ data.tar.gz: 7b61d7ad8d26120a5a39414a93c51bd8fb0dc11eeb7008ea647b5bb8b2ac51af855539f41929f92c3374766765c3588f02009348c216d24dea2d88c4beab5a3c
@@ -14,8 +14,8 @@ class TCPClient
14
14
  end
15
15
 
16
16
  class NotConnected < SocketError
17
- def self.raise!(which)
18
- raise(self, "client not connected - #{which}", caller(1))
17
+ def self.raise!(reason)
18
+ raise(self, "client not connected - #{reason}", caller(1))
19
19
  end
20
20
  end
21
21
 
@@ -4,7 +4,7 @@ require 'socket'
4
4
 
5
5
  class TCPClient
6
6
  class Address
7
- attr_reader :to_s, :hostname, :addrinfo
7
+ attr_reader :hostname, :addrinfo
8
8
 
9
9
  def initialize(addr)
10
10
  case addr
@@ -20,17 +20,20 @@ class TCPClient
20
20
  @addrinfo.freeze
21
21
  end
22
22
 
23
+ def to_s
24
+ return "[#{@hostname}]:#{@addrinfo.ip_port}" if @hostname.index(':') # IP6
25
+ "#{@hostname}:#{@addrinfo.ip_port}"
26
+ end
27
+
23
28
  private
24
29
 
25
30
  def init_from_selfclass(address)
26
- @to_s = address.to_s
27
31
  @hostname = address.hostname
28
32
  @addrinfo = address.addrinfo
29
33
  end
30
34
 
31
35
  def init_from_addrinfo(addrinfo)
32
- @hostname, port = addrinfo.getnameinfo(Socket::NI_NUMERICSERV)
33
- @to_s = "#{@hostname}:#{port}"
36
+ @hostname, _port = addrinfo.getnameinfo(Socket::NI_NUMERICSERV)
34
37
  @addrinfo = addrinfo
35
38
  end
36
39
 
@@ -38,7 +41,6 @@ class TCPClient
38
41
  @hostname, port = from_string(str.to_s)
39
42
  return init_from_addrinfo(Addrinfo.tcp(nil, port)) unless @hostname
40
43
  @addrinfo = Addrinfo.tcp(@hostname, port)
41
- @to_s = as_str(@hostname, port)
42
44
  end
43
45
 
44
46
  def from_string(str)
@@ -47,10 +49,5 @@ class TCPClient
47
49
  name = name[1, name.size - 2] if name[0] == '[' && name[-1] == ']'
48
50
  [name, str[idx + 1, str.size - idx].to_i]
49
51
  end
50
-
51
- def as_str(hostname, port)
52
- return "[#{hostname}]:#{port}" if hostname.index(':') # IP6
53
- "#{hostname}:#{port}"
54
- end
55
52
  end
56
53
  end
@@ -1,3 +1,3 @@
1
1
  class TCPClient
2
- VERSION = '0.0.10'.freeze
2
+ VERSION = '0.0.11'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tcp-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Blumtritt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-01 00:00:00.000000000 Z
11
+ date: 2019-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler