digital-transport 0.6.0 → 0.7.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
  SHA1:
3
- metadata.gz: ebc66bca4fa184489e9e3150ffe00fcc1cc14d26
4
- data.tar.gz: 43e9b5b2de33c6fc647a300e1a6228386b824684
3
+ metadata.gz: 7bef42589885904d645a4292752810953782d877
4
+ data.tar.gz: 7e305bfc77044fae5f8d66e9ab9887482f0fb4cd
5
5
  SHA512:
6
- metadata.gz: 395e76d6e3d347c611c798b4078481b18e52f4971ef3cb582a237933f970a0c7b6330e7e05abea3ca234511f1ae490bfeab7577232ad08d2a86f2d0853cd2459
7
- data.tar.gz: fb9c67b12c6cb9a2a5ee19a9c586a7bb30e01d50c0b1d35938fda3b71f8787b21c1503cdcb09a7898038b897fb0b58605dbcea2e9ba5dd13ca8cca34be291785
6
+ metadata.gz: 864d29f9043ce4032dcbda34aac41f473b8377723ddad72ac74d504e2a0942b8be5793db7cffd40cb0b6bb05b0d68abbae4f83c90bbebd599f3383804f2fc64f
7
+ data.tar.gz: 4e38dd77510f9e3e0f236638727913fad7f2e7de361e103af7265768fb5713b333897aeae8fdd3dcc9daae88da12031f8bb6de4c26cbc5f22c730c0ad2ba43bd
@@ -1,4 +1,5 @@
1
1
  require 'socket'
2
+ require 'timeout'
2
3
  require 'functional'
3
4
 
4
5
  module Digital
@@ -30,9 +31,9 @@ module Digital
30
31
  Socket.new(AF_INET, SOCK_STREAM, 0).tap do |socket|
31
32
  socket.setsockopt(IPPROTO_TCP, TCP_NODELAY, (@opts[:tcp_nodelay] || DEFAULTS[:tcp_no_delay]).to_i)
32
33
  return connect_nonblock(
33
- socket,
34
- Socket.pack_sockaddr_in(@port, @ip),
35
- @opts[:timeout].to_i.nonzero? || DEFAULTS[:timeout]
34
+ socket,
35
+ Socket.pack_sockaddr_in(@port, @ip),
36
+ @opts[:timeout].to_i.nonzero? || DEFAULTS[:timeout]
36
37
  )
37
38
  end
38
39
  end
@@ -95,21 +96,26 @@ module Digital
95
96
 
96
97
  # @api private
97
98
  def connect_nonblock(io_like, endpoint, timeout)
98
- # IO.connect_nonblock retrun value is different across multiple platform.
99
- io_like.connect_nonblock(endpoint)
99
+ io_like.connect_nonblock(endpoint)
100
100
  raise Errno::EISCONN
101
- rescue Errno::EINPROGRESS # connection in progress, wait a bit.
102
- IO.select(nil, [io_like], nil, timeout) ? retry : nil
103
- rescue Errno::EISCONN # The socket is already connected.
101
+ rescue Errno::EINPROGRESS
102
+ if IO.select(nil, [io_like], nil, timeout)
103
+ retry
104
+ else
105
+ io_like.close
106
+ Either.left(Timeout::Error.new('Connection timeout'))
107
+ end
108
+ rescue Errno::EISCONN
104
109
  init_io io_like
105
110
  Either.right(self)
106
111
  rescue => ex
112
+ io_like.close
107
113
  Either.left(ex)
108
114
  end
109
115
 
110
116
  def init_io(io)
111
117
  @io = io
112
- end
118
+ end
113
119
  end
114
120
  end
115
121
  end
@@ -1,5 +1,5 @@
1
1
  module Digital
2
2
  module Transport
3
- VERSION = '0.6.0'.freeze
3
+ VERSION = '0.7.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: digital-transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Lishtaba
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-20 00:00:00.000000000 Z
11
+ date: 2016-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.11'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.11'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
@@ -56,14 +56,14 @@ dependencies:
56
56
  name: rspec_junit_formatter
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
@@ -84,62 +84,62 @@ dependencies:
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ~>
102
102
  - !ruby/object:Gem::Version
103
103
  version: '3.4'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ~>
109
109
  - !ruby/object:Gem::Version
110
110
  version: '3.4'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: functional-ruby
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rs_232
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - ~>
130
130
  - !ruby/object:Gem::Version
131
131
  version: '2.0'
132
- - - ">="
132
+ - - '>='
133
133
  - !ruby/object:Gem::Version
134
134
  version: 2.0.5
135
135
  type: :runtime
136
136
  prerelease: false
137
137
  version_requirements: !ruby/object:Gem::Requirement
138
138
  requirements:
139
- - - "~>"
139
+ - - ~>
140
140
  - !ruby/object:Gem::Version
141
141
  version: '2.0'
142
- - - ">="
142
+ - - '>='
143
143
  - !ruby/object:Gem::Version
144
144
  version: 2.0.5
145
145
  description: Library intended to unify interface between multiple transport adapters
@@ -149,10 +149,10 @@ executables: []
149
149
  extensions: []
150
150
  extra_rdoc_files: []
151
151
  files:
152
- - ".gitignore"
153
- - ".rubocop.yml"
154
- - ".travis.yml"
155
- - ".yardopts"
152
+ - .gitignore
153
+ - .rubocop.yml
154
+ - .travis.yml
155
+ - .yardopts
156
156
  - CODE_OF_CONDUCT.md
157
157
  - Gemfile
158
158
  - LICENSE.txt
@@ -178,18 +178,19 @@ require_paths:
178
178
  - lib
179
179
  required_ruby_version: !ruby/object:Gem::Requirement
180
180
  requirements:
181
- - - ">="
181
+ - - '>='
182
182
  - !ruby/object:Gem::Version
183
183
  version: '0'
184
184
  required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  requirements:
186
- - - ">="
186
+ - - '>='
187
187
  - !ruby/object:Gem::Version
188
188
  version: '0'
189
189
  requirements: []
190
190
  rubyforge_project:
191
- rubygems_version: 2.2.2
191
+ rubygems_version: 2.0.14.1
192
192
  signing_key:
193
193
  specification_version: 4
194
194
  summary: interface between multiple transport adapters
195
195
  test_files: []
196
+ has_rdoc: