heroics 0.0.25 → 0.1.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
  SHA256:
3
- metadata.gz: e68ba785351a943b6f0074745b8feda4a605e784b041fa5b1bfa6f6508737f94
4
- data.tar.gz: 0215babfbc42434506a8ee778db394b0ed352b54dd7e56536a45ae9df2ab43f1
3
+ metadata.gz: 5647a8b91b25c77f40182266db987cd58c4f189eae45a70a694ba4d21f736d19
4
+ data.tar.gz: 7a723886449d51423484019452f5f22be13bef2874f94d85c90153c7e4b16aa5
5
5
  SHA512:
6
- metadata.gz: 61535d6335adbf12786d56b27fa2b53dfc13b7f835fe7bba7040bcb4b9724391de3d6b0ae0254fff3ad1580b64e44f48dcc47a5f8ef7ac664f20f1260743be26
7
- data.tar.gz: 905ea0ed8f1310471be27d7d50608cd4afdd0f393b82557a000c42c7b73ac002195ccdf4a400042d4a6ad0fa59e2585f30fd16280dbe4dcaabd670b2e0a28eed
6
+ metadata.gz: adfc5e7f5a5159d9264215bcc8496e334535ace0f5b770fb46de19f331a03425423a7c2aee7f21cf990c57aa4a36e724206bd1f280f70e68c0f7d15640930390
7
+ data.tar.gz: 75d171e2daf0bc99a5d1d675661684e15f4d128ccb1cc1f02deabddfc56cef955de82bbd85f366e17dd6f915452cd2df2d8d223830f4de0593d6bf149ba76f27
@@ -0,0 +1,4 @@
1
+ ## 0.1.0
2
+
3
+ - Introduced rate throttling integration point (https://github.com/interagent/heroics/pull/95)
4
+
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.test_files = spec.files.grep('^(test|spec|features)/')
21
21
  spec.require_paths = ['lib']
22
22
 
23
- spec.add_development_dependency 'bundler', '~> 1.3'
23
+ spec.add_development_dependency 'bundler'
24
24
  spec.add_development_dependency 'minitest', '4.7.5'
25
25
  spec.add_development_dependency 'netrc'
26
26
  spec.add_development_dependency 'rake'
@@ -1,6 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Heroics
4
+ module NullRateLimit
5
+ def self.call
6
+ yield
7
+ end
8
+ end
9
+
4
10
  # Attempts to load configuration, provides defaults, and provide helpers to access that data
5
11
  class Configuration
6
12
  attr_reader :base_url,
@@ -22,7 +28,7 @@ module Heroics
22
28
  @options = {}
23
29
  @options[:cache] = 'Moneta.new(:Memory)'
24
30
  @options[:default_headers] = {}
25
-
31
+ @options[:rate_throttle] = NullRateLimit
26
32
  @ruby_name_replacement_patterns = { /[\s-]+/ => '_' }
27
33
 
28
34
  yield self if block_given?
@@ -57,5 +63,9 @@ module Heroics
57
63
  raise "Must provide a hash of replacements" unless patterns.is_a?(Hash)
58
64
  @ruby_name_replacement_patterns = patterns
59
65
  end
66
+
67
+ def rate_throttle=(rate_throttle)
68
+ @options[:rate_throttle] = rate_throttle
69
+ end
60
70
  end
61
71
  end
@@ -18,6 +18,7 @@ module Heroics
18
18
  @link_schema = link_schema
19
19
  @default_headers = options[:default_headers] || {}
20
20
  @cache = options[:cache] || {}
21
+ @rate_throttle = options[:rate_throttle] || Heroics::Configuration.defaults.options[:rate_throttle]
21
22
  end
22
23
 
23
24
  # Make a request to the server.
@@ -108,7 +109,10 @@ module Heroics
108
109
  etag = @cache["etag:#{cache_key}"]
109
110
  options[:headers] = options[:headers].merge({'If-None-Match' => etag}) if etag
110
111
  end
111
- response = connection.request(options)
112
+
113
+ response = @rate_throttle.call do
114
+ connection.request(options)
115
+ end
112
116
 
113
117
  if response.status == 304
114
118
  body = @cache["data:#{cache_key}"]
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Heroics
3
- VERSION = '0.0.25'
3
+ VERSION = '0.1.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.25
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - geemus
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-09-14 00:00:00.000000000 Z
12
+ date: 2019-10-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '1.3'
20
+ version: '0'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '1.3'
27
+ version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: minitest
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -177,6 +177,7 @@ extra_rdoc_files: []
177
177
  files:
178
178
  - ".gitignore"
179
179
  - ".travis.yml"
180
+ - CHANGELOG.md
180
181
  - CONTRIBUTING.md
181
182
  - CONTRIBUTORS.md
182
183
  - Gemfile
@@ -220,8 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
221
  - !ruby/object:Gem::Version
221
222
  version: '0'
222
223
  requirements: []
223
- rubyforge_project:
224
- rubygems_version: 2.7.6
224
+ rubygems_version: 3.0.3
225
225
  signing_key:
226
226
  specification_version: 4
227
227
  summary: A Ruby client generator for HTTP APIs described with a JSON schema