Sha256: ab71fbd6dfb8f194204b80228243ad63214638457b5b80b569c3d7f6a3b8d525

Contents?: true

Size: 568 Bytes

Versions: 2

Compression:

Stored size: 568 Bytes

Contents

# frozen_string_literal: true

module Runcom
  # A developer friendly wrapper of XDG cache.
  Cache = Struct.new :name, :home, :environment, keyword_init: true do
    extend Forwardable

    delegate %i[inspect] => :cache

    def initialize *arguments
      super

      self[:home] ||= Runcom::Paths::Friendly
      self[:environment] ||= ENV
      @cache = XDG::Cache.new home: home, environment: environment
      freeze
    end

    def path
      paths.find(&:exist?)
    end

    def paths
      cache.all
    end

    private

    attr_reader :cache
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
runcom-5.1.1 lib/runcom/cache.rb
runcom-5.1.0 lib/runcom/cache.rb