mirror of
https://github.com/onyx-and-iris/voicemeeter-rb.git
synced 2024-11-22 01:40:49 +00:00
check configpath only if configpath exists
override Loader to_s
This commit is contained in:
parent
01314e2e98
commit
ca66af7d84
@ -16,12 +16,16 @@ module Voicemeeter
|
||||
def initialize(kind)
|
||||
@kind = kind
|
||||
@configs = Hash.new
|
||||
logger.debug("generated loader for #{kind}")
|
||||
end
|
||||
|
||||
def to_s
|
||||
"Loader #{@kind}"
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def build_reset_profile(overrides = {})
|
||||
#stree-ignore
|
||||
def build_reset_profile
|
||||
aouts = (0...@kind.phys_out).to_h { |i| ["A#{i + 1}", false] }
|
||||
bouts = (0...@kind.virt_out).to_h { |i| ["B#{i + 1}", false] }
|
||||
strip_bools = %w[mute mono solo].to_h { |param| [param, false] }
|
||||
@ -38,15 +42,7 @@ module Voicemeeter
|
||||
(0...@kind.phys_in).to_h do |i|
|
||||
[
|
||||
"strip-#{i}",
|
||||
{
|
||||
**aouts,
|
||||
**bouts,
|
||||
**strip_bools,
|
||||
**gain,
|
||||
**phys_float,
|
||||
**eq,
|
||||
**overrides
|
||||
}
|
||||
{**aouts,**bouts,**strip_bools,**gain,**phys_float,**eq,**overrides}
|
||||
]
|
||||
end
|
||||
|
||||
@ -69,25 +65,25 @@ module Voicemeeter
|
||||
end
|
||||
|
||||
def read_from_yml
|
||||
#stree-ignore
|
||||
filepaths = [
|
||||
Pathname.getwd.join("configs", @kind.name.to_s),
|
||||
Pathname.new(Dir.home).join(
|
||||
".config",
|
||||
"voicemeeter-rb",
|
||||
@kind.name.to_s
|
||||
),
|
||||
Pathname.new(Dir.home).join(
|
||||
"Documents",
|
||||
"Voicemeeter",
|
||||
"configs",
|
||||
@kind.name.to_s
|
||||
)
|
||||
Pathname.new(Dir.home).join(".config", "voicemeeter-rb", @kind.name.to_s),
|
||||
Pathname.new(Dir.home).join("Documents", "Voicemeeter", "configs", @kind.name.to_s)
|
||||
]
|
||||
filepaths.each do |pn|
|
||||
configs = pn.glob("*.yml")
|
||||
configs.each do |config|
|
||||
filename = config.basename.sub_ext ""
|
||||
@configs[filename.to_s.to_sym] = YAML.load_file(config)
|
||||
if pn.exist?
|
||||
logger.debug "checking #{pn} for configs"
|
||||
configs = pn.glob("*.yml")
|
||||
configs.each do |config|
|
||||
filename = (config.basename.sub_ext "").to_s.to_sym
|
||||
if @configs.key? filename
|
||||
logger.debug "config with name '#{filename}' already in memory, skipping..."
|
||||
next
|
||||
end
|
||||
@configs[filename] = YAML.load_file(config)
|
||||
logger.info "#{@kind.name}/#{filename} loaded into memory"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -95,6 +91,7 @@ module Voicemeeter
|
||||
public
|
||||
|
||||
def build
|
||||
logger.debug "Running #{self}"
|
||||
@configs[:reset] = build_reset_profile
|
||||
read_from_yml
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user