Class: Muzak::Config
- Inherits:
-
Object
- Object
- Muzak::Config
- Defined in:
- lib/muzak/config.rb
Overview
Muzak's static configuration dumping ground. Key-value pairs are loaded from CONFIG_FILE and translated from kebab-case to snake_case methods.
Constant Summary collapse
- CONFIG_DIR =
The root directory for all user configuration, data, etc
File.("~/.config/muzak").freeze
- CONFIG_FILE =
Muzak's primary configuration file
File.join(CONFIG_DIR, "muzak.yml").freeze
- INDEX_FILE =
Muzak's music index
File.join(CONFIG_DIR, "index.dat").freeze
- PLAYLIST_DIR =
The directory for all user playlists
File.join(CONFIG_DIR, "playlists").freeze
- USER_PLUGIN_DIR =
The directory for all user plugins
File.join(CONFIG_DIR, "plugins").freeze
- USER_COMMAND_DIR =
The directory for all user commands
File.join(CONFIG_DIR, "commands").freeze
- MUSIC_SUFFIXES =
All filename suffixes that muzak recognizes as music.
[ ".mp3", ".flac", ".m4a", ".wav", ".ogg", ".oga", ".opus", ].freeze
- ALBUM_ART_REGEX =
The regular expression that muzak uses to find album art.
/(cover)|(folder).(jpg)|(png)/i.freeze
- PLUGIN_EVENTS =
All events currently propagated by Instance#event
[ :instance_started, :instance_quitting, :player_activated, :player_deactivated, :song_loaded, :song_unloaded, :playlist_enqueued, ].freeze
- DEFAULT_CONFIG =
The default configuration keys and values.
{ # core defaults "events" => true, "debug" => false, "verbose" => true, "music" => File.("~/music"), "player" => "mpv", "jukebox-size" => 100, "autoplay" => false, # client/daemon defaults "daemon-port" => 2669, "daemon-host" => "localhost", }.freeze
Class Method Summary collapse
-
.method_missing(method, *args) ⇒ false
Catches all undefined configuration keys and defaults them to false.
-
.plugin?(pname) ⇒ Boolean
Whether or not the given plugin is configured.
-
.resolve_command(cmd) ⇒ String
Convert the given command into a method (kebab to camel case).
-
.resolve_method(meth) ⇒ String
Convert the given method into a command (camel to kebab case).
Class Method Details
.method_missing(method, *args) ⇒ false
Catches all undefined configuration keys and defaults them to false.
93 94 95 |
# File 'lib/muzak/config.rb', line 93 def self.method_missing(method, *args) false end |
.plugin?(pname) ⇒ Boolean
the truth-value of this method is used in part to determine which plugins should be loaded.
Returns whether or not the given plugin is configured.
100 101 102 |
# File 'lib/muzak/config.rb', line 100 def self.plugin?(pname) respond_to? "plugin_#{pname}" end |
.resolve_command(cmd) ⇒ String
Convert the given command into a method (kebab to camel case).
78 79 80 |
# File 'lib/muzak/config.rb', line 78 def self.resolve_command(cmd) cmd.tr "-", "_" end |
.resolve_method(meth) ⇒ String
Convert the given method into a command (camel to kebab case).
87 88 89 |
# File 'lib/muzak/config.rb', line 87 def self.resolve_method(meth) meth.to_s.tr "_", "-" end |