summaryrefslogtreecommitdiff
path: root/lib/csv/parser.rb
diff options
context:
space:
mode:
authorrm155 <[email protected]>2021-10-10 22:21:42 -0400
committerSutou Kouhei <[email protected]>2021-10-24 05:57:33 +0900
commitee948fc1b4cb1ad382beee709008bb93b8f6ba75 (patch)
tree323e979f3c67259699d838228d28a0ea4fb3ac92 /lib/csv/parser.rb
parent274882be62e5996d804e87103586feaeec381820 (diff)
[ruby/csv] Add support for Ractor (https://github.com/ruby/csv/pull/218)
https://github.com/ruby/csv/commit/a802690e11
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5010
Diffstat (limited to 'lib/csv/parser.rb')
-rw-r--r--lib/csv/parser.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/csv/parser.rb b/lib/csv/parser.rb
index 0d8a157fd7..3334acfbdd 100644
--- a/lib/csv/parser.rb
+++ b/lib/csv/parser.rb
@@ -480,9 +480,9 @@ class CSV
begin
StringScanner.new("x").scan("x")
rescue TypeError
- @@string_scanner_scan_accept_string = false
+ STRING_SCANNER_SCAN_ACCEPT_STRING = false
else
- @@string_scanner_scan_accept_string = true
+ STRING_SCANNER_SCAN_ACCEPT_STRING = true
end
def prepare_separators
@@ -506,7 +506,7 @@ class CSV
@first_column_separators = Regexp.new(@escaped_first_column_separator +
"+".encode(@encoding))
else
- if @@string_scanner_scan_accept_string
+ if STRING_SCANNER_SCAN_ACCEPT_STRING
@column_end = @column_separator
else
@column_end = Regexp.new(@escaped_column_separator)
@@ -725,6 +725,8 @@ class CSV
end
end
+ SCANNER_TEST_CHUNK_SIZE =
+ Integer((ENV["CSV_PARSER_SCANNER_TEST_CHUNK_SIZE"] || "1"), 10)
def build_scanner
inputs = @samples.collect do |sample|
UnoptimizedStringIO.new(sample)
@@ -734,10 +736,9 @@ class CSV
else
inputs << @input
end
- chunk_size = ENV["CSV_PARSER_SCANNER_TEST_CHUNK_SIZE"] || "1"
InputsScanner.new(inputs,
@encoding,
- chunk_size: Integer(chunk_size, 10))
+ chunk_size: SCANNER_TEST_CHUNK_SIZE)
end
else
def build_scanner