rubysl-net-protocol 1.0.0 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a5f5190a2f8eea39f80416cc303533647f25b1c
4
- data.tar.gz: e7e39d163a97f4f42b9f1da93968fc84729d41a2
3
+ metadata.gz: 3f0dddf4e307731f0d4912dab2cb75188a77121a
4
+ data.tar.gz: 6e32a554d2c4e473a6de3a3458c081edb0247aec
5
5
  SHA512:
6
- metadata.gz: c451315d4c840b290f1adee071288a5eaf9b65638090c649ed7c87d8813ddc0ca4fd5f43251b0ffd122a2148ebb12442899ae26d73b93f8ee9a92ab2d7fc9d67
7
- data.tar.gz: 78b3ae013cadd203836a021c62f5f4c5410b143e6bfcfd4eb36fb0eeb679ea28ff159fa2eb9d1da3d23741830b254aeaa9a9ff28440678463318160c8e6a71dc
6
+ metadata.gz: 62b61fcc4432be376df0d401738fc201ec9e810c0ca60b08959c5a83dea326b46a47ea539daf1e328c1cf9113709041218ea2b073c3b77e8f69a7740a065b15a
7
+ data.tar.gz: ebb62c7ca6e2fa6a7d0bb5881701a8a5c42cf7c4e0d5ba4fb0712abc824f35d5b4be3f1c916ec8386e6a0fe2adb17a44e6c6d0c02a9e810c3c1bd093c7421789
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ env:
3
+ - RUBYLIB=lib
4
+ script: bundle exec mspec spec
5
+ rvm:
6
+ - rbx-nightly-19mode
@@ -2,8 +2,8 @@
2
2
  # = net/protocol.rb
3
3
  #
4
4
  #--
5
- # Copyright (c) 1999-2005 Yukihiro Matsumoto
6
- # Copyright (c) 1999-2005 Minero Aoki
5
+ # Copyright (c) 1999-2004 Yukihiro Matsumoto
6
+ # Copyright (c) 1999-2004 Minero Aoki
7
7
  #
8
8
  # written and maintained by Minero Aoki <aamine@loveruby.net>
9
9
  #
@@ -45,23 +45,41 @@ module Net # :nodoc:
45
45
  class ProtoRetriableError < ProtocolError; end
46
46
  ProtocRetryError = ProtoRetriableError
47
47
 
48
+ ##
49
+ # OpenTimeout, a subclass of Timeout::Error, is raised if a connection cannot
50
+ # be created within the open_timeout.
51
+
52
+ class OpenTimeout < Timeout::Error; end
53
+
54
+ ##
55
+ # ReadTimeout, a subclass of Timeout::Error, is raised if a chunk of the
56
+ # response cannot be read within the read_timeout.
57
+
58
+ class ReadTimeout < Timeout::Error; end
59
+
48
60
 
49
61
  class BufferedIO #:nodoc: internal use only
50
62
  def initialize(io)
51
63
  @io = io
52
64
  @read_timeout = 60
65
+ @continue_timeout = nil
53
66
  @debug_output = nil
54
67
  @rbuf = ''
55
68
  end
56
69
 
57
70
  attr_reader :io
58
71
  attr_accessor :read_timeout
72
+ attr_accessor :continue_timeout
59
73
  attr_accessor :debug_output
60
74
 
61
75
  def inspect
62
76
  "#<#{self.class} io=#{@io}>"
63
77
  end
64
78
 
79
+ def eof?
80
+ @io.eof?
81
+ end
82
+
65
83
  def closed?
66
84
  @io.closed?
67
85
  end
@@ -121,7 +139,7 @@ module Net # :nodoc:
121
139
  return rbuf_consume(@rbuf.size)
122
140
  end
123
141
  end
124
-
142
+
125
143
  def readline
126
144
  readuntil("\n").chop
127
145
  end
@@ -131,9 +149,23 @@ module Net # :nodoc:
131
149
  BUFSIZE = 1024 * 16
132
150
 
133
151
  def rbuf_fill
134
- timeout(@read_timeout) {
135
- @rbuf << @io.sysread(BUFSIZE)
136
- }
152
+ begin
153
+ @rbuf << @io.read_nonblock(BUFSIZE)
154
+ rescue IO::WaitReadable
155
+ if IO.select([@io], nil, nil, @read_timeout)
156
+ retry
157
+ else
158
+ raise Net::ReadTimeout
159
+ end
160
+ rescue IO::WaitWritable
161
+ # OpenSSL::Buffering#read_nonblock may fail with IO::WaitWritable.
162
+ # http://www.openssl.org/support/faq.html#PROG10
163
+ if IO.select(nil, [@io], nil, @read_timeout)
164
+ retry
165
+ else
166
+ raise Net::ReadTimeout
167
+ end
168
+ end
137
169
  end
138
170
 
139
171
  def rbuf_consume(len)
@@ -154,6 +186,8 @@ module Net # :nodoc:
154
186
  }
155
187
  end
156
188
 
189
+ alias << write
190
+
157
191
  def writeline(str)
158
192
  writing {
159
193
  write0 str + "\r\n"
@@ -202,16 +236,6 @@ module Net # :nodoc:
202
236
 
203
237
 
204
238
  class InternetMessageIO < BufferedIO #:nodoc: internal use only
205
- def InternetMessageIO.old_open(addr, port,
206
- open_timeout = nil, read_timeout = nil, debug_output = nil)
207
- debug_output << "opening connection to #{addr}...\n" if debug_output
208
- s = timeout(open_timeout) { TCPsocket.new(addr, port) }
209
- io = new(s)
210
- io.read_timeout = read_timeout
211
- io.debug_output = debug_output
212
- io
213
- end
214
-
215
239
  def initialize(io)
216
240
  super
217
241
  @wbuf = nil
@@ -232,7 +256,7 @@ module Net # :nodoc:
232
256
  LOG_on()
233
257
  LOG "read message (#{read_bytes} bytes)"
234
258
  end
235
-
259
+
236
260
  # *library private* (cannot handle 'break')
237
261
  def each_list_item
238
262
  while (str = readuntil("\r\n")) != ".\r\n"
@@ -298,7 +322,7 @@ module Net # :nodoc:
298
322
 
299
323
  def each_crlf_line(src)
300
324
  buffer_filling(@wbuf, src) do
301
- while line = @wbuf.slice!(/\A.*(?:\n|\r\n|\r(?!\z))/n)
325
+ while line = @wbuf.slice!(/\A[^\r\n]*(?:\n|\r(?:\n|(?!\z)))/)
302
326
  yield line.chomp("\n") + "\r\n"
303
327
  end
304
328
  end
@@ -317,8 +341,8 @@ module Net # :nodoc:
317
341
  yield
318
342
  end
319
343
  else # generic reader
320
- src.each do |s|
321
- buf << s
344
+ src.each do |str|
345
+ buf << str
322
346
  yield if buf.size > 1024
323
347
  end
324
348
  yield unless buf.empty?
@@ -1,7 +1,7 @@
1
1
  module RubySL
2
2
  module Net
3
3
  module Protocol
4
- VERSION = "1.0.0"
4
+ VERSION = "2.0.1"
5
5
  end
6
6
  end
7
7
  end
@@ -16,6 +16,9 @@ Gem::Specification.new do |spec|
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ["lib"]
18
18
 
19
+ spec.required_ruby_version = "~> 2.0"
20
+
19
21
  spec.add_development_dependency "bundler", "~> 1.3"
20
22
  spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "mspec", "~> 1.5"
21
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubysl-net-protocol
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Shirai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-27 00:00:00.000000000 Z
11
+ date: 2013-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
41
55
  description: Ruby standard library net-protocol.
42
56
  email:
43
57
  - brixen@gmail.com
@@ -46,6 +60,7 @@ extensions: []
46
60
  extra_rdoc_files: []
47
61
  files:
48
62
  - .gitignore
63
+ - .travis.yml
49
64
  - Gemfile
50
65
  - LICENSE
51
66
  - README.md
@@ -65,9 +80,9 @@ require_paths:
65
80
  - lib
66
81
  required_ruby_version: !ruby/object:Gem::Requirement
67
82
  requirements:
68
- - - '>='
83
+ - - ~>
69
84
  - !ruby/object:Gem::Version
70
- version: '0'
85
+ version: '2.0'
71
86
  required_rubygems_version: !ruby/object:Gem::Requirement
72
87
  requirements:
73
88
  - - '>='
@@ -80,3 +95,4 @@ signing_key:
80
95
  specification_version: 4
81
96
  summary: Ruby standard library net-protocol.
82
97
  test_files: []
98
+ has_rdoc: