From d2d557dc7b5d4f9668920877403b63a3f93cf802 Mon Sep 17 00:00:00 2001 From: Akinori MUSHA Date: Thu, 19 Jan 2017 16:30:23 +0900 Subject: [PATCH] Enable `liberal_parsing` for ruby >=2.4 --- app/models/agents/csv_agent.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/agents/csv_agent.rb b/app/models/agents/csv_agent.rb index 5246ff0296..50e1e9f829 100644 --- a/app/models/agents/csv_agent.rb +++ b/app/models/agents/csv_agent.rb @@ -161,8 +161,17 @@ def local_get_io(event) end end + def parse_csv_options(mo) + options = { + col_sep: separator(mo), + headers: boolify(mo['with_header']), + } + options[:liberal_parsing] = true if CSV::DEFAULT_OPTIONS.key?(:liberal_parsing) + options + end + def parse_csv(io, mo, array = nil) - CSV.new(io, col_sep: separator(mo), headers: boolify(mo['with_header'])).each do |row| + CSV.new(io, **parse_csv_options(mo)).each do |row| if block_given? yield get_payload(row, mo) else