first pass at caching. still WIP. Need to parameterize some things
This commit is contained in:
parent
df510ef183
commit
df64ab5ba1
|
@ -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
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
require "github_api"
|
||||
require "octokit"
|
||||
require 'faraday-http-cache'
|
||||
require "logger"
|
||||
require "active_support"
|
||||
require "json"
|
||||
require "benchmark"
|
||||
|
||||
|
|
|
@ -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
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue
Block a user