lib/roo/csv.rb in roo-2.8.3 vs lib/roo/csv.rb in roo-2.9.0
- old
+ new
@@ -88,20 +88,26 @@
end
def each_row(options, &block)
if uri?(filename)
each_row_using_tempdir(options, &block)
- elsif is_stream?(filename_or_stream)
- ::CSV.new(filename_or_stream, options).each(&block)
else
- ::CSV.foreach(filename, options, &block)
+ csv_foreach(filename_or_stream, options, &block)
end
end
def each_row_using_tempdir(options, &block)
::Dir.mktmpdir(Roo::TEMP_PREFIX, ENV["ROO_TMP"]) do |tmpdir|
tmp_filename = download_uri(filename, tmpdir)
- ::CSV.foreach(tmp_filename, options, &block)
+ csv_foreach(tmp_filename, options, &block)
+ end
+ end
+
+ def csv_foreach(path_or_io, options, &block)
+ if is_stream?(path_or_io)
+ ::CSV.new(path_or_io, **options).each(&block)
+ else
+ ::CSV.foreach(path_or_io, **options, &block)
end
end
def set_row_count(sheet, last_row)
@first_row[sheet] = 1