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 df510ef183
commit df64ab5ba1
3 changed files with 21 additions and 0 deletions

View File

@ -28,4 +28,6 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "github_api", ">= 0.14"
spec.add_runtime_dependency "rainbow", ">= 2.1"
spec.add_runtime_dependency("octokit", ["~> 4.0"])
spec.add_runtime_dependency("faraday-http-cache")
spec.add_runtime_dependency("activesupport")
end

View File

@ -3,6 +3,9 @@
require "github_api"
require "octokit"
require 'faraday-http-cache'
require "logger"
require "active_support"
require "json"
require "benchmark"

View File

@ -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
#