From bfae38147eddf5fc055d9af7535b5011b0e04f04 Mon Sep 17 00:00:00 2001 From: viehlieb Date: Fri, 20 Jan 2023 14:37:43 +0100 Subject: [PATCH] removed parameterized parse function --- lib/foodsoft_article_import.rb | 10 +--------- lib/foodsoft_article_import/bioromeo.rb | 2 +- lib/foodsoft_article_import/borkenstein.rb | 2 +- lib/foodsoft_article_import/dnb_xml.rb | 2 +- lib/foodsoft_article_import/foodsoft.rb | 2 +- 5 files changed, 5 insertions(+), 13 deletions(-) diff --git a/lib/foodsoft_article_import.rb b/lib/foodsoft_article_import.rb index fee3162..34db818 100644 --- a/lib/foodsoft_article_import.rb +++ b/lib/foodsoft_article_import.rb @@ -34,18 +34,10 @@ module FoodsoftArticleImport # @param file [File, Tempfile] # @option opts [String] type file format (required) (see {.file_formats}) # @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 parser = file_formats[type] if block_given? - puts " - " + "______________" + " - " + "______________" + " - " + "______________" + " - " + "given" + " - " + "______________"+ " - " + "______________"+ " - " + "______________" parser.parse(file, custom_file, **opts, &blk) else data = [] diff --git a/lib/foodsoft_article_import/bioromeo.rb b/lib/foodsoft_article_import/bioromeo.rb index 27ef8d4..ddad5d2 100644 --- a/lib/foodsoft_article_import/bioromeo.rb +++ b/lib/foodsoft_article_import/bioromeo.rb @@ -27,7 +27,7 @@ module FoodsoftArticleImport RES_PARSE_UNIT_LIST.map {|r| /#{r}\s*$/} + RES_PARSE_UNIT_LIST.map {|r| /-#{r}/} - def self.parse(file, **opts) + def self.parse(file, custom_file=nil, **opts) opts = OPTIONS.merge(opts) ss = FoodsoftArticleImport.open_spreadsheet(file, **opts) diff --git a/lib/foodsoft_article_import/borkenstein.rb b/lib/foodsoft_article_import/borkenstein.rb index 896503b..5c30de9 100644 --- a/lib/foodsoft_article_import/borkenstein.rb +++ b/lib/foodsoft_article_import/borkenstein.rb @@ -19,7 +19,7 @@ module FoodsoftArticleImport encoding: "UTF-8" # @todo check this }.freeze - def self.parse(file, **opts) + def self.parse(file, custom_file=nil, **opts) global_manufacturer = nil file.set_encoding(opts[:encoding] || OPTIONS[:encoding]) diff --git a/lib/foodsoft_article_import/dnb_xml.rb b/lib/foodsoft_article_import/dnb_xml.rb index efd21a6..853044a 100644 --- a/lib/foodsoft_article_import/dnb_xml.rb +++ b/lib/foodsoft_article_import/dnb_xml.rb @@ -14,7 +14,7 @@ module FoodsoftArticleImport OPTIONS = {}.freeze # parses a string or file - def self.parse(file, opts={}) + def self.parse(file, custom_file=nil, opts={}) doc = Nokogiri.XML(file, nil, nil, Nokogiri::XML::ParseOptions::RECOVER + Nokogiri::XML::ParseOptions::NONET + diff --git a/lib/foodsoft_article_import/foodsoft.rb b/lib/foodsoft_article_import/foodsoft.rb index 64c70e0..a4c099c 100644 --- a/lib/foodsoft_article_import/foodsoft.rb +++ b/lib/foodsoft_article_import/foodsoft.rb @@ -16,7 +16,7 @@ module FoodsoftArticleImport::Foodsoft # Parses Foodsoft file # the yielded article is a simple hash - def self.parse(file, **opts) + def self.parse(file, custom_file=nil, **opts) opts = OPTIONS.merge(opts) ss = FoodsoftArticleImport.open_spreadsheet(file, **opts)