Module: Kotoshu::Paths
- Defined in:
- lib/kotoshu/paths.rb
Overview
Centralized XDG Base Directory paths.
Resolves cache, config, and data paths per the XDG Base Directory Specification. Kotoshu-specific env vars (KOTOSHU_CACHE_PATH etc.) take precedence over the generic XDG_*_HOME vars, which take precedence over the hardcoded defaults.
Default layout:
~/.cache/kotoshu/ downloaded dicts, models, frequency lists
~/.config/kotoshu/ user-edited config, personal dictionary
~/.local/share/kotoshu/ append-only data (audit log)
Class Method Summary collapse
- .audit_log_path ⇒ Object
- .cache_path ⇒ Object
- .config_path ⇒ Object
- .data_path ⇒ Object
- .ensure_exist! ⇒ Object
- .personal_dictionary_path ⇒ Object
Class Method Details
.audit_log_path ⇒ Object
31 32 33 |
# File 'lib/kotoshu/paths.rb', line 31 def audit_log_path ENV.fetch("KOTOSHU_AUDIT_LOG", nil) || File.join(data_path, "audit.log") end |
.cache_path ⇒ Object
19 20 21 |
# File 'lib/kotoshu/paths.rb', line 19 def cache_path ENV.fetch("KOTOSHU_CACHE_PATH", nil) || xdg("CACHE", "cache") end |
.config_path ⇒ Object
23 24 25 |
# File 'lib/kotoshu/paths.rb', line 23 def config_path ENV.fetch("KOTOSHU_CONFIG_PATH", nil) || xdg("CONFIG", "config") end |
.data_path ⇒ Object
27 28 29 |
# File 'lib/kotoshu/paths.rb', line 27 def data_path ENV.fetch("KOTOSHU_DATA_PATH", nil) || xdg("DATA", "local/share") end |
.ensure_exist! ⇒ Object
39 40 41 42 43 |
# File 'lib/kotoshu/paths.rb', line 39 def ensure_exist! FileUtils.mkdir_p(cache_path) FileUtils.mkdir_p(config_path) FileUtils.mkdir_p(data_path) end |
.personal_dictionary_path ⇒ Object
35 36 37 |
# File 'lib/kotoshu/paths.rb', line 35 def personal_dictionary_path ENV.fetch("KOTOSHU_PERSONAL_DIC", nil) || File.join(config_path, "personal.dic") end |