From bb62f01b11c76c75a819ddc0dd5324d678c3155f Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Wed, 2 Aug 2023 13:01:46 +0100 Subject: [PATCH] no need to pass loader reference to FileReader --- lib/voicemeeter/configs.rb | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/voicemeeter/configs.rb b/lib/voicemeeter/configs.rb index 35796d2..ca0be73 100644 --- a/lib/voicemeeter/configs.rb +++ b/lib/voicemeeter/configs.rb @@ -51,8 +51,7 @@ module Voicemeeter class FileReader include Logging - def initialize(loader, kind) - @loader = loader + def initialize(kind) @configpaths = [ Pathname.getwd.join("configs", kind.name.to_s), Pathname.new(Dir.home).join(".config", "voicemeeter-rb", kind.name.to_s), @@ -90,13 +89,22 @@ module Voicemeeter @configs = Hash.new do |hash, key| raise Errors::VMError.new "unknown config #{key}. known configs: #{hash.keys}" end - @filereader = FileReader.new(self, kind) + @filereader = FileReader.new(kind) end def to_s "Loader #{@kind}" end + def run + logger.debug "Running #{self}" + configs[:reset] = TOMLStrBuilder.run(@kind) + @filereader.each do |identifier, data| + register(identifier, data) + end + self + end + private def register(identifier, data) if configs.key? identifier logger.debug "config with name '#{identifier}' already in memory, skipping..." @@ -106,15 +114,6 @@ module Voicemeeter configs[identifier] = data logger.info "#{@kind.name}/#{identifier} loaded into memory" end - - def run - logger.debug "Running #{self}" - configs[:reset] = TOMLStrBuilder.run(@kind) - @filereader.each do |identifier, data| - register(identifier, data) - end - self - end end def get(kind_id)