Skip to content

Commit

Permalink
Enable liberal_parsing for ruby >=2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
knu committed May 27, 2017
1 parent 0f5edc9 commit d2d557d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/models/agents/csv_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d2d557d

Please sign in to comment.