Class: Slk::Support::XdgPaths

Inherits:
Object
  • Object
show all
Defined in:
lib/slk/support/xdg_paths.rb

Overview

Cross-platform paths for config and cache directories. Uses XDG Base Directory spec on Unix, APPDATA/LOCALAPPDATA on Windows.

Constant Summary collapse

WINDOWS =
Gem.win_platform?

Instance Method Summary collapse

Instance Method Details

#cache_dirObject



14
15
16
# File 'lib/slk/support/xdg_paths.rb', line 14

def cache_dir
  @cache_dir ||= normalize_path(File.join(default_cache_base, 'slk'))
end

#cache_file(filename) ⇒ Object



43
44
45
# File 'lib/slk/support/xdg_paths.rb', line 43

def cache_file(filename)
  File.join(cache_dir, filename)
end

#config_dirObject



10
11
12
# File 'lib/slk/support/xdg_paths.rb', line 10

def config_dir
  @config_dir ||= normalize_path(File.join(default_config_base, 'slk'))
end

#config_file(filename) ⇒ Object



39
40
41
# File 'lib/slk/support/xdg_paths.rb', line 39

def config_file(filename)
  File.join(config_dir, filename)
end

#ensure_cache_dirObject



51
52
53
# File 'lib/slk/support/xdg_paths.rb', line 51

def ensure_cache_dir
  FileUtils.mkdir_p(cache_dir)
end

#ensure_config_dirObject



47
48
49
# File 'lib/slk/support/xdg_paths.rb', line 47

def ensure_config_dir
  FileUtils.mkdir_p(config_dir)
end