ione 1.2.0.pre3 → 1.2.0.pre4
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/ione/future.rb +9 -5
- data/lib/ione/io/base_connection.rb +4 -2
- data/lib/ione/io/ssl_connection.rb +3 -1
- data/lib/ione/version.rb +1 -1
- data/spec/ione/future_spec.rb +16 -0
- data/spec/ione/io/ssl_connection_spec.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0d198d610290a10e580f755f216bbae8ccca0ab
|
4
|
+
data.tar.gz: ada926b95e4a03d55ffad99687ca9f468d1cdd1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85e98209e280e3fcd0ca52577ffde6fdbe337191af45830bf9b43d3ded0839aa3ef902267da22abb62f937a2d3321ca0abaf15cd66a0920dfe2a9dc3357d2f19
|
7
|
+
data.tar.gz: e5eac3de0c0024e20bad63f82a32a57973d50081df75bf789f7d76bfda413bb8a180bb5ae6919be3aff91c4fa809d8596bfa26a02b0f3bc995b023801cbf3133
|
data/lib/ione/future.rb
CHANGED
@@ -91,10 +91,14 @@ module Ione
|
|
91
91
|
# @return [Ione::Future<Array>] an array of the values of the constituent
|
92
92
|
# futures
|
93
93
|
def all(*futures)
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
94
|
+
if futures.size == 1 && (fs = futures.first).is_a?(Enumerable)
|
95
|
+
futures = fs
|
96
|
+
end
|
97
|
+
if futures.count == 0
|
98
|
+
resolved([])
|
99
|
+
else
|
100
|
+
CombinedFuture.new(futures)
|
101
|
+
end
|
98
102
|
end
|
99
103
|
|
100
104
|
# Returns a future which will be resolved with the value of the first
|
@@ -741,7 +745,7 @@ module Ione
|
|
741
745
|
true
|
742
746
|
end
|
743
747
|
|
744
|
-
def
|
748
|
+
def resolved?
|
745
749
|
true
|
746
750
|
end
|
747
751
|
|
@@ -19,7 +19,10 @@ module Ione
|
|
19
19
|
#
|
20
20
|
# @return [true, false] returns false if the connection was already closed
|
21
21
|
def close(cause=nil)
|
22
|
-
|
22
|
+
@lock.synchronize do
|
23
|
+
return false if @state == :closed
|
24
|
+
@state = :closed
|
25
|
+
end
|
23
26
|
if @io
|
24
27
|
begin
|
25
28
|
@io.close
|
@@ -28,7 +31,6 @@ module Ione
|
|
28
31
|
# nothing to do, the socket was most likely already closed
|
29
32
|
end
|
30
33
|
end
|
31
|
-
@state = :closed
|
32
34
|
if cause && !cause.is_a?(IoError)
|
33
35
|
cause = ConnectionClosedError.new(cause.message)
|
34
36
|
end
|
@@ -45,7 +45,7 @@ module Ione
|
|
45
45
|
new_data = @io.read_nonblock(2**16)
|
46
46
|
@data_listener.call(new_data) if @data_listener
|
47
47
|
end
|
48
|
-
rescue IO::WaitReadable
|
48
|
+
rescue IO::WaitReadable, IO::WaitWritable
|
49
49
|
# no more data available
|
50
50
|
rescue => e
|
51
51
|
close(e)
|
@@ -59,6 +59,8 @@ module Ione
|
|
59
59
|
@data_listener.call(new_data) if @data_listener
|
60
60
|
read_size = @io.pending
|
61
61
|
end
|
62
|
+
rescue IO::WaitReadable, IO::WaitWritable
|
63
|
+
# no more data available
|
62
64
|
rescue => e
|
63
65
|
close(e)
|
64
66
|
end
|
data/lib/ione/version.rb
CHANGED
data/spec/ione/future_spec.rb
CHANGED
@@ -979,6 +979,14 @@ module Ione
|
|
979
979
|
Future.all.value.should == []
|
980
980
|
end
|
981
981
|
|
982
|
+
it 'completes with an empty list when an empty list is given' do
|
983
|
+
Future.all([]).value.should == []
|
984
|
+
end
|
985
|
+
|
986
|
+
it 'completes with an empty list when an empty enumerable is given' do
|
987
|
+
Future.all([].to_enum).value.should == []
|
988
|
+
end
|
989
|
+
|
982
990
|
it 'completes with a list of one item when a single future is given' do
|
983
991
|
f = Future.resolved(1)
|
984
992
|
Future.all(f).value.should == [1]
|
@@ -1000,6 +1008,14 @@ module Ione
|
|
1000
1008
|
f.value.should have(3).items
|
1001
1009
|
end
|
1002
1010
|
|
1011
|
+
it 'accepts an enumerable of one future' do
|
1012
|
+
promises = [Promise.new]
|
1013
|
+
futures = promises.map(&:future).to_enum
|
1014
|
+
f = Future.all(futures)
|
1015
|
+
promises.each(&:fulfill)
|
1016
|
+
f.value.should have(1).item
|
1017
|
+
end
|
1018
|
+
|
1003
1019
|
it 'accepts anything that implements #on_complete as futures' do
|
1004
1020
|
ff1, ff2, ff3 = double, double, double
|
1005
1021
|
ff1.stub(:on_complete) { |&listener| listener.call(1, nil) }
|
@@ -153,6 +153,24 @@ module Ione
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
+
it 'does not close the socket when #read_nonblock raises IO::WaitWritable' do
|
157
|
+
error = OpenSSL::SSL::SSLError.new
|
158
|
+
error.extend(IO::WaitWritable) unless error.is_a?(IO::WaitWritable)
|
159
|
+
ssl_socket.stub(:read_nonblock).and_raise(error)
|
160
|
+
handler.connect
|
161
|
+
handler.read
|
162
|
+
ssl_socket.should_not have_received(:close)
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'does not close the socket when #read_nonblock raises IO::WaitReadable' do
|
166
|
+
error = OpenSSL::SSL::SSLError.new
|
167
|
+
error.extend(IO::WaitReadable) unless error.is_a?(IO::WaitReadable)
|
168
|
+
ssl_socket.stub(:read_nonblock).and_raise(error)
|
169
|
+
handler.connect
|
170
|
+
handler.read
|
171
|
+
ssl_socket.should_not have_received(:close)
|
172
|
+
end
|
173
|
+
|
156
174
|
it 'closes the connection when an error occurs' do
|
157
175
|
ssl_socket.stub(:read_nonblock).and_raise('boork')
|
158
176
|
handler.connect
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ione
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.0.
|
4
|
+
version: 1.2.0.pre4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Theo Hultberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Reactive programming framework for Ruby, painless evented IO, futures
|
14
14
|
and an efficient byte buffer
|