struct

Dirs::Project

Inherits Struct / Value / Object

Constructors

new(app_name : String)

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.

Source

Instance methods

cache(*path : String) : Path

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.

Source
config(*path : String) : Path

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.

Source
data(*path : String) : Path

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.

Source
runtime(*path : String) : Path

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).

Source
state(*path : String) : Path

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.

Source