Class: Slk::Support::XdgPaths
- Inherits:
-
Object
- Object
- Slk::Support::XdgPaths
- 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
- #cache_dir ⇒ Object
- #cache_file(filename) ⇒ Object
- #config_dir ⇒ Object
- #config_file(filename) ⇒ Object
- #ensure_cache_dir ⇒ Object
- #ensure_config_dir ⇒ Object
Instance Method Details
#cache_dir ⇒ Object
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_dir ⇒ Object
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_dir ⇒ Object
51 52 53 |
# File 'lib/slk/support/xdg_paths.rb', line 51 def ensure_cache_dir FileUtils.mkdir_p(cache_dir) end |
#ensure_config_dir ⇒ Object
47 48 49 |
# File 'lib/slk/support/xdg_paths.rb', line 47 def ensure_config_dir FileUtils.mkdir_p(config_dir) end |