tcp-client 0.0.9 → 0.0.10

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: 5bfc192ce3217cf36198c5b1455a16e4be9cca061f984f62d8803b88b6aca24c
4
- data.tar.gz: 427adb5f70cf966da45adaf84a9aec99d88f1091dc1fd7ae398ea58f43f736f9
3
+ metadata.gz: b04df2a87aaa1d7eea3322907e4f37c8ae228507474b6b59927617e12eb73d49
4
+ data.tar.gz: 4454f0e6a53984627ffc3cb681a6b496f49306040d3a2bc0bfdabdf2405595a8
5
5
  SHA512:
6
- metadata.gz: f57ba3c454f390504717a88c2d42d409ed82e3967f730a10d414c9781c2a5a38ffd4518b421fe2dec5b00f95a89f587c00aa980507cf3d75db6feaf536010b04
7
- data.tar.gz: 6bb29528b348b60de418de060067e9f55937107290901fb53cd6cdffbad42fe35050c12d2257c2410144ea936b35b511338697fecf444523ca5546d6a2aab47e
6
+ metadata.gz: 48e6bae6c20b9335593ca20d45f03884fd11db4fe2ff97b35766f17444f414f4cf15d5e187b02f059001e1bc819ed442cb4abd715de44bffbcac53f01dcacba5
7
+ data.tar.gz: 912f1716f2bdeeb3e9bbdff18a5232c015d15c461f4aa4ba1919af2d7836f8f56e7916ee3800e7a26633dfee3c05257849a255669f9cb6eaf1a87c475f12a459
@@ -22,13 +22,6 @@ class TCPClient
22
22
 
23
23
  private
24
24
 
25
- def init_from_string(str)
26
- @hostname, port = from_string(str.to_s)
27
- return init_from_addrinfo(Addrinfo.tcp(nil, port)) unless @hostname
28
- @addrinfo = Addrinfo.tcp(@hostname, port)
29
- @to_s = @hostname.index(':') ? "[#{@hostname}]:#{port}" : "#{@hostname}:#{port}"
30
- end
31
-
32
25
  def init_from_selfclass(address)
33
26
  @to_s = address.to_s
34
27
  @hostname = address.hostname
@@ -41,11 +34,23 @@ class TCPClient
41
34
  @addrinfo = addrinfo
42
35
  end
43
36
 
37
+ def init_from_string(str)
38
+ @hostname, port = from_string(str.to_s)
39
+ return init_from_addrinfo(Addrinfo.tcp(nil, port)) unless @hostname
40
+ @addrinfo = Addrinfo.tcp(@hostname, port)
41
+ @to_s = as_str(@hostname, port)
42
+ end
43
+
44
44
  def from_string(str)
45
45
  return [nil, str.to_i] unless idx = str.rindex(':')
46
46
  name = str[0, idx]
47
47
  name = name[1, name.size - 2] if name[0] == '[' && name[-1] == ']'
48
48
  [name, str[idx + 1, str.size - idx].to_i]
49
49
  end
50
+
51
+ def as_str(hostname, port)
52
+ return "[#{hostname}]:#{port}" if hostname.index(':') # IP6
53
+ "#{hostname}:#{port}"
54
+ end
50
55
  end
51
56
  end
@@ -96,5 +96,5 @@ module IOTimeoutMixin
96
96
  end
97
97
  end
98
98
 
99
- private_constant :DeadlineMethods, :DeadlineIO
99
+ private_constant(:DeadlineMethods, :DeadlineIO)
100
100
  end
@@ -42,5 +42,5 @@ class TCPClient
42
42
  end
43
43
  end
44
44
 
45
- private_constant :SSLSocket
45
+ private_constant(:SSLSocket)
46
46
  end
@@ -33,5 +33,5 @@ class TCPClient
33
33
  end
34
34
  end
35
35
 
36
- private_constant :TCPSocket
36
+ private_constant(:TCPSocket)
37
37
  end
@@ -1,3 +1,3 @@
1
1
  class TCPClient
2
- VERSION = '0.0.9'.freeze
2
+ VERSION = '0.0.10'.freeze
3
3
  end
@@ -1,7 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
3
+ require 'rake/clean'
4
4
  require 'rake/testtask'
5
+ require 'bundler/gem_tasks'
6
+
7
+ STDOUT.sync = STDERR.sync = true
8
+
9
+ CLOBBER << 'prj'
5
10
 
6
11
  Rake::TestTask.new(:test) do |t|
7
12
  t.ruby_opts = %w[-w]
@@ -14,9 +14,12 @@ GemSpec = Gem::Specification.new do |spec|
14
14
  limits for each method (`connect`, `read`, `write`).
15
15
  DESCRIPTION
16
16
  spec.author = 'Mike Blumtritt'
17
- spec.email = 'mike.blumtritt@invision.de'
17
+ spec.email = 'mike.blumtritt@pm.me'
18
18
  spec.homepage = 'https://github.com/mblumtritt/tcp-client'
19
- spec.metadata = {'issue_tracker' => 'https://github.com/mblumtritt/tcp-client/issues'}
19
+ spec.metadata = {
20
+ 'source_code_uri' => 'https://github.com/mblumtritt/tcp-client',
21
+ 'bug_tracker_uri' => 'https://github.com/mblumtritt/tcp-client/issues'
22
+ }
20
23
  spec.rubyforge_project = spec.name
21
24
 
22
25
  spec.add_development_dependency 'bundler'
@@ -43,6 +43,7 @@ class TCPClientTest < Test
43
43
  def with_dummy_server(port)
44
44
  # this server will never receive or send any data
45
45
  server = TCPServer.new('localhost', port)
46
+ yield
46
47
  ensure
47
48
  server&.close
48
49
  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.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Blumtritt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-26 00:00:00.000000000 Z
11
+ date: 2019-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,7 +58,7 @@ description: |
58
58
  easy to use client which can handle time limits correctly. Unlike
59
59
  other implementations this client respects given/configurable time
60
60
  limits for each method (`connect`, `read`, `write`).
61
- email: mike.blumtritt@invision.de
61
+ email: mike.blumtritt@pm.me
62
62
  executables: []
63
63
  extensions: []
64
64
  extra_rdoc_files:
@@ -87,7 +87,8 @@ files:
87
87
  homepage: https://github.com/mblumtritt/tcp-client
88
88
  licenses: []
89
89
  metadata:
90
- issue_tracker: https://github.com/mblumtritt/tcp-client/issues
90
+ source_code_uri: https://github.com/mblumtritt/tcp-client
91
+ bug_tracker_uri: https://github.com/mblumtritt/tcp-client/issues
91
92
  post_install_message:
92
93
  rdoc_options: []
93
94
  require_paths:
@@ -103,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
104
  - !ruby/object:Gem::Version
104
105
  version: 1.3.6
105
106
  requirements: []
106
- rubygems_version: 3.0.1
107
+ rubygems_version: 3.0.3
107
108
  signing_key:
108
109
  specification_version: 4
109
110
  summary: A TCP client implementation with working timeout support.