Fix import options and add tests
This commit is contained in:
parent
610cd8fce4
commit
26e7012ef0
5 changed files with 20 additions and 16 deletions
|
|
@ -8,10 +8,10 @@ class FoodsoftFile
|
|||
# the parsed article is a simple hash
|
||||
def self.parse(file, options = {})
|
||||
filepath = file.is_a?(String) ? file : file.to_path
|
||||
filename = options[:filename] || filepath
|
||||
fileext = ::File.extname(filename)
|
||||
options = {col_sep: ';', encoding: 'utf-8'}.merge(options)
|
||||
s = Roo::Spreadsheet.open filepath, extension: fileext, csv_options: options
|
||||
filename = options.delete(:filename) || filepath
|
||||
fileext = File.extname(filename)
|
||||
options[:csv_options] = {col_sep: ';', encoding: 'utf-8'}.merge(options[:csv_options]||{})
|
||||
s = Roo::Spreadsheet.open(filepath, options.merge({extension: fileext}))
|
||||
|
||||
row_index = 1
|
||||
s.each do |row|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue