lib/eco/api/common/people/default_parsers/xls_parser.rb in eco-helpers-2.6.4 vs lib/eco/api/common/people/default_parsers/xls_parser.rb in eco-helpers-2.7.0
- old
+ new
@@ -2,21 +2,21 @@
attribute :xls
attr_accessor :already_required
attr_reader :file
- def parser(file, deps)
+ def parser(file, _deps)
@file = file
rows.tap do |rws|
@file = nil
rws.each do |row|
to_string!(row)
end
end
end
- def serializer(array_hash, deps)
+ def serializer(_array_hash, _deps)
raise "Not implemented. TODO: using axlsx or rubyXL gems. See: https://spin.atomicobject.com/2017/03/22/parsing-excel-files-ruby/"
end
private
@@ -26,11 +26,10 @@
next val if val.is_a?(String)
val.to_s
end
end
-
def headers
logger.warn("Headers detection is using your fields_map.json file (native behaviour)")
session.fields_mapper.list(:external).uniq
end
@@ -46,22 +45,20 @@
def spreadheet(name_or_index = sheet_name)
workbook.sheet(name_or_index)
end
def rows(target = headers)
- begin
- spreadheet.parse(header_search: target, clean: true)
- rescue Roo::HeaderRowNotFoundError => e
- missing = JSON.parse(e.message)
- logger.warn("The input file is missing these headers: #{missing}")
- present = target - missing
- rows(present)
- end
+ spreadheet.parse(header_search: target, clean: true)
+ rescue Roo::HeaderRowNotFoundError => e
+ missing = JSON.parse(e.message)
+ logger.warn("The input file is missing these headers: #{missing}")
+ present = target - missing
+ rows(present)
end
def require_reading_libs!
return if already_required
require 'roo'
require 'roo-xls'
- already_required = true
+ self.already_required = true
end
end