desk 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +1 -3
- data/desk.gemspec +1 -1
- data/lib/desk/error.rb +7 -13
- data/lib/desk/version.rb +1 -1
- data/lib/faraday/response/raise_http_4xx.rb +1 -1
- data/spec/faraday/response_spec.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
SHA512:
|
3
|
-
data.tar.gz: f5707b5b210f15d2441f5601fc18344b89046e2d6b79aef3f86dc0b8aba22fe0eb7e2e1de36b867dd72c6b4b84549e3097de6067f8cf9c25fa34ae4878b15963
|
4
|
-
metadata.gz: 9ec58c7e7f4a6b0ea44dd9ae678a81777923e3e0a64ca75a088959088247c54552eb18427c1a8f42777ca9020d215d587d95953a7de167d46c5df1eb2305f684
|
5
2
|
SHA1:
|
6
|
-
data.tar.gz:
|
7
|
-
metadata.gz:
|
3
|
+
data.tar.gz: 431843df69ff391f0895bef451f4342a657b0613
|
4
|
+
metadata.gz: f975d744573fdd39377aeb18ed2b66d5d0e425d4
|
5
|
+
SHA512:
|
6
|
+
data.tar.gz: fb0efe6acca7471194aa91072690210addc1b79d2838127010b687568624344eeb8c5e39124727114f5751eeb777f67b56998fde3b81db0fc74b3f7286491cbe
|
7
|
+
metadata.gz: 43e7560e18b054ef3eb2216af88f4c3409de90304a4f81da39cb9674baf6b7b992f5a3e12e621c487acfab4da3e57235937cbd83c4b4efdbd6072d7de2c20c48
|
data/Gemfile
CHANGED
data/desk.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.add_development_dependency('yard', '~> 0.6')
|
14
14
|
s.add_runtime_dependency('json', '~> 1.7') if RUBY_VERSION < '1.9'
|
15
15
|
s.add_runtime_dependency('hashie', '~> 1.2.0')
|
16
|
-
s.add_runtime_dependency('faraday', '~> 0.
|
16
|
+
s.add_runtime_dependency('faraday', '~> 0.9.0')
|
17
17
|
s.add_runtime_dependency('faraday_middleware', '~> 0.9.0')
|
18
18
|
s.add_runtime_dependency('jruby-openssl', '~> 0.7.2') if RUBY_PLATFORM == 'java'
|
19
19
|
s.add_runtime_dependency('multi_json', '~> 1.6')
|
data/lib/desk/error.rb
CHANGED
@@ -10,19 +10,19 @@ module Desk
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def ratelimit_reset
|
13
|
-
|
13
|
+
@http_headers.values_at('x-rate-limit-reset', 'X-Rate-Limit-Reset').detect {|value| value }.to_i
|
14
14
|
end
|
15
15
|
|
16
16
|
def ratelimit_limit
|
17
|
-
@http_headers.values_at('x-
|
17
|
+
@http_headers.values_at('x-rate-limit-limit', 'X-Rate-Limit-Limit').detect {|value| value }.to_i
|
18
18
|
end
|
19
19
|
|
20
20
|
def ratelimit_remaining
|
21
|
-
@http_headers.values_at('x-
|
21
|
+
@http_headers.values_at('x-rate-limit-remaining', 'X-Rate-Limit-Remaining').detect {|value| value }.to_i
|
22
22
|
end
|
23
23
|
|
24
24
|
def retry_after
|
25
|
-
|
25
|
+
ratelimit_reset
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -41,15 +41,9 @@ module Desk
|
|
41
41
|
# Raised when Desk returns the HTTP status code 406
|
42
42
|
class NotAcceptable < Error; end
|
43
43
|
|
44
|
-
# Raised when Desk returns the HTTP status code
|
45
|
-
|
46
|
-
|
47
|
-
#
|
48
|
-
# @see http://dev.desk.com/pages/rate-limiting
|
49
|
-
def retry_after
|
50
|
-
@http_headers.values_at('retry-after', 'Retry-After').detect {|value| value }.to_i
|
51
|
-
end
|
52
|
-
end
|
44
|
+
# Raised when Desk returns the HTTP status code 429
|
45
|
+
# Called EnhanceYourCalm because TooManyRequests is taken (see below)
|
46
|
+
class EnhanceYourCalm < Error; end
|
53
47
|
|
54
48
|
# Raised when Desk max_requests is reached and use_max_requests is set to true
|
55
49
|
class TooManyRequests < StandardError; end
|
data/lib/desk/version.rb
CHANGED
@@ -16,7 +16,7 @@ module Faraday
|
|
16
16
|
raise Desk::NotFound.new(error_message(env), env[:response_headers])
|
17
17
|
when 406
|
18
18
|
raise Desk::NotAcceptable.new(error_message(env), env[:response_headers])
|
19
|
-
when
|
19
|
+
when 429
|
20
20
|
raise Desk::EnhanceYourCalm.new(error_message(env), env[:response_headers])
|
21
21
|
end
|
22
22
|
end
|
@@ -11,7 +11,7 @@ describe Faraday::Response do
|
|
11
11
|
403 => Desk::Forbidden,
|
12
12
|
404 => Desk::NotFound,
|
13
13
|
406 => Desk::NotAcceptable,
|
14
|
-
|
14
|
+
429 => Desk::EnhanceYourCalm,
|
15
15
|
500 => Desk::InternalServerError,
|
16
16
|
502 => Desk::BadGateway,
|
17
17
|
503 => Desk::ServiceUnavailable,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: desk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Warren
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-05-06 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -118,7 +118,7 @@ dependencies:
|
|
118
118
|
requirements:
|
119
119
|
- - ~>
|
120
120
|
- !ruby/object:Gem::Version
|
121
|
-
version: 0.
|
121
|
+
version: 0.9.0
|
122
122
|
type: :runtime
|
123
123
|
version_requirements: *id011
|
124
124
|
- !ruby/object:Gem::Dependency
|