Dirs::Project
Inherits Struct / Value / Object
Constructors
Dirs for an application.
Respects the XDG Base Directory Specification on UNIX systems, with sensible defaults for other systems, notably macOS and Windows.
Example:
app = Dirs::Project.new("myapp")
app.config("settings.json")
On UNIX systems, this could return Path["~/.config/myapp/settings.json"]
for example.
Instance methods
Path to an application's cache directory, under the user's home directory.
Example:
app = Dirs::Project.new("myapp")
app.cache("cache.db")
# => $HOME/.cache/myapp/cache.db (UNIX)
# => $HOME/Library/Caches/myapp/cache.db (Darwin)
# => %LOCALAPPDATA%\myapp\cache\cache.db (Windows)
See Dirs.cache_home for system specific details.
Path to an application's configuration directory, under the user's home directory.
Example:
app = Dirs::Project.new("myapp")
app.config("settings.json")
# => $HOME/.config/myapp/settings.json (UNIX)
# => $HOME/Library/Preferences/myapp/settings.json (Darwin)
# => %APPDATA%\myapp\config\settings.json (Windows)
See Dirs.config_home for system specific details.
Path to an application's data directory, under the user's home data directory.
Example:
app = Dirs::Project.new("myapp")
app.data("plugins")
# => $HOME/.local/share/myapp/plugins (UNIX)
# => $HOME/Library/Application Support/myapp/plugins (Darwin)
# => %APPDATA%\myapp\data\plugins (Windows)
See Dirs.data_home for system specific details.
Path to an application's runtime directory, under the user's runtime directory.
Example:
app = Dirs::Project.new("myapp")
app.data("ctl.sock")
# => $HOME/.local/share/myapp/ctl.sock (UNIX)
# => $HOME/Library/Application Support/myapp/ctl.sock (Darwin)
# => %APPDATA%\myapp\data\ctl.sock (Windows)
See Dirs.data_home for system specific details.
WARNING: Not portable. The method is undefined on macOS and Windows (no such directory).
Path to an application's state directory, under the user's home state directory.
Example:
app = Dirs::Project.new("myapp")
app.state("history.log")
# => $HOME/.local/state/myapp/history.log (UNIX)
# => $HOME/Library/State/myapp/history.log (Darwin)
# => %LOCALAPPDATA%\myapp\state\history.log (Windows)
See Dirs.state_home for system specific details.