File tree Expand file tree Collapse file tree 12 files changed +58
-9
lines changed Expand file tree Collapse file tree 12 files changed +58
-9
lines changed Original file line number Diff line number Diff line change @@ -154,7 +154,9 @@ def rewind
154154 # @returns [String] a string representation of the buffered body.
155155 def inspect
156156 if @chunks
157- "\# <#{ self . class } #{ @chunks . size } chunks, #{ self . length } bytes>"
157+ "#<#{ self . class } #{ @index } /#{ @chunks . size } chunks, #{ self . length } bytes>"
158+ else
159+ "#<#{ self . class } empty>"
158160 end
159161 end
160162 end
Original file line number Diff line number Diff line change @@ -53,6 +53,14 @@ def close(error = nil)
5353
5454 super
5555 end
56+
57+ # Inspect the completable body.
58+ #
59+ # @returns [String] a string representation of the completable body.
60+ def inspect
61+ callback_status = @callback ? "callback pending" : "callback completed"
62+ return "#{ super } | #<#{ self . class } #{ callback_status } >"
63+ end
5664 end
5765 end
5866 end
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ def ratio
7979 #
8080 # @returns [String] a string representation of the body.
8181 def inspect
82- "#{ super } | \ # <#{ self . class } #{ ( ratio *100 ) . round ( 2 ) } %>"
82+ "#{ super } | #<#{ self . class } #{ ( ratio *100 ) . round ( 2 ) } %>"
8383 end
8484 end
8585
Original file line number Diff line number Diff line change @@ -135,7 +135,11 @@ def join
135135 #
136136 # @returns [String] a string representation of the file body.
137137 def inspect
138- "\# <#{ self . class } file=#{ @file . inspect } offset=#{ @offset } remaining=#{ @remaining } >"
138+ if @offset > 0
139+ "#<#{ self . class } #{ @file . inspect } +#{ @offset } , #{ @remaining } bytes remaining>"
140+ else
141+ "#<#{ self . class } #{ @file . inspect } , #{ @remaining } bytes remaining>"
142+ end
139143 end
140144 end
141145 end
Original file line number Diff line number Diff line change @@ -53,6 +53,13 @@ def ready?
5353 def length
5454 @length
5555 end
56+
57+ # Inspect the head body.
58+ #
59+ # @returns [String] a string representation of the head body.
60+ def inspect
61+ "#<#{ self . class } #{ @length } bytes (empty)>"
62+ end
5663 end
5764 end
5865 end
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ def rewindable?
8686 #
8787 # @returns [String] a string representation of the body.
8888 def inspect
89- "\ # <#{ self . class } #{ @index } /#{ @chunks . size } chunks read>"
89+ "#{ super } | #<#{ self . class } #{ @index } /#{ @chunks . size } chunks read>"
9090 end
9191 end
9292 end
Original file line number Diff line number Diff line change @@ -386,6 +386,21 @@ def closed?
386386 @closed
387387 end
388388
389+ # Inspect the stream.
390+ #
391+ # @returns [String] a string representation of the stream.
392+ def inspect
393+ buffer_info = @buffer ? "#{ @buffer . bytesize } bytes buffered" : "no buffer"
394+
395+ status = [ ]
396+ status << "closed" if @closed
397+ status << "read-closed" if @closed_read
398+
399+ status_info = status . empty? ? "open" : status . join ( ", " )
400+
401+ return "#<#{ self . class } #{ buffer_info } , #{ status_info } >"
402+ end
403+
389404 # @returns [Boolean] Whether there are any output chunks remaining.
390405 def empty?
391406 @output . empty?
Original file line number Diff line number Diff line change @@ -149,6 +149,19 @@ def close_input(error = nil)
149149 def close_output ( error = nil )
150150 @output &.close ( error )
151151 end
152+
153+ # Inspect the streaming body.
154+ #
155+ # @returns [String] a string representation of the streaming body.
156+ def inspect
157+ if @block
158+ "#<#{ self . class } block available, not consumed>"
159+ elsif @output
160+ "#<#{ self . class } block consumed, output active>"
161+ else
162+ "#<#{ self . class } block consumed, output closed>"
163+ end
164+ end
152165 end
153166
154167 # A response body is used on the server side to generate the response body using a block.
Original file line number Diff line number Diff line change @@ -166,9 +166,9 @@ def output
166166 # @returns [String] A string representation of the body.
167167 def inspect
168168 if @error
169- "\ # <#{ self . class } #{ @count } chunks written, #{ status } , error=#{ @error } >"
169+ "#<#{ self . class } #{ @count } chunks written, #{ status } , error=#{ @error } >"
170170 else
171- "\ # <#{ self . class } #{ @count } chunks written, #{ status } >"
171+ "#<#{ self . class } #{ @count } chunks written, #{ status } >"
172172 end
173173 end
174174
Original file line number Diff line number Diff line change 5858
5959 with "#inspect" do
6060 it "can generate string representation" do
61- expect ( compressed_body . inspect ) . to be == "#<Protocol::HTTP::Body::Buffered 0 chunks, 0 bytes> | #<Protocol::HTTP::Body::Deflate 100.0%>"
61+ expect ( compressed_body . inspect ) . to be == "#<Protocol::HTTP::Body::Buffered 0/0 chunks, 0 bytes> | #<Protocol::HTTP::Body::Deflate 100.0%>"
6262 end
6363 end
6464end
You can’t perform that action at this time.
0 commit comments