lib/ddr/index/csv_query_result.rb in ddr-models-2.6.2 vs lib/ddr/index/csv_query_result.rb in ddr-models-2.7.0.rc1

- old
+ new

@@ -24,10 +24,11 @@ @table ||= CSV.parse(data, csv_opts) end def csv_opts { headers: csv_headers, + converters: [convert_semicolons, convert_escaped_newlines], return_headers: false, write_headers: true, } end @@ -58,11 +59,18 @@ def solr_csv_params params.merge(solr_csv_opts) end def data - raw = Connection.get("select", params: solr_csv_params) - raw.gsub(/\\#{CSV_MV_SEPARATOR}/, CSV_MV_SEPARATOR) + Connection.get("select", params: solr_csv_params) + end + + def convert_semicolons + lambda { |f| f.gsub(/\\#{CSV_MV_SEPARATOR}/, CSV_MV_SEPARATOR) rescue f } + end + + def convert_escaped_newlines + lambda { |f| f.gsub(/\\r/, "\r").gsub(/\\n/, "\n") rescue f } end end end