first pass at caching. still WIP. Need to parameterize some things

This commit is contained in:
Andrew Waage
2016-05-18 15:40:25 -07:00
committed by Olle Jonsson
parent 3cf2802d9a
commit 4ecb21c0b0
4 changed files with 37 additions and 0 deletions
@@ -27,10 +27,26 @@ module GitHubChangelogGenerator
@github_options[:access_token] = @github_token unless @github_token.nil?
@github_options[:api_endpoint] = @options[:github_endpoint] unless @options[:github_endpoint].nil?
init_middleware
client_type = @options[:github_endpoint].nil? ? Octokit::Client : Octokit::EnterpriseAdminClient
@client = client_type.new(@github_options)
end
def init_middleware
middleware_opts = {
:serializer => Marshal,
:store => ActiveSupport::Cache::FileStore.new('/tmp/cache'),
:logger => Logger.new('/tmp/github-changelog-logger.log'),
:shared_cache => false
}
stack = Faraday::RackBuilder.new do |builder|
builder.use Faraday::HttpCache, middleware_opts
builder.use Octokit::Response::RaiseError
builder.adapter Faraday.default_adapter
# builder.response :logger
end
Octokit.middleware = stack
end
# Fetch all tags from repo
#