Skip to content
This repository was archived by the owner on Nov 8, 2018. It is now read-only.

Commit 6e910a3

Browse files
committed
use caching for HTTP requests
1 parent 0a8fac1 commit 6e910a3

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN apk add --update openssh-client
88
RUN apk add --update perl
99
RUN apk add --update ruby
1010
RUN apk add --update ruby-json
11-
RUN gem install octokit httpclient --no-rdoc --no-ri
11+
RUN gem install octokit httpclient faraday-http-cache --no-rdoc --no-ri
1212

1313
ADD assets/ /opt/resource/
1414
RUN chmod +x /opt/resource/*

Dockerfile.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN apk add --update openssh-client
88
RUN apk add --update perl
99
RUN apk add --update ruby
1010
RUN apk add --update ruby-json
11-
RUN gem install octokit httpclient --no-rdoc --no-ri
11+
RUN gem install octokit httpclient faraday-http-cache --no-rdoc --no-ri
1212

1313
ADD assets/ /opt/resource/
1414
RUN chmod +x /opt/resource/*

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ source 'https://rubygems.org'
22

33
gem 'octokit'
44
gem 'httpclient'
5+
gem 'faraday-http-cache'
56

67
group :development do
78
gem 'pry'

Gemfile.lock

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ GEM
2323
eventmachine_httpserver (0.2.1)
2424
faraday (0.9.2)
2525
multipart-post (>= 1.2, < 3)
26+
faraday-http-cache (2.0.0)
27+
faraday (~> 0.8)
2628
hashdiff (0.3.0)
2729
http_parser.rb (0.6.0)
2830
httpclient (2.8.2.4)
@@ -85,6 +87,7 @@ PLATFORMS
8587
ruby
8688

8789
DEPENDENCIES
90+
faraday-http-cache
8891
httpclient
8992
octokit
9093
pry
@@ -95,4 +98,4 @@ DEPENDENCIES
9598
webmock
9699

97100
BUNDLED WITH
98-
1.13.6
101+
1.14.6

assets/lib/commands/base.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
require 'faraday'
2-
# httpclient and excon are the only Faraday adpater which support
3-
# the no_proxy environment variable atm
4-
# NOTE: this has to be set before require octokit
5-
::Faraday.default_adapter = :httpclient
6-
72
require 'octokit'
3+
require 'faraday-http-cache'
4+
5+
stack = Faraday::RackBuilder.new do |builder|
6+
builder.use Faraday::HttpCache, serializer: Marshal, shared_cache: false
7+
builder.use Octokit::Response::RaiseError
8+
# httpclient and excon are the only Faraday adpater which support
9+
# the no_proxy environment variable atm
10+
builder.adapter :httpclient
11+
end
12+
Octokit.middleware = stack
13+
814
require_relative '../input'
915

1016
module Commands

0 commit comments

Comments
 (0)