Module: Ego::Filesystem

Defined in:
lib/ego/filesystem.rb

Constant Summary collapse

HANDLER_GLOB =
'handler/*.rb'
BASENAME =
'ego'
XDG_CACHE_HOME =
ENV['XDG_CACHE_HOME'] || File.expand_path('~/.cache')
XDG_CONFIG_HOME =
ENV['XDG_CONFIG_HOME'] || File.expand_path('~/.config')
XDG_DATA_HOME =
ENV['XDG_DATA_HOME'] || File.expand_path('~/.local/share')

Class Method Summary collapse

Class Method Details

.builtin_handlersObject



24
25
26
# File 'lib/ego/filesystem.rb', line 24

def builtin_handlers
  Dir[File.expand_path(HANDLER_GLOB, __dir__)]
end

.cache(path = '') ⇒ Object



12
13
14
# File 'lib/ego/filesystem.rb', line 12

def cache path = ''
  File.join XDG_CACHE_HOME, BASENAME, path
end

.config(path = '') ⇒ Object



16
17
18
# File 'lib/ego/filesystem.rb', line 16

def config path = ''
  File.join XDG_CONFIG_HOME, BASENAME, path
end

.data(path = '') ⇒ Object



20
21
22
# File 'lib/ego/filesystem.rb', line 20

def data path = ''
  File.join XDG_DATA_HOME, BASENAME, path
end

.user_handlersObject



28
29
30
# File 'lib/ego/filesystem.rb', line 28

def user_handlers
  Dir[File.expand_path(HANDLER_GLOB, config)]
end