class AudioAddict::Config

Attributes

path[W]

Public Class Methods

default_path() click to toggle source
# File lib/audio_addict/config.rb, line 45
def default_path
  "#{Dir.home}/.audio_addict/config"
end
delete(*keys) click to toggle source
# File lib/audio_addict/config.rb, line 17
def delete(*keys)
  keys.each { |key| properties.delete key.to_sym }
end
has_key?(key) click to toggle source
# File lib/audio_addict/config.rb, line 25
def has_key?(key)
  properties.has_key? key.to_sym
end
method_missing(name, *args, &_blk) click to toggle source
# File lib/audio_addict/config.rb, line 8
def method_missing(name, *args, &_blk)
  if name.to_s.end_with? "="
    name = name[0..-2].to_sym
    properties[name] = args.first
  else
    properties[name]
  end
end
path() click to toggle source
# File lib/audio_addict/config.rb, line 41
def path
  @path ||= ENV.fetch("AUDIO_ADDICT_CONFIG_PATH", default_path)
end
properties() click to toggle source
# File lib/audio_addict/config.rb, line 29
def properties
  @properties ||= properties!
end
properties!() click to toggle source
# File lib/audio_addict/config.rb, line 33
def properties!
  File.exist?(path) ? YAML.load_file(path) : {}
end
save() click to toggle source
# File lib/audio_addict/config.rb, line 21
def save
  File.deep_write path, sorted_properties.to_yaml
end
sorted_properties() click to toggle source
# File lib/audio_addict/config.rb, line 37
def sorted_properties
  properties.sort.to_h
end