bridge_api 0.1.46 → 0.1.47

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
  SHA256:
3
- metadata.gz: 8b44a0b256fd219e4500817cdbd13fa4845d8de5b2bfbb9932da73ce1d0ad2e5
4
- data.tar.gz: 230aeb36234a6217a1b0c287db7f893de9a522e02d5ca326fa3a99e48ede163b
3
+ metadata.gz: 33d53dbe69e83c140ece152e38d4b640a952dbe71157d3349d2ec992c00a3cdf
4
+ data.tar.gz: ce0087b8b507566f1620be38adac6e9dcdc48ac4bf24319616771b381cf0b02d
5
5
  SHA512:
6
- metadata.gz: eac5a3221b794a9bc416195e0b1d917380945d59134db19789b80206746030df6bf8e8987ec8b69a50c7310bd8336610e0ca465deed5db81cf65c725f872c142
7
- data.tar.gz: 1d82b404080ae51fdcf22e1ef6eddd05d9c1bd21cde4fe0cd3b93997061514729178106cba5df30f117b8a89da7e251b7f26d1eb22d7b8f15937e894e0e2e43e
6
+ metadata.gz: abf0c52442afe33ed5708c7c70a09e04277c5838244cbf3c5696842f86cdb54716d1740d38c6b4d7cd53cb069531075ab9a79fd03a7ac7088b7c7aa31a05fa24
7
+ data.tar.gz: 2f1a010419bad863287b118a899484c689b901099a891b1ac40b57a55ec010585b81a6b4f1a5d7aaa6237d2ebc3342662555454daed43b960f71124121fc7979
@@ -1,11 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bridge_api (0.1.46)
4
+ bridge_api (0.1.47)
5
5
  faraday (~> 0.9.0)
6
6
  faraday_middleware (>= 0.12.2)
7
7
  footrest (>= 0.5.1)
8
8
  logging (>= 2.2.2)
9
+ paul_walker (>= 0.1.1)
9
10
 
10
11
  GEM
11
12
  remote: https://rubygems.org/
@@ -19,7 +20,7 @@ GEM
19
20
  public_suffix (>= 2.0.2, < 4.0)
20
21
  byebug (8.2.5)
21
22
  coderay (1.1.2)
22
- concurrent-ruby (1.0.5)
23
+ concurrent-ruby (1.1.1)
23
24
  crack (0.4.3)
24
25
  safe_yaml (~> 1.0.0)
25
26
  diff-lcs (1.3)
@@ -43,6 +44,8 @@ GEM
43
44
  minitest (5.11.3)
44
45
  multi_json (1.13.1)
45
46
  multipart-post (2.0.0)
47
+ paul_walker (0.1.1)
48
+ redis (>= 4.0)
46
49
  pry (0.11.3)
47
50
  coderay (~> 1.1.0)
48
51
  method_source (~> 0.9.0)
@@ -51,6 +54,7 @@ GEM
51
54
  rack-protection (1.5.5)
52
55
  rack
53
56
  rake (0.9.6)
57
+ redis (4.0.3)
54
58
  rspec (2.99.0)
55
59
  rspec-core (~> 2.99.0)
56
60
  rspec-expectations (~> 2.99.0)
@@ -31,4 +31,5 @@ Gem::Specification.new do |gem|
31
31
  gem.add_dependency 'faraday_middleware', '>= 0.12.2'
32
32
  gem.add_dependency 'footrest', '>= 0.5.1'
33
33
  gem.add_dependency 'logging', '>= 2.2.2'
34
+ gem.add_dependency 'paul_walker', '>= 0.1.1'
34
35
  end
@@ -6,6 +6,7 @@ require 'footrest/pagination'
6
6
  require 'footrest/follow_redirects'
7
7
  require 'footrest/parse_json'
8
8
  require 'base64'
9
+ require 'paul_walker'
9
10
 
10
11
  module BridgeAPI
11
12
  class Client < Footrest::Client
@@ -57,6 +58,7 @@ module BridgeAPI
57
58
  def enforce_rate_limits
58
59
  return unless BridgeAPI.enforce_rate_limits && !current_limit.nil?
59
60
  return unless current_limit < BridgeAPI::rate_limit_min
61
+ BridgeAPI.logger.debug("Current LIMIT: #{current_limit}")
60
62
  tts = ((BridgeAPI.rate_limit_min - current_limit) / 5).ceil
61
63
  tts = BridgeAPI.min_sleep_seconds if tts < BridgeAPI.min_sleep_seconds
62
64
  tts = BridgeAPI.max_sleep_seconds if tts > BridgeAPI.max_sleep_seconds
@@ -74,11 +76,20 @@ module BridgeAPI
74
76
  end
75
77
 
76
78
  def current_limit
77
- BridgeAPI.rate_limits[config[:api_key]]
79
+ if config[:master_rate_limit]
80
+ limit = PaulWalker::RateLimit.get(config[:api_key], config[:api_key])
81
+ limit['current']
82
+ else
83
+ BridgeAPI.rate_limits[config[:api_key]]
84
+ end
78
85
  end
79
86
 
80
87
  def current_limit=(value)
81
- BridgeAPI.rate_limits[config[:api_key]] = value
88
+ if config[:master_rate_limit]
89
+ PaulWalker::RateLimit.add(config[:api_key], config[:api_key], value, BridgeAPI::rate_limit_min)
90
+ else
91
+ BridgeAPI.rate_limits[config[:api_key]] = value
92
+ end
82
93
  end
83
94
 
84
95
  def set_connection(config)
@@ -1,3 +1,3 @@
1
1
  module BridgeAPI
2
- VERSION = '0.1.46'.freeze unless defined?(BridgeAPI::VERSION)
2
+ VERSION = '0.1.47'.freeze unless defined?(BridgeAPI::VERSION)
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridge_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.46
4
+ version: 0.1.47
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Shaffer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-23 00:00:00.000000000 Z
11
+ date: 2018-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -190,6 +190,20 @@ dependencies:
190
190
  - - ">="
191
191
  - !ruby/object:Gem::Version
192
192
  version: 2.2.2
193
+ - !ruby/object:Gem::Dependency
194
+ name: paul_walker
195
+ requirement: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ version: 0.1.1
200
+ type: :runtime
201
+ prerelease: false
202
+ version_requirements: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - ">="
205
+ - !ruby/object:Gem::Version
206
+ version: 0.1.1
193
207
  description: Ruby gem for interacting with the bridge API
194
208
  email:
195
209
  - jshaffer@instructure.com