Module: CachingOctokit
- Included in:
- Backend
- Defined in:
- lib/gitarro/backend.rb
Overview
by default enabled (faraday_cache in memory, will be deleted after gitarro run 2nd time. usefull for -C check option and performance, since we cache)
Instance Method Summary collapse
- #create_dir_store(cache_path) ⇒ Object
-
#dont_generate_cache? ⇒ Boolean
if true we dont need the cache.
- #generate_cache(httpcache_path) ⇒ Object
Instance Method Details
#create_dir_store(cache_path) ⇒ Object
80 81 82 83 84 |
# File 'lib/gitarro/backend.rb', line 80 def create_dir_store(cache_path) cache_name = 'httpcache' full_cache_dir = "#{cache_path}#{cache_name}" ActiveSupport::Cache::FileStore.new(full_cache_dir) end |
#dont_generate_cache? ⇒ Boolean
if true we dont need the cache
101 102 103 104 105 106 107 |
# File 'lib/gitarro/backend.rb', line 101 def dont_generate_cache? return false unless @changed_since > 0 puts '###############################' puts 'NO HTTP Faraday Cache generated!' puts '###############################' true end |
#generate_cache(httpcache_path) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/gitarro/backend.rb', line 86 def generate_cache(httpcache_path) # changed_since cannot work with cache return false if dont_generate_cache? stack = Faraday::RackBuilder.new do |builder| builder.use Faraday::HttpCache, store: create_dir_store(httpcache_path), serializer: Marshal, shared_cache: false builder.use Octokit::Response::RaiseError builder.adapter Faraday.default_adapter end Octokit.middleware = stack end |