tcp-client 0.11.0 → 0.11.1

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: 91bdfe4046f3e4baeefe4a140d7a2bdb0cac02d3c069102e9c574fe02e5ca1c8
4
- data.tar.gz: e26cc5ce187d50aba43d06403730445f3605667a4cffc5d4c7105dd549ca4c9a
3
+ metadata.gz: 3c5d814647f45ebfc5a5d43b6b0ae208092c36493bdc839c7e4e722c3ff4b1f0
4
+ data.tar.gz: 6187b371bb275f0cc88c63091dce51e91f45b79c5257580f881616433c581345
5
5
  SHA512:
6
- metadata.gz: dfc647093949536fa3c040f9140ec5039a37934e1b77ccc3150f9c16a8de824123c7e8b374faa9479c5572a84f7cb9e08a051e356fe76e79d9245e10efd61bf4
7
- data.tar.gz: 6046435c921660e284838c0e33559540f81de5f8b4c150ab63bf37ee72fc7605bc128d5c2b79d8ac7cb6cf657267bc445a4bef36103508ffaed4d6b0961d023c
6
+ metadata.gz: c48c0b4b0b9f14545895ae489f27d2a75a2c400598a342b553f8e7bbace7f2b4d9d9874f70e85ff40fe3ff4c59e2ea1973e8f324aceacb2705c7982fb1ebb772
7
+ data.tar.gz: 9c8259dcb4b9b351224627f08a84041d2d8bdf543233d0cefc2b14ed265d67a4b7a2b128bfe75fa4fd8a6b44bab527bb81a815a1edeefafcd85a4733d0064087
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # TCPClient
2
2
 
3
- A TCP client implementation with working timeout support.
3
+ Use your TCP connections with working timeout.
4
4
 
5
5
  - Gem: [rubygems.org](https://rubygems.org/gems/tcp-client)
6
6
  - Source: [github.com](https://github.com/mblumtritt/tcp-client)
@@ -8,7 +8,8 @@ A TCP client implementation with working timeout support.
8
8
 
9
9
  ## Description
10
10
 
11
- This Gem implements a TCP client with (optional) SSL support. It is an easy to use, versatile configurable client that can correctly handle time limits. Unlike other implementations, this client respects predefined/configurable time limits for each method (`connect`, `read`, `write`). Deadlines for a sequence of read/write actions can also be monitored.
11
+ This gem implements a customizable TCP client class that gives you control over time limits. You can set time limits for individual read or write calls or set a deadline for entire call sequences.
12
+ It has a very small footprint, no dependencies and is easily useable.
12
13
 
13
14
  ## Sample
14
15
 
@@ -37,7 +38,7 @@ response =
37
38
  puts(response)
38
39
  ```
39
40
 
40
- For more samples see [the samples dir](https://github.com/mblumtritt/tcp-client/tree/main/sample)
41
+ For more samples see [the examples dir](https://github.com/mblumtritt/tcp-client/tree/main/examples)
41
42
 
42
43
  ## Installation
43
44
 
@@ -61,7 +62,7 @@ To install the gem globally use:
61
62
  gem install tcp-client
62
63
  ```
63
64
 
64
- After that you need only a single line of code in your project to have on board:
65
+ After that you need only a single line of code in your project to have it on board:
65
66
 
66
67
  ```ruby
67
68
  require 'tcp-client'
@@ -2,5 +2,5 @@
2
2
 
3
3
  class TCPClient
4
4
  # The current version number.
5
- VERSION = '0.11.0'
5
+ VERSION = '0.11.1'
6
6
  end
metadata CHANGED
@@ -1,79 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tcp-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.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: 2022-07-03 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: yard
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
11
+ date: 2022-07-30 00:00:00.000000000 Z
12
+ dependencies: []
69
13
  description: |
70
- This Gem implements a TCP client with (optional) SSL support.
71
- It is an easy to use, versatile configurable client that can correctly
72
- handle time limits.
73
- Unlike other implementations, this client respects
74
- predefined/configurable time limits for each method
75
- (`connect`, `read`, `write`). Deadlines for a sequence of read/write
76
- actions can also be monitored.
14
+ This gem implements a customizable TCP client class that gives you control
15
+ over time limits. You can set time limits for individual read or write calls
16
+ or set a deadline for entire call sequences.
17
+ It has a very small footprint, no dependencies and is easily useable.
77
18
  email:
78
19
  executables: []
79
20
  extensions: []
@@ -81,11 +22,8 @@ extra_rdoc_files:
81
22
  - README.md
82
23
  - LICENSE
83
24
  files:
84
- - ".gitignore"
85
- - ".yardopts"
86
25
  - LICENSE
87
26
  - README.md
88
- - gems.rb
89
27
  - lib/tcp-client.rb
90
28
  - lib/tcp-client/address.rb
91
29
  - lib/tcp-client/configuration.rb
@@ -97,23 +35,13 @@ files:
97
35
  - lib/tcp-client/tcp_socket.rb
98
36
  - lib/tcp-client/version.rb
99
37
  - lib/tcp_client.rb
100
- - rakefile.rb
101
- - sample/google.rb
102
- - sample/google_ssl.rb
103
- - spec/helper.rb
104
- - spec/tcp-client/address_spec.rb
105
- - spec/tcp-client/configuration_spec.rb
106
- - spec/tcp-client/default_configuration_spec.rb
107
- - spec/tcp-client/version_spec.rb
108
- - spec/tcp_client_spec.rb
109
- - tcp-client.gemspec
110
38
  homepage: https://github.com/mblumtritt/tcp-client
111
39
  licenses:
112
40
  - BSD-3-Clause
113
41
  metadata:
114
42
  source_code_uri: https://github.com/mblumtritt/tcp-client
115
43
  bug_tracker_uri: https://github.com/mblumtritt/tcp-client/issues
116
- documentation_uri: https://rubydoc.info/github/mblumtritt/tcp-client
44
+ documentation_uri: https://rubydoc.info/gems/tcp-client
117
45
  post_install_message:
118
46
  rdoc_options: []
119
47
  require_paths:
@@ -132,11 +60,5 @@ requirements: []
132
60
  rubygems_version: 3.3.7
133
61
  signing_key:
134
62
  specification_version: 4
135
- summary: A TCP client implementation with working timeout support.
136
- test_files:
137
- - spec/helper.rb
138
- - spec/tcp-client/address_spec.rb
139
- - spec/tcp-client/configuration_spec.rb
140
- - spec/tcp-client/default_configuration_spec.rb
141
- - spec/tcp-client/version_spec.rb
142
- - spec/tcp_client_spec.rb
63
+ summary: Use your TCP connections with working timeout.
64
+ test_files: []
data/.gitignore DELETED
@@ -1,6 +0,0 @@
1
- tmp/
2
- pkg/
3
- local/
4
- doc/
5
- .yardoc/
6
- gems.locked
data/.yardopts DELETED
@@ -1,5 +0,0 @@
1
- --readme README.md
2
- --title 'tcp-client Documentation'
3
- --charset utf-8
4
- --markup markdown
5
- 'lib/**/*.rb' - 'LICENSE'
data/gems.rb DELETED
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
- gemspec
data/rakefile.rb DELETED
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rake/clean'
4
- require 'bundler/gem_tasks'
5
- require 'rspec/core/rake_task'
6
- require 'yard'
7
-
8
- $stdout.sync = $stderr.sync = true
9
-
10
- CLEAN << '.yardoc'
11
- CLOBBER << 'prj' << 'doc'
12
-
13
- task(:default) { exec('rake --tasks') }
14
- task(test: :spec)
15
- RSpec::Core::RakeTask.new { |task| task.ruby_opts = %w[-w] }
16
- YARD::Rake::YardocTask.new { |task| task.stats_options = %w[--list-undoc] }
data/sample/google.rb DELETED
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../lib/tcp-client'
4
-
5
- # global configuration.
6
- # - 0.5 seconds to connect the server
7
- # - 0.25 seconds to write a single data junk
8
- # - 0.25 seconds to read some bytes
9
- TCPClient.configure do |cfg|
10
- cfg.connect_timeout = 0.5
11
- cfg.write_timeout = 0.25
12
- cfg.read_timeout = 0.25
13
- end
14
-
15
- # request to Google:
16
- # - send a simple HTTP get request
17
- # - read 12 byte: "HTTP/1.1 " + 3 byte HTTP status code
18
- TCPClient.open('www.google.com:80') do |client|
19
- p client.write("GET / HTTP/1.1\r\nHost: www.google.com\r\n\r\n")
20
- p client.read(12)
21
- end
data/sample/google_ssl.rb DELETED
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../lib/tcp-client'
4
-
5
- # create a configuration:
6
- # - don't use internal buffering
7
- # - use TLS 1.2 or TLS 1.3
8
- cfg =
9
- TCPClient::Configuration.create(
10
- buffered: false,
11
- ssl_params: {
12
- min_version: :TLS1_2,
13
- max_version: :TLS1_3
14
- }
15
- )
16
-
17
- # request to Google.com:
18
- # - limit all network interactions to 1.5 seconds
19
- # - use the Configuration cfg
20
- # - send a simple HTTP get request
21
- # - read the returned message and headers
22
- response =
23
- TCPClient.with_deadline(1.5, 'www.google.com:443', cfg) do |client|
24
- client.write("GET / HTTP/1.1\r\nHost: www.google.com\r\n\r\n") #=> 40
25
- client.readline("\r\n\r\n") #=> header, see response
26
- end
27
-
28
- puts(response)
data/spec/helper.rb DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rspec/core'
4
- require_relative '../lib/tcp-client'
5
-
6
- $stdout.sync = $stderr.sync = true
7
-
8
- RSpec.configure do |config|
9
- config.disable_monkey_patching!
10
- config.warnings = true
11
- config.order = :random
12
- end
@@ -1,132 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../helper'
4
-
5
- RSpec.describe TCPClient::Address do
6
- describe '.new' do
7
- context 'when called with an Integer parameter' do
8
- subject(:address) { TCPClient::Address.new(42) }
9
-
10
- it 'points to the given port on localhost' do
11
- expect(address.hostname).to eq 'localhost'
12
- expect(address.port).to be 42
13
- expect(address.to_s).to eq 'localhost:42'
14
- end
15
-
16
- it 'uses IPv6' do
17
- expect(address.addrinfo.ip?).to be true
18
- expect(address.addrinfo.ipv6?).to be true
19
- expect(address.addrinfo.ipv4?).to be false
20
- end
21
- end
22
-
23
- context 'when called with an Addrinfo' do
24
- subject(:address) { TCPClient::Address.new(addrinfo) }
25
- let(:addrinfo) { Addrinfo.tcp('::1', 42) }
26
-
27
- it 'uses the given Addrinfo' do
28
- expect(address.addrinfo).to eq addrinfo
29
- end
30
-
31
- it 'points to the given host and port' do
32
- expect(address.hostname).to eq 'localhost'
33
- expect(address.port).to be 42
34
- expect(address.to_s).to eq 'localhost:42'
35
- end
36
-
37
- it 'uses IPv6' do
38
- expect(address.addrinfo.ip?).to be true
39
- expect(address.addrinfo.ipv6?).to be true
40
- expect(address.addrinfo.ipv4?).to be false
41
- end
42
- end
43
-
44
- context 'when called with a String' do
45
- context 'when a host name and port is provided' do
46
- subject(:address) { TCPClient::Address.new('localhost:42') }
47
-
48
- it 'points to the given host and port' do
49
- expect(address.hostname).to eq 'localhost'
50
- expect(address.port).to be 42
51
- expect(address.to_s).to eq 'localhost:42'
52
- expect(address.addrinfo.ip?).to be true
53
- end
54
-
55
- end
56
-
57
- context 'when only a port is provided' do
58
- subject(:address) { TCPClient::Address.new(':42') }
59
-
60
- it 'points to the given port on localhost' do
61
- expect(address.hostname).to eq 'localhost'
62
- expect(address.port).to be 42
63
- expect(address.to_s).to eq 'localhost:42'
64
- expect(address.addrinfo.ip?).to be true
65
- end
66
- end
67
-
68
- context 'when an IPv6 address is provided' do
69
- subject(:address) { TCPClient::Address.new('[::1]:42') }
70
-
71
- it 'points to the given port on localhost' do
72
- expect(address.hostname).to eq '::1'
73
- expect(address.port).to be 42
74
- expect(address.to_s).to eq '[::1]:42'
75
- expect(address.addrinfo.ip?).to be true
76
- end
77
- end
78
- end
79
- end
80
-
81
- describe '#to_h' do
82
- subject(:address) { TCPClient::Address.new('localhost:42') }
83
-
84
- it 'returns itself as an Hash' do
85
- expect(address.to_h).to eq(host: 'localhost', port: 42)
86
- end
87
- end
88
-
89
- describe 'comparison' do
90
- context 'comparing two equal instances' do
91
- let(:address_a) { TCPClient::Address.new('localhost:42') }
92
- let(:address_b) { TCPClient::Address.new('localhost:42') }
93
-
94
- it 'compares to equal' do
95
- expect(address_a).to eq address_b
96
- end
97
-
98
- context 'using the == operator' do
99
- it 'compares to equal' do
100
- expect(address_a == address_b).to be true
101
- end
102
- end
103
-
104
- context 'using the === operator' do
105
- it 'compares to equal' do
106
- expect(address_a === address_b).to be true
107
- end
108
- end
109
- end
110
-
111
- context 'comparing two non-equal instances' do
112
- let(:address_a) { TCPClient::Address.new('localhost:42') }
113
- let(:address_b) { TCPClient::Address.new('localhost:21') }
114
-
115
- it 'compares not to equal' do
116
- expect(address_a).not_to eq address_b
117
- end
118
-
119
- context 'using the == operator' do
120
- it 'compares not to equal' do
121
- expect(address_a == address_b).to be false
122
- end
123
- end
124
-
125
- context 'using the === operator' do
126
- it 'compares not to equal' do
127
- expect(address_a === address_b).to be false
128
- end
129
- end
130
- end
131
- end
132
- end