no need to pass loader reference to FileReader

This commit is contained in:
onyx-and-iris 2023-08-02 13:01:46 +01:00
parent fdfadaafac
commit bb62f01b11

View File

@ -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)