tinybucket 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c36e731063e026b4a9765820e9c2af76d614b37
4
- data.tar.gz: 6c751c8bde9a75fd7bb43b82e25f9f291c711e5f
3
+ metadata.gz: 65f9c7b6e4cffe83881f78a6c23c787e1f054402
4
+ data.tar.gz: 2596b76496b6a201d0dbdf9fc22d434b8d2f29b7
5
5
  SHA512:
6
- metadata.gz: 932cbe0ffb529644bd277f0efe6d9e8fba47b37069aa3eb9ed8cf9c1b744717ebde8f6ed844e4c1ce55a5154829216365b137afffc52a30781ba02f9c3edb20c
7
- data.tar.gz: 3145f50edc5ca01591945a5055ad14059afab8be2909f1d16213f23ea7dc35357d477d68b8c1fa7bb0e99ffff7f5ca26aa1a37e3be45a72b9c58a61723d78127
6
+ metadata.gz: f9133bcb3b6c335495c0b00d678d5bf845a45c58ce476dc6e5e45953f7a9201a565c90e832f0681eafebd75c47bf12fc0c91cad8cf94f5f497404293ccba805c
7
+ data.tar.gz: cd947d13332ee1ebeafad0f07238e0103905c614ba77fc39f623fcc433701fdd138a35fb08d7bdad941167c7b48f21b7aa463c8658773c004128d759747ac9a7
data/.travis.yml CHANGED
@@ -2,7 +2,7 @@ sudo: false
2
2
  language: ruby
3
3
  before_install:
4
4
  - gem install bundler -v 1.10.6
5
- rvm: 2.1.2
5
+ rvm: 2.2
6
6
  addons:
7
7
  code_climate:
8
8
  repo_token: 58717000233e2eba64f18993364e4689b9c3e862a3e775d14890cd235979a7f9
data/README.md CHANGED
@@ -42,10 +42,19 @@ logger = Logger.new($stdout)
42
42
  logger.level = Logger::WARN
43
43
 
44
44
  Tinybucket.configure do |config|
45
- # set your logger if you want.
45
+ # Configure logger if you want.
46
+ #
47
+ # optional, default: nil (no logging)
46
48
  config.logger = logger
47
49
 
48
- # configure oauth_token/oauth_secret
50
+ # Configure cache_store options if you need.
51
+ #
52
+ # see https://github.com/plataformatec/faraday-http-cache
53
+ #
54
+ # optional, default: nil (disable request cache)
55
+ config.cache_store_options = { store: Rails.cache, logger: logger }
56
+
57
+ # Configure oauth_token/oauth_secret
49
58
  config.oauth_token = 'key'
50
59
  config.oauth_secret = 'secret'
51
60
  end
data/lib/tinybucket.rb CHANGED
@@ -10,6 +10,7 @@ require 'faraday'
10
10
  require 'faraday_middleware'
11
11
  require 'faraday_middleware/response_middleware'
12
12
  require 'faraday_middleware/follow_oauth_redirects'
13
+ require 'faraday-http-cache'
13
14
 
14
15
  require 'active_model'
15
16
 
@@ -1,6 +1,6 @@
1
1
  module Tinybucket
2
2
  class Config
3
3
  include ActiveSupport::Configurable
4
- config_accessor :logger, :oauth_token, :oauth_secret
4
+ config_accessor :logger, :oauth_token, :oauth_secret, :cache_store_options
5
5
  end
6
6
  end
@@ -36,6 +36,8 @@ module Tinybucket
36
36
  consumer_secret: Tinybucket.config.oauth_secret
37
37
  }
38
38
 
39
+ configure_response_cache(conn)
40
+
39
41
  conn.request :multipart
40
42
  conn.request :url_encoded
41
43
  conn.request :oauth, oauth_secrets
@@ -49,6 +51,12 @@ module Tinybucket
49
51
  end
50
52
  end
51
53
 
54
+ def configure_response_cache(conn)
55
+ return unless Tinybucket.config.cache_store_options
56
+
57
+ conn.use :http_cache, Tinybucket.config.cache_store_options
58
+ end
59
+
52
60
  def stack(parser, options = {}, &block)
53
61
  Faraday::RackBuilder.new(&block) and return if block_given?
54
62
 
@@ -1,3 +1,3 @@
1
1
  module Tinybucket
2
- VERSION = '1.1.0'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
@@ -17,6 +17,7 @@ RSpec.describe Tinybucket do
17
17
  let(:logger) { Logger.new($stdout) }
18
18
  let(:oauth_token) { 'test_oauth_token' }
19
19
  let(:oauth_secret) { 'test_oauth_secret' }
20
+ let(:cache_store_options) { { logger: Tinybucket.logger } }
20
21
 
21
22
  it 'is configurable' do
22
23
  expect(config.logger).to be_nil
@@ -24,12 +25,14 @@ RSpec.describe Tinybucket do
24
25
  expect do
25
26
  Tinybucket.configure do |config|
26
27
  config.logger = logger
28
+ config.cache_store_options = cache_store_options
27
29
  config.oauth_token = oauth_token
28
30
  config.oauth_secret = oauth_secret
29
31
  end
30
32
  end.not_to raise_error
31
33
 
32
34
  expect(config.logger).to eq(logger)
35
+ expect(config.cache_store_options).to eq(cache_store_options)
33
36
  expect(config.oauth_token).to eq(oauth_token)
34
37
  expect(config.oauth_secret).to eq(oauth_secret)
35
38
  end
data/tinybucket.gemspec CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_runtime_dependency 'activesupport', ['>= 4.1.6']
23
23
  spec.add_runtime_dependency 'faraday', ['= 0.9.0']
24
24
  spec.add_runtime_dependency 'faraday_middleware', ['= 0.9.1']
25
+ spec.add_runtime_dependency 'faraday-http-cache', ['~> 1.2']
25
26
  spec.add_runtime_dependency 'simple_oauth', ['= 0.2.0']
26
27
 
27
28
  spec.add_development_dependency 'bundler', '~> 1.10'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tinybucket
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - hirakiuc
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.9.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: faraday-http-cache
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.2'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.2'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: simple_oauth
71
85
  requirement: !ruby/object:Gem::Requirement