Sha256: 4060cac8d272366a9a2dd254167bccd8ad0e4a439d38cec3bfb58428092828b7

Contents?: true

Size: 753 Bytes

Versions: 2

Compression:

Stored size: 753 Bytes

Contents

require 'pathname'

module AppStore; end

module AppStore::Emigrant

  # Cache mechanism
  class Cache

    LOCATION = begin
      path = Pathname.new('~/.ase-cache').expand_path
      unless path.directory?
        path.mkpath
      end
      path
    end

    # Whether cache has this item
    def self.has? item
      LOCATION.join(item).file?
    end

    # Path to given item (whether existent or not)
    def self.path_to item
      LOCATION.join(item).to_s
    end

    # Forcefully clears the cache
    def self.clear!
      LOCATION.children.each do |item|
        item.delete if item.file?
      end
    end

    # Number of items in the cache
    def self.count
      LOCATION.children.select { |item| item.file? }.length
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
app-store-emigrant-0.0.9 lib/app-store-emigrant/cache.rb
app-store-emigrant-0.0.8 lib/app-store-emigrant/cache.rb