Sha256: 952fc2d1256e891313a5b78c87bed8a0c24ab7ac712d21abdc4b677549398ddc

Contents?: true

Size: 701 Bytes

Versions: 2

Compression:

Stored size: 701 Bytes

Contents

module Ego::Filesystem
  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')

  module_function

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

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

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ego-0.2.0 lib/ego/filesystem.rb
ego-0.1.0 lib/ego/filesystem.rb