File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -178,26 +178,40 @@ def create_plot
178178
179179 def output_data ( input )
180180 # Pass the input to subsequent pipelines
181- case options [ :pass ]
182- when IO , StringIO
183- options [ :pass ] . print ( input )
184- else
185- if options [ :pass ]
186- File . open ( options [ :pass ] , 'w' ) do | f |
187- f . print ( input )
188- end
181+ out = options [ :pass ]
182+ # Handle Tempfile first to keep tests and behavior consistent.
183+ # Ruby 2.7 Tempfile is Delegator-based and does not match IO/File checks.
184+ # Then handle path strings and IO-like objects.
185+ case out
186+ when Tempfile
187+ File . open ( out . path , 'w' ) do | f |
188+ f . print ( input )
189189 end
190+ when String
191+ File . open ( out , 'w' ) do |f |
192+ f . print ( input )
193+ end
194+ else
195+ out . print ( input ) if out . respond_to? ( :print )
190196 end
191197 end
192198
193199 def output_plot ( plot )
194- case options [ :output ]
195- when IO , StringIO
196- plot . render ( options [ :output ] )
197- when String , Tempfile
198- File . open ( options [ :output ] , 'w' ) do |f |
200+ out = options [ :output ]
201+ # Handle Tempfile first to keep tests and behavior consistent.
202+ # Ruby 2.7 Tempfile is Delegator-based and does not match IO/File checks.
203+ # Then handle path strings and IO-like objects.
204+ case out
205+ when Tempfile
206+ File . open ( out . path , 'w' ) do |f |
199207 plot . render ( f )
200208 end
209+ when String
210+ File . open ( out , 'w' ) do |f |
211+ plot . render ( f )
212+ end
213+ else
214+ plot . render ( out ) if out . respond_to? ( :write )
201215 end
202216 end
203217
You can’t perform that action at this time.
0 commit comments