Module: Charty::CacheDir

Defined in:
lib/charty/cache_dir.rb

Class Method Summary collapse

Class Method Details

.cache_dir_pathObject



7
8
9
# File 'lib/charty/cache_dir.rb', line 7

def cache_dir_path
  platform_cache_dir_path + "charty"
end

.path(*path_components) ⇒ Object



23
24
25
# File 'lib/charty/cache_dir.rb', line 23

def path(*path_components)
  cache_dir_path.join(*path_components)
end

.platform_cache_dir_pathObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/charty/cache_dir.rb', line 11

def platform_cache_dir_path
  base_dir = case RUBY_PLATFORM
             when /mswin/, /mingw/
               ENV.fetch("LOCALAPPDATA", "~/AppData/Local")
             when /darwin/
               "~/Library/Caches"
             else
               ENV.fetch("XDG_CACHE_HOME", "~/.cache")
             end
  Pathname(base_dir).expand_path
end