From b31848744ff47570e9a4fb9e09ff141207898178 Mon Sep 17 00:00:00 2001 From: viehlieb Date: Sun, 26 Feb 2023 13:23:09 +0100 Subject: [PATCH] remove options from parsemethod --- lib/foodsoft_article_import.rb | 7 +++---- lib/foodsoft_article_import/bioromeo.rb | 4 ++-- lib/foodsoft_article_import/bnn.rb | 13 +------------ lib/foodsoft_article_import/foodsoft.rb | 4 ++-- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/lib/foodsoft_article_import.rb b/lib/foodsoft_article_import.rb index 289ecb7..22de3ee 100644 --- a/lib/foodsoft_article_import.rb +++ b/lib/foodsoft_article_import.rb @@ -35,16 +35,15 @@ 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_path: nil, type: nil, **opts, &blk) + def self.parse(file, custom_file_path: nil, type: nil, &blk) custom_file_path ||= nil type ||= 'bnn' - parser = file_formats[type] if block_given? - parser.parse(file, custom_file_path: custom_file_path, **opts, &blk) + parser.parse(file, custom_file_path: custom_file_path, &blk) else data = [] - parser.parse(file, custom_file_path: custom_file_path, **opts) { |a| data << a } + parser.parse(file, custom_file_path: custom_file_path) { |a| data << a } data end end diff --git a/lib/foodsoft_article_import/bioromeo.rb b/lib/foodsoft_article_import/bioromeo.rb index 135cf1b..054439f 100644 --- a/lib/foodsoft_article_import/bioromeo.rb +++ b/lib/foodsoft_article_import/bioromeo.rb @@ -28,9 +28,9 @@ module FoodsoftArticleImport RES_PARSE_UNIT_LIST.map { |r| /#{r}\s*$/ } + RES_PARSE_UNIT_LIST.map { |r| /-#{r}/ } - def self.parse(file, custom_file_path: nil, **opts) + def self.parse(file, custom_file_path: nil) custom_file_path ||= nil - opts = OPTIONS.merge(opts) + opts = OPTIONS.dup opts[:liberal_parsing] = true opts[:col_sep] = ',' ss = FoodsoftArticleImport.open_spreadsheet(file, **opts) diff --git a/lib/foodsoft_article_import/bnn.rb b/lib/foodsoft_article_import/bnn.rb index 16593fa..06c7b36 100644 --- a/lib/foodsoft_article_import/bnn.rb +++ b/lib/foodsoft_article_import/bnn.rb @@ -71,22 +71,11 @@ module FoodsoftArticleImport # TODO: Complete deposit list.... article.merge!(deposit: translate(:deposit, row[26])) if translate(:deposit, row[26]) - # get scale prices if exists - # article.merge!(:scale_quantity => row[40], :scale_price => row[41]) unless row[40].nil? or row[41].nil? - unless row[37].nil? && row[65].nil? && row[66].nil? - scale_factor = row[66].gsub(',', '.').to_f - price = row[37].gsub(',', '.').to_f - price_per = (scale_factor * price).round(2).to_s.gsub('.', ',') - article.merge!(:price_per => price_per) - article.merge!(:unit_symbol => row[65] ) - end - - if !row[62].nil? # consider special prices article[:note] = "Sonderpreis: #{article[:price]} von #{row[62]} bis #{row[63]}" yield article, :special, i - + # Check now for article status, we only consider outlisted articles right now # N=neu, A=Änderung, X=ausgelistet, R=Restbestand, # V=vorübergehend ausgelistet, W=wiedergelistet diff --git a/lib/foodsoft_article_import/foodsoft.rb b/lib/foodsoft_article_import/foodsoft.rb index 5fd09b4..25ff4ba 100644 --- a/lib/foodsoft_article_import/foodsoft.rb +++ b/lib/foodsoft_article_import/foodsoft.rb @@ -17,9 +17,9 @@ module FoodsoftArticleImport # Parses Foodsoft file # the yielded article is a simple hash - def self.parse(file, custom_file_path: nil, **opts) + def self.parse(file, custom_file_path: nil) custom_file_path ||= nil - opts = OPTIONS.merge(opts) + opts = OPTIONS.dup ss = FoodsoftArticleImport.open_spreadsheet(file, **opts)