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

View File

@ -4,12 +4,21 @@ PATH
github_changelog_generator (1.13.1)
github_api (>= 0.14)
rainbow (>= 2.1)
activesupport
faraday-http-cache
github_api (~> 0.12)
octokit (~> 4.0)
rake (>= 10.0)
GEM
remote: https://rubygems.org/
specs:
activesupport (4.2.6)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.4.0)
ast (2.3.0)
childprocess (0.5.9)
@ -28,17 +37,22 @@ GEM
docile (1.1.5)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
faraday-http-cache (1.3.0)
ffi (1.9.14)
github_api (0.14.5)
faraday (~> 0.8)
addressable (~> 2.4.0)
descendants_tracker (~> 0.0.4)
faraday (~> 0.8, < 0.10)
hashie (>= 3.4)
multi_json (>= 1.7.5, < 2.0)
oauth2 (~> 1.0)
hashie (3.4.6)
i18n (0.7.0)
iniparse (1.4.2)
json (1.8.3)
jwt (1.5.6)
minitest (5.9.0)
multi_json (1.12.1)
multi_xml (0.5.5)
multipart-post (2.0.0)
@ -92,6 +106,8 @@ GEM
thor (0.19.1)
thread_safe (0.3.5)
tins (1.6.0)
tzinfo (1.2.2)
thread_safe (~> 0.1)
unicode-display_width (1.1.1)
PLATFORMS

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
#