removed parameterized parse function

This commit is contained in:
viehlieb 2023-01-20 14:37:43 +01:00
parent 7a058847eb
commit bfae38147e
5 changed files with 5 additions and 13 deletions

View file

@ -34,18 +34,10 @@ module FoodsoftArticleImport
# @param file [File, Tempfile] # @param file [File, Tempfile]
# @option opts [String] type file format (required) (see {.file_formats}) # @option opts [String] type file format (required) (see {.file_formats})
# @return [File, Roo::Spreadsheet] file with encoding set if needed # @return [File, Roo::Spreadsheet] file with encoding set if needed
def self.parse(file, custom_file=nil, type:, **opts, &blk) def self.parse(file, custom_file=nil, type='bnn', **opts, &blk)
# @todo handle wrong or undetected type # @todo handle wrong or undetected type
parser = file_formats[type] parser = file_formats[type]
if block_given? if block_given?
puts "
" + "______________" + "
" + "______________" + "
" + "______________" + "
" + "given" + "
" + "______________"+ "
" + "______________"+ "
" + "______________"
parser.parse(file, custom_file, **opts, &blk) parser.parse(file, custom_file, **opts, &blk)
else else
data = [] data = []

View file

@ -27,7 +27,7 @@ module FoodsoftArticleImport
RES_PARSE_UNIT_LIST.map {|r| /#{r}\s*$/} + RES_PARSE_UNIT_LIST.map {|r| /#{r}\s*$/} +
RES_PARSE_UNIT_LIST.map {|r| /-#{r}/} RES_PARSE_UNIT_LIST.map {|r| /-#{r}/}
def self.parse(file, **opts) def self.parse(file, custom_file=nil, **opts)
opts = OPTIONS.merge(opts) opts = OPTIONS.merge(opts)
ss = FoodsoftArticleImport.open_spreadsheet(file, **opts) ss = FoodsoftArticleImport.open_spreadsheet(file, **opts)

View file

@ -19,7 +19,7 @@ module FoodsoftArticleImport
encoding: "UTF-8" # @todo check this encoding: "UTF-8" # @todo check this
}.freeze }.freeze
def self.parse(file, **opts) def self.parse(file, custom_file=nil, **opts)
global_manufacturer = nil global_manufacturer = nil
file.set_encoding(opts[:encoding] || OPTIONS[:encoding]) file.set_encoding(opts[:encoding] || OPTIONS[:encoding])

View file

@ -14,7 +14,7 @@ module FoodsoftArticleImport
OPTIONS = {}.freeze OPTIONS = {}.freeze
# parses a string or file # parses a string or file
def self.parse(file, opts={}) def self.parse(file, custom_file=nil, opts={})
doc = Nokogiri.XML(file, nil, nil, doc = Nokogiri.XML(file, nil, nil,
Nokogiri::XML::ParseOptions::RECOVER + Nokogiri::XML::ParseOptions::RECOVER +
Nokogiri::XML::ParseOptions::NONET + Nokogiri::XML::ParseOptions::NONET +

View file

@ -16,7 +16,7 @@ module FoodsoftArticleImport::Foodsoft
# Parses Foodsoft file # Parses Foodsoft file
# the yielded article is a simple hash # the yielded article is a simple hash
def self.parse(file, **opts) def self.parse(file, custom_file=nil, **opts)
opts = OPTIONS.merge(opts) opts = OPTIONS.merge(opts)
ss = FoodsoftArticleImport.open_spreadsheet(file, **opts) ss = FoodsoftArticleImport.open_spreadsheet(file, **opts)