async-http 0.40.0 → 0.40.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
  SHA256:
3
- metadata.gz: 9648e5ee0b4e51a48771c3c861cdd9642eaba42a2d55fe9ad6bf47a70f2dc150
4
- data.tar.gz: 4690e5a313f699de6ac6e774259f21ec889fb3f4540074c3526c92bc1e0ceab8
3
+ metadata.gz: 19652f31b1217cc8b9e93e6d633e0f4bf5fd8fbd0b2f65ad68ebefee8e5bae8e
4
+ data.tar.gz: 0a0c185d0127532f1c078dd39719e705f102b5750cc5b62d206f3b535c6f30c0
5
5
  SHA512:
6
- metadata.gz: 816c05d8d689c21b64f046cff2f7da9460c4b4d9b28205ce23b91ac8fd3053edfced60d9d5838a9f237e89497b004a644267c7f4cfd14a375f08a1195ae15ff9
7
- data.tar.gz: 9c4ed6fa66a82c2ad4de23249ff5e21ba1a8d24d9d59ccf07b93b640233d2892afe5e3a70ce84e3d5eb04e032b4ef0ec84926c41803ab198dc0b1ec6b3dffe52
6
+ metadata.gz: 3395f5ac2df1c7b7ca1d966329726bfbed96dbcba0a5f1d17291975c83e1ac76aefd0ed8d5649dc0924688bdc933a24e23250f0fe558ae54e771a4a2c7f4767e
7
+ data.tar.gz: b2edc23828a9bce9714fb86c2b12eb3dd0795dca1e573b200b52398506c1b591e44cf7364abc017765d4e939aabcc96e3d969a78d26cd796c95126a2be07a84c
@@ -44,34 +44,32 @@ module Async
44
44
 
45
45
  def call(stream)
46
46
  return @block.call(stream)
47
- ensure
48
- @block = nil
49
47
  end
50
48
 
51
49
  # Has the producer called #finish and has the reader consumed the nil token?
52
50
  def empty?
53
- @block.nil?
51
+ if @stream
52
+ @stream.empty?
53
+ else
54
+ false
55
+ end
54
56
  end
55
57
 
56
58
  # Read the next available chunk.
57
59
  def read
58
- return unless @block
59
-
60
60
  unless @task
61
61
  @stream = Stream.new(@input)
62
62
 
63
63
  @task = Task.current.async do
64
64
  @block.call(@stream)
65
65
  end
66
-
67
- @block = nil
68
66
  end
69
67
 
70
68
  return @stream.output.read
71
69
  end
72
70
 
73
71
  def inspect
74
- "\#<#{self.class} #{@block}>"
72
+ "\#<#{self.class} #{@block.inspect}>"
75
73
  end
76
74
  end
77
75
  end
@@ -31,6 +31,7 @@ module Async
31
31
 
32
32
  # Will hold remaining data in `#read`.
33
33
  @buffer = nil
34
+ @closed = false
34
35
  end
35
36
 
36
37
  attr :input
@@ -110,9 +111,22 @@ module Async
110
111
  @output&.close
111
112
  end
112
113
 
114
+ # Close the input and output bodies.
113
115
  def close
114
116
  self.close_read
115
117
  self.close_write
118
+ ensure
119
+ @closed = true
120
+ end
121
+
122
+ # Whether the stream has been closed.
123
+ def closed?
124
+ @closed
125
+ end
126
+
127
+ # Whether there are any output chunks remaining?
128
+ def empty?
129
+ @output.empty?
116
130
  end
117
131
 
118
132
  private
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module HTTP
23
- VERSION = "0.40.0"
23
+ VERSION = "0.40.1"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.40.0
4
+ version: 0.40.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams