record_store 6.0.0 → 6.0.1

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: 6f450801e1929b93095645ce0975dba493e5acc0eb3dd8582fe1e480eeccb285
4
- data.tar.gz: 9e6418b616eccdacf8b164a51627fc2ddb2d9c8eb8e233f67b03862642eeaf4a
3
+ metadata.gz: 9c526e771b65c9da7f83836311bfc8c7b2af502a6801256ccdaa540b54df4138
4
+ data.tar.gz: f5e34d123f4dbef6d2206c4703310af91784deb0d0d2681de05f4aea78b83985
5
5
  SHA512:
6
- metadata.gz: 76bccf5594a613fc29f9052596add31a8622f5b0bbdb3cf32a1a46ee6ff91cd1312fd576b8108d86534397ac253bcc61b7fa630be0d1ffb69d5e179b424a4dad
7
- data.tar.gz: dc01e786afb99b508b1cd8b2fbb612b2a52741a9c9f12146a0b08189cf2d0d3f9366cefc05f4ba4e1fd190e55612445fc80e2484aaa91bd1f5712a51c13864e2
6
+ metadata.gz: d5c507ba11cdefb048f6ceb74f30c1edef6a0f4bd0f0558126f7be02de3b9b38bab5c9d02bf8c8fec9f07ac59207dd24115fac7d0819141029f2691da989ada2
7
+ data.tar.gz: d688116ba3470d5ff1a4ab4d74b8d38d8d274d1180988839679d1d9b8aeb2e813a20b3fbc0634077e9a216b74d28ca1b0e3da125c43240488f5626a9c6fbd265
@@ -1,4 +1,6 @@
1
1
  # CHANGELOG
2
+ ## 6.0.1
3
+ - add API rate limiting to DNSimple provider
2
4
 
3
5
  ## 6.0.0
4
6
  - add `--all` option for `record-store diff` to compare ignored records too [FEATURE]
@@ -1,4 +1,5 @@
1
1
  require 'dnsimple'
2
+ require_relative 'dnsimple/patch_api_header'
2
3
 
3
4
  module RecordStore
4
5
  class Provider::DNSimple < Provider
@@ -0,0 +1,30 @@
1
+ # Patch Dnsimple client method which retrieves headers for API rate limit dynamically
2
+ module Dnsimple
3
+ class Client
4
+ def execute(method, path, data = nil, options = {})
5
+ response = request(method, path, data, options)
6
+ rate_limit_sleep(response.headers["x-ratelimit-reset"].to_i, response.headers["x-ratelimit-remaining"].to_i)
7
+
8
+ case response.code
9
+ when 200..299
10
+ response
11
+ when 401
12
+ raise AuthenticationFailed, response["message"]
13
+ when 404
14
+ raise NotFoundError, response
15
+ else
16
+ raise RequestError, response
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def rate_limit_sleep(rate_limit_reset, rate_limit_remaining)
23
+ rate_limit_reset_in = [0, rate_limit_reset - Time.now.to_i].max
24
+ rate_limit_periods = rate_limit_remaining + 1
25
+ wait_time = rate_limit_reset_in / rate_limit_periods.to_f
26
+
27
+ sleep(wait_time) if wait_time > 0
28
+ end
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module RecordStore
2
- VERSION = '6.0.0'.freeze
2
+ VERSION = '6.0.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: record_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 6.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Willem van Bergen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-04-24 00:00:00.000000000 Z
12
+ date: 2020-05-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -355,6 +355,7 @@ files:
355
355
  - lib/record_store/cli.rb
356
356
  - lib/record_store/provider.rb
357
357
  - lib/record_store/provider/dnsimple.rb
358
+ - lib/record_store/provider/dnsimple/patch_api_header.rb
358
359
  - lib/record_store/provider/dynect.rb
359
360
  - lib/record_store/provider/google_cloud_dns.rb
360
361
  - lib/record_store/provider/ns1.rb