Sha256: 413122fca067906be9b09ccc08638187641a85858ecbd5e5b271831daf2ac530

Contents?: true

Size: 540 Bytes

Versions: 4

Compression:

Stored size: 540 Bytes

Contents

module Datasets
  class CachePath
    def initialize(id)
      @id = id
    end

    def base_dir
      Pathname(system_cache_dir).expand_path + 'red-datasets' + @id
    end

    def remove
      FileUtils.rmtree(base_dir.to_s, secure: true) if base_dir.exist?
    end

    private

    def system_cache_dir
      case RUBY_PLATFORM
      when /mswin/, /mingw/
        ENV['LOCALAPPDATA'] || '~/AppData/Local'
      when /darwin/
        '~/Library/Caches'
      else
        ENV['XDG_CACHE_HOME'] || '~/.cache'
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
red-datasets-0.1.8 lib/datasets/cache-path.rb
red-datasets-0.1.7 lib/datasets/cache-path.rb
red-datasets-0.1.6 lib/datasets/cache-path.rb
red-datasets-0.1.5 lib/datasets/cache-path.rb