module ZendeskAppsTools::Cache
Constants
- CACHE_FILE_NAME
Public Instance Methods
cache_path()
click to toggle source
# File lib/zendesk_apps_tools/cache.rb, line 21 def cache_path @cache_path ||= File.join options[:path], CACHE_FILE_NAME end
clear_cache()
click to toggle source
# File lib/zendesk_apps_tools/cache.rb, line 17 def clear_cache File.delete cache_path if options[:clean] && File.exist?(cache_path) end
fetch_cache(key)
click to toggle source
# File lib/zendesk_apps_tools/cache.rb, line 12 def fetch_cache(key) @cache ||= File.exist?(cache_path) ? JSON.parse(File.read(@cache_path)) : {} @cache[key] if @cache end
save_cache(hash)
click to toggle source
# File lib/zendesk_apps_tools/cache.rb, line 5 def save_cache(hash) return if options[:zipfile] @cache = File.exist?(cache_path) ? JSON.parse(File.read(@cache_path)).update(hash) : hash File.open(@cache_path, 'w') { |f| f.write JSON.pretty_generate(@cache) } end