2019-04-15 00:01:51 +03:00
|
|
|
require "tempfile"
|
2010-12-25 09:58:58 +03:00
|
|
|
require "test/unit"
|
|
|
|
|
|
|
|
require "csv"
|
|
|
|
|
2019-07-09 15:16:49 +03:00
|
|
|
require_relative "../lib/with_different_ofs"
|
2019-04-15 00:01:51 +03:00
|
|
|
|
2023-04-04 00:31:49 +03:00
|
|
|
module CSVHelper
|
2019-04-15 00:01:51 +03:00
|
|
|
def with_chunk_size(chunk_size)
|
|
|
|
chunk_size_keep = ENV["CSV_PARSER_SCANNER_TEST_CHUNK_SIZE"]
|
|
|
|
begin
|
|
|
|
ENV["CSV_PARSER_SCANNER_TEST_CHUNK_SIZE"] = chunk_size
|
|
|
|
yield
|
|
|
|
ensure
|
|
|
|
ENV["CSV_PARSER_SCANNER_TEST_CHUNK_SIZE"] = chunk_size_keep
|
|
|
|
end
|
|
|
|
end
|
2019-11-25 04:06:59 +03:00
|
|
|
|
|
|
|
def with_verbose(verbose)
|
|
|
|
original = $VERBOSE
|
|
|
|
begin
|
|
|
|
$VERBOSE = verbose
|
|
|
|
yield
|
|
|
|
ensure
|
|
|
|
$VERBOSE = original
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def with_default_internal(encoding)
|
|
|
|
original = Encoding.default_internal
|
|
|
|
begin
|
|
|
|
with_verbose(false) do
|
|
|
|
Encoding.default_internal = encoding
|
|
|
|
end
|
|
|
|
yield
|
|
|
|
ensure
|
|
|
|
with_verbose(false) do
|
|
|
|
Encoding.default_internal = original
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-04-15 00:01:51 +03:00
|
|
|
end
|