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
- PLAYLIST_GLOB =
The glob pattern for all user playlists
File.join(PLAYLIST_DIR, "*.yml").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
- USER_COMMAND_GLOB =
The glob pattern for all user commands
File.join(USER_COMMAND_DIR, "*.rb").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
- PLUGIN_EVENTS =
All events currently propagated by Instance#event
%i[ 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).
-
.respond_to_missing?(*_args) ⇒ true
We "respond" to all methods with a default of false, so this is always true.
Class Method Details
.method_missing(method, *args) ⇒ false
Catches all undefined configuration keys and defaults them to false.
101 102 103 104 105 106 107 108 109 |
# File 'lib/muzak/config.rb', line 101 def self.method_missing(method, *args) # this is basically useless, since respond_to_missing? will always be true, # but it gets RuboCop to shut up. if respond_to_missing? method, *args false else super end 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.
120 121 122 |
# File 'lib/muzak/config.rb', line 120 def self.plugin?(pname) respond_to? "plugin_#{pname}" end |
.resolve_command(cmd) ⇒ String
Convert the given command into a method (kebab to camel case).
86 87 88 |
# File 'lib/muzak/config.rb', line 86 def self.resolve_command(cmd) cmd.tr "-", "_" end |
.resolve_method(meth) ⇒ String
Convert the given method into a command (camel to kebab case).
95 96 97 |
# File 'lib/muzak/config.rb', line 95 def self.resolve_method(meth) meth.to_s.tr "_", "-" end |
.respond_to_missing?(*_args) ⇒ true
We "respond" to all methods with a default of false, so this is always true.
113 114 115 |
# File 'lib/muzak/config.rb', line 113 def self.respond_to_missing?(*_args) true end |