lib/remote_table/delimited.rb in remote_table-3.0.0.beta vs lib/remote_table/delimited.rb in remote_table-3.0.0.rc1

- old
+ new

@@ -29,11 +29,11 @@ if not headers # represent the row as an array array = row.map do |v| - v = v.to_s + v = RemoteTable.normalize_whitespace v if not some_value_present and not keep_blank_rows and v.present? some_value_present = true end v end @@ -44,11 +44,11 @@ else # represent the row as a hash hash = ::ActiveSupport::OrderedHash.new row.each do |k, v| - v = v.to_s + v = RemoteTable.normalize_whitespace v if not some_value_present and not keep_blank_rows and v.present? some_value_present = true end hash[k] = v end @@ -60,18 +60,10 @@ end ensure local_copy.cleanup end - # Passes user-specified options in PASSTHROUGH_CSV_SETTINGS. - # - # Also maps: - # * +:headers+ directly - # * +:keep_blank_rows+ to the CSV option +:skip_blanks+ - # * +:delimiter+ to the CSV option +:col_sep+ - # - # @return [Hash] def csv_options { skip_blanks: !keep_blank_rows, headers: headers, col_sep: delimiter, @@ -86,10 +78,10 @@ false when :first_row, TrueClass i = 0 line = local_copy.encoded_io.gets Engine.parse_line(line).map do |v| - header = v.to_s.gsub(/\s+/, ' ').strip + header = RemoteTable.normalize_whitespace v header.present? ? header : "empty_#{i+=1}" end when Array @headers else