async-io 1.9.4 → 1.10.0
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/async/io/protocol/line.rb +1 -1
- data/lib/async/io/stream.rb +21 -3
- data/lib/async/io/version.rb +1 -1
- data/spec/async/io/stream_spec.rb +25 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c16b3fc4731d433938fa0e1e17dfc6f9adf6d04e5be969490d48393c0c1e88c8
|
4
|
+
data.tar.gz: ce83e964e7bac569a90fc6c53130b0fbfe6ef8f331ecd8e070711237dc36e170
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c75b738875dab6744261a409eda31b33356fe0350fbf1baa61103294ef5166ba93f70b73428ba41c2077976b69aa6b755c71f8221b74ed913b7a13ad7bb0b7bb
|
7
|
+
data.tar.gz: 6e9f04ae63f63698bdfc611e67af677a293f103561de4cfb163de5e92aa3573ac89623d642e25419e5a4abc3436aae4d91d990c294852c6bcbca26ab269c039f
|
data/lib/async/io/stream.rb
CHANGED
@@ -138,11 +138,22 @@ module Async
|
|
138
138
|
flush
|
139
139
|
end
|
140
140
|
|
141
|
+
def closed?
|
142
|
+
@io.closed?
|
143
|
+
end
|
144
|
+
|
141
145
|
# Closes the stream and flushes any unwritten data.
|
142
146
|
def close
|
143
|
-
|
144
|
-
|
145
|
-
|
147
|
+
return if @io.closed?
|
148
|
+
|
149
|
+
begin
|
150
|
+
flush
|
151
|
+
rescue
|
152
|
+
# We really can't do anything here unless we want #close to raise exceptions.
|
153
|
+
Async.logger.error(self) {$!}
|
154
|
+
ensure
|
155
|
+
@io.close
|
156
|
+
end
|
146
157
|
end
|
147
158
|
|
148
159
|
# Returns true if the stream is at file which means there is no more data to be read.
|
@@ -154,6 +165,13 @@ module Async
|
|
154
165
|
|
155
166
|
alias eof eof?
|
156
167
|
|
168
|
+
def eof!
|
169
|
+
@read_buffer.clear
|
170
|
+
@eof = true
|
171
|
+
|
172
|
+
raise EOFError
|
173
|
+
end
|
174
|
+
|
157
175
|
private
|
158
176
|
|
159
177
|
# Fills the buffer from the underlying stream.
|
data/lib/async/io/version.rb
CHANGED
@@ -97,4 +97,29 @@ RSpec.describe Async::IO::Stream do
|
|
97
97
|
expect(io.string).to be == "Hello World\n"
|
98
98
|
end
|
99
99
|
end
|
100
|
+
|
101
|
+
describe '#eof' do
|
102
|
+
it "should terminate stream" do
|
103
|
+
expect do
|
104
|
+
stream.eof!
|
105
|
+
end.to raise_error(EOFError)
|
106
|
+
|
107
|
+
expect(stream).to be_eof
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe '#close' do
|
112
|
+
it 'can be closed even if underlying io is closed' do
|
113
|
+
io.close
|
114
|
+
|
115
|
+
expect(stream.io).to be_closed
|
116
|
+
|
117
|
+
# Put some data in the write buffer
|
118
|
+
stream.write "."
|
119
|
+
|
120
|
+
expect do
|
121
|
+
stream.close
|
122
|
+
end.to_not raise_error
|
123
|
+
end
|
124
|
+
end
|
100
125
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|