aboutsummaryrefslogtreecommitdiffstats
path: root/lib/roo/csv.rb
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2022-03-19 21:47:36 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2022-03-19 21:47:36 -0400
commitf5fb17e5a64b215644bc104f099dad8c2f10c37d (patch)
tree6ad047451881cfe94f3aabe1c33b404c134a5085 /lib/roo/csv.rb
parent9e07e8cd4836ddc89accdb7b20152c9a4f06fd03 (diff)
New upstream version 2.9.0.upstream/2.9.0
Diffstat (limited to 'lib/roo/csv.rb')
-rw-r--r--lib/roo/csv.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/roo/csv.rb b/lib/roo/csv.rb
index 516def6..4431bc2 100644
--- a/lib/roo/csv.rb
+++ b/lib/roo/csv.rb
@@ -90,17 +90,23 @@ module Roo
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