tcp-client 0.1.0 → 0.1.1
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 +4 -4
- data/lib/tcp-client/address.rb +1 -1
- data/lib/tcp-client/configuration.rb +9 -9
- data/lib/tcp-client/mixin/io_timeout.rb +2 -6
- data/lib/tcp-client/version.rb +1 -1
- data/rakefile.rb +1 -1
- data/tcp-client.gemspec +9 -15
- data/test/tcp_client_test.rb +3 -3
- data/test/test_helper.rb +2 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e45ec8c3b7922c52959609426b92075a00a183e109c0ebf81011faeb27d6fc1
|
4
|
+
data.tar.gz: 0ac11baf6e4056548f4d720e578448975e21fccc743248d81253b63f52b51117
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18bc160a8aaeda0656182c999d21d2fed955b24413a1293731cfc089e118f7489b5baaed71b66bf602f0cae6c0539cb894ad045f5552f2743c2ac6b883492824
|
7
|
+
data.tar.gz: 2972220034105e5f35e066e81214f6a44324636ec2383861be62da63686b9c16a138e691f86760a8eaabf34e1826b3d59381f8dbdc468b1a92facd0d21028578
|
data/lib/tcp-client/address.rb
CHANGED
@@ -44,7 +44,7 @@ class TCPClient
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def from_string(str)
|
47
|
-
|
47
|
+
idx = str.rindex(':') or return nil, str.to_i
|
48
48
|
name = str[0, idx]
|
49
49
|
name = name[1, name.size - 2] if name[0] == '[' && name[-1] == ']'
|
50
50
|
[name, str[idx + 1, str.size - idx].to_i]
|
@@ -19,22 +19,22 @@ class TCPClient
|
|
19
19
|
@ssl_params ? true : false
|
20
20
|
end
|
21
21
|
|
22
|
-
def ssl=(
|
23
|
-
return @ssl_params = nil unless
|
24
|
-
return @ssl_params =
|
22
|
+
def ssl=(value)
|
23
|
+
return @ssl_params = nil unless value
|
24
|
+
return @ssl_params = value.dup if Hash === value
|
25
25
|
@ssl_params ||= {}
|
26
26
|
end
|
27
27
|
|
28
|
-
def buffered=(
|
29
|
-
@buffered =
|
28
|
+
def buffered=(value)
|
29
|
+
@buffered = value ? true : false
|
30
30
|
end
|
31
31
|
|
32
|
-
def keep_alive=(
|
33
|
-
@keep_alive =
|
32
|
+
def keep_alive=(value)
|
33
|
+
@keep_alive = value ? true : false
|
34
34
|
end
|
35
35
|
|
36
|
-
def reverse_lookup=(
|
37
|
-
@reverse_lookup =
|
36
|
+
def reverse_lookup=(value)
|
37
|
+
@reverse_lookup = value ? true : false
|
38
38
|
end
|
39
39
|
|
40
40
|
def timeout=(seconds)
|
@@ -59,9 +59,7 @@ module IOTimeoutMixin
|
|
59
59
|
end
|
60
60
|
|
61
61
|
module DeadlineMethods
|
62
|
-
private
|
63
|
-
|
64
|
-
def with_deadline(deadline, exclass)
|
62
|
+
private def with_deadline(deadline, exclass)
|
65
63
|
loop do
|
66
64
|
case ret = yield
|
67
65
|
when :wait_writable
|
@@ -78,9 +76,7 @@ module IOTimeoutMixin
|
|
78
76
|
end
|
79
77
|
|
80
78
|
module DeadlineIO
|
81
|
-
private
|
82
|
-
|
83
|
-
def with_deadline(deadline, exclass)
|
79
|
+
private def with_deadline(deadline, exclass)
|
84
80
|
loop do
|
85
81
|
case ret = yield
|
86
82
|
when :wait_writable
|
data/lib/tcp-client/version.rb
CHANGED
data/rakefile.rb
CHANGED
data/tcp-client.gemspec
CHANGED
@@ -5,6 +5,10 @@ require_relative './lib/tcp-client/version'
|
|
5
5
|
GemSpec = Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'tcp-client'
|
7
7
|
spec.version = TCPClient::VERSION
|
8
|
+
spec.author = 'Mike Blumtritt'
|
9
|
+
|
10
|
+
spec.required_ruby_version = '>= 2.7.0'
|
11
|
+
|
8
12
|
spec.summary = 'A TCP client implementation with working timeout support.'
|
9
13
|
spec.description = <<~DESCRIPTION
|
10
14
|
This gem implements a TCP client with (optional) SSL support. The
|
@@ -13,27 +17,17 @@ GemSpec = Gem::Specification.new do |spec|
|
|
13
17
|
other implementations this client respects given/configurable time
|
14
18
|
limits for each method (`connect`, `read`, `write`).
|
15
19
|
DESCRIPTION
|
16
|
-
spec.author = 'Mike Blumtritt'
|
17
|
-
spec.email = 'mike.blumtritt@pm.me'
|
18
20
|
spec.homepage = 'https://github.com/mblumtritt/tcp-client'
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
}
|
23
|
-
spec.rubyforge_project = spec.name
|
21
|
+
|
22
|
+
spec.metadata['source_code_uri'] = 'https://github.com/mblumtritt/tcp-client'
|
23
|
+
spec.metadata['bug_tracker_uri'] = 'https://github.com/mblumtritt/tcp-client/issues'
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler'
|
26
26
|
spec.add_development_dependency 'minitest'
|
27
27
|
spec.add_development_dependency 'rake'
|
28
28
|
|
29
|
-
|
30
|
-
spec.
|
31
|
-
spec.required_rubygems_version = Gem::Requirement.new('>= 1.3.6')
|
32
|
-
|
33
|
-
spec.require_paths = %w[lib]
|
34
|
-
|
35
|
-
all_files = %x(git ls-files -z).split(0.chr)
|
36
|
-
spec.test_files = all_files.grep(%r{^(spec|test)/})
|
29
|
+
all_files = Dir.chdir(__dir__) { `git ls-files -z`.split(0.chr) }
|
30
|
+
spec.test_files = all_files.grep(%r{^test/})
|
37
31
|
spec.files = all_files - spec.test_files
|
38
32
|
|
39
33
|
spec.extra_rdoc_files = %w[README.md]
|
data/test/tcp_client_test.rb
CHANGED
@@ -22,9 +22,9 @@ class TCPClientTest < MiniTest::Test
|
|
22
22
|
def create_nonconnected_client
|
23
23
|
client = TCPClient.new
|
24
24
|
client.connect('', config)
|
25
|
+
client
|
25
26
|
rescue Errno::EADDRNOTAVAIL
|
26
|
-
|
27
|
-
return client
|
27
|
+
client
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_failed_state
|
@@ -41,7 +41,7 @@ class TCPClientTest < MiniTest::Test
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_connected_state
|
44
|
-
TCPClient.open('localhost:1234') do |subject|
|
44
|
+
TCPClient.open('localhost:1234', config) do |subject|
|
45
45
|
refute(subject.closed?)
|
46
46
|
assert_equal('localhost:1234', subject.to_s)
|
47
47
|
refute_nil(subject.address)
|
data/test/test_helper.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Blumtritt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-12 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:
|
61
|
+
email:
|
62
62
|
executables: []
|
63
63
|
extensions: []
|
64
64
|
extra_rdoc_files:
|
@@ -99,12 +99,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
99
|
requirements:
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 2.
|
102
|
+
version: 2.7.0
|
103
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
104
|
requirements:
|
105
105
|
- - ">="
|
106
106
|
- !ruby/object:Gem::Version
|
107
|
-
version:
|
107
|
+
version: '0'
|
108
108
|
requirements: []
|
109
109
|
rubygems_version: 3.2.9
|
110
110
|
signing_key:
|