CSC/ECE 517 Fall 2019 - E1938. OSS project Duke Blue: Fix import glitches
Issue #918
New code introduced is as follows.
File:app/helpers/import_topics_helper.rb
Code:
def self.define_attributes(row_hash)
attributes = {} if !row_hash[:description].nil? and !row_hash[:description].ascii_only? row_hash[:description] = self.trim_non_ascii(row_hash[:description]) puts row_hash[:description] end attributes["topic_identifier"] = row_hash[:topic_identifier].strip attributes["topic_name"] = row_hash[:topic_name].strip attributes["max_choosers"] = row_hash[:max_choosers].strip attributes end
def self.trim_non_ascii(string) string.split().each do |char| !char.ascii_only? ? string.tr!(char, ' ') : nil end string.gsub!(/\s+/, ' ') end