Class: AppStore::Emigrant::Cache
- Inherits:
-
Object
- Object
- AppStore::Emigrant::Cache
- Defined in:
- lib/app-store-emigrant/cache.rb
Overview
Cache mechanism
Constant Summary collapse
- LOCATION =
begin path = Pathname.new('~/.ase-cache'). unless path.directory? path.mkpath end path end
Class Method Summary collapse
-
.clear! ⇒ Object
Forcefully clears the cache.
-
.count ⇒ Object
Number of items in the cache.
-
.has?(item) ⇒ Boolean
Whether cache has this item.
-
.path_to(item) ⇒ Object
Path to given item (whether existent or not).
Class Method Details
.clear! ⇒ Object
Forcefully clears the cache
29 30 31 32 33 |
# File 'lib/app-store-emigrant/cache.rb', line 29 def self.clear! LOCATION.children.each do |item| item.delete if item.file? end end |
.count ⇒ Object
Number of items in the cache
36 37 38 |
# File 'lib/app-store-emigrant/cache.rb', line 36 def self.count LOCATION.children.select { |item| item.file? }.length end |
.has?(item) ⇒ Boolean
Whether cache has this item
19 20 21 |
# File 'lib/app-store-emigrant/cache.rb', line 19 def self.has? item LOCATION.join(item).file? end |
.path_to(item) ⇒ Object
Path to given item (whether existent or not)
24 25 26 |
# File 'lib/app-store-emigrant/cache.rb', line 24 def self.path_to item LOCATION.join(item).to_s end |