Module: Ego::Filesystem
- Defined in:
- lib/ego/filesystem.rb
Overview
Provides utility methods for getting configuration, data, and cache paths.
Constant Summary collapse
- PLUGIN_GLOB =
Glob pattern for matching plug-in files
'plugins/*.rb'- BASENAME =
XDG subdirectoy name
'ego'- XDG_CACHE_HOME =
Value of
$XDG_CACHE_HOMEor fallback if not set ENV['XDG_CACHE_HOME'] || File.('~/.cache')
- XDG_CONFIG_HOME =
Value of
$XDG_CONFIG_HOMEor fallback if not set ENV['XDG_CONFIG_HOME'] || File.('~/.config')
- XDG_DATA_HOME =
Value of
$XDG_DATA_HOMEor fallback if not set ENV['XDG_DATA_HOME'] || File.('~/.local/share')
Class Method Summary collapse
-
.builtin_plugins ⇒ Array
All built-in plug-in paths.
-
.cache(path = '') ⇒ String
The path to cache directory with
pathappended. -
.config(path = '') ⇒ String
The path to config directory with
pathappended. -
.data(path = '') ⇒ String
The path to data directory with
pathappended. -
.user_plugins ⇒ Array
All user plug-in paths.
Class Method Details
.builtin_plugins ⇒ Array
Returns all built-in plug-in paths.
51 52 53 |
# File 'lib/ego/filesystem.rb', line 51 def builtin_plugins Dir[File.(PLUGIN_GLOB, __dir__)] end |
.cache(path = '') ⇒ String
Returns the path to cache directory with path appended.
26 27 28 |
# File 'lib/ego/filesystem.rb', line 26 def cache(path = '') File.join(XDG_CACHE_HOME, BASENAME, path) end |
.config(path = '') ⇒ String
Returns the path to config directory with path appended.
35 36 37 |
# File 'lib/ego/filesystem.rb', line 35 def config(path = '') File.join(XDG_CONFIG_HOME, BASENAME, path) end |
.data(path = '') ⇒ String
Returns the path to data directory with path appended.
44 45 46 |
# File 'lib/ego/filesystem.rb', line 44 def data(path = '') File.join(XDG_DATA_HOME, BASENAME, path) end |
.user_plugins ⇒ Array
Returns all user plug-in paths.
58 59 60 |
# File 'lib/ego/filesystem.rb', line 58 def user_plugins Dir[File.(PLUGIN_GLOB, config)] end |