da_face 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/da_face.rb +6 -1
- data/lib/da_face/api/adapters/base.rb +3 -0
- data/lib/da_face/api/adapters/excon_adapter.rb +21 -7
- data/lib/da_face/api/rate_limit_info.rb +13 -0
- data/lib/da_face/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 868b1428a056a9be26cea60cb95d55b9ed0810b7
|
4
|
+
data.tar.gz: 9fcc13e2e0724b38977f32abd7e11d76959dc05b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2172ad20e3370a2a205d08dfdb93e4c8784e7234dee42a81be55bd9e0c3e51fe668ee97e1f87e61115bef01bd361adf9757def0252a789f20ee06a5adfd2f977
|
7
|
+
data.tar.gz: fc860afe4305c39b942f15b71ffbf7a987bcfe553910a46813f9a9856cf7123551cf0e26f97152a54bf9b17686a0ad2182f2fa1dc53cc1204f41ee88b480eb68
|
data/Gemfile.lock
CHANGED
data/lib/da_face.rb
CHANGED
@@ -7,6 +7,7 @@ require "da_face/api/adapter"
|
|
7
7
|
require "da_face/api/adapters/base"
|
8
8
|
require "da_face/api/adapters/excon_adapter"
|
9
9
|
require "da_face/api/adapters/em_http_request_adapter"
|
10
|
+
require "da_face/api/rate_limit_info"
|
10
11
|
require "da_face/api/push"
|
11
12
|
require "da_face/api/push_log"
|
12
13
|
require "da_face/api/push_log_entry"
|
@@ -34,12 +35,16 @@ require "yajl"
|
|
34
35
|
|
35
36
|
module DaFace
|
36
37
|
class << self
|
37
|
-
attr_accessor :configuration
|
38
|
+
attr_accessor :configuration, :rate_limit_status
|
38
39
|
|
39
40
|
def configuration
|
40
41
|
@configuration ||= Configuration.new
|
41
42
|
end
|
42
43
|
|
44
|
+
def rate_limit_status
|
45
|
+
@rate_limit_status ||= DaFace::Api::RateLimitStatus.new
|
46
|
+
end
|
47
|
+
|
43
48
|
def configure
|
44
49
|
yield(configuration)
|
45
50
|
self.configuration
|
@@ -52,6 +52,9 @@ module DaFace
|
|
52
52
|
'?' + URI.encode(params.collect{ |key, value| "#{key}=#{value}"}.join('&')) unless params.empty?
|
53
53
|
end
|
54
54
|
|
55
|
+
def set_rate_limit_status rate_limit, remaining
|
56
|
+
DaFace.rate_limit_status = DaFace::Api::RateLimitStatus.new(:limit => rate_limit, :remaining => remaining)
|
57
|
+
end
|
55
58
|
|
56
59
|
end
|
57
60
|
end
|
@@ -8,25 +8,39 @@ module DaFace
|
|
8
8
|
|
9
9
|
def get path, params={}
|
10
10
|
response = connection.get :path => "#{path}#{url_params(params)}", :headers => get_headers
|
11
|
-
|
11
|
+
handle_response(response)
|
12
12
|
end
|
13
13
|
|
14
14
|
def post path, payload
|
15
15
|
response = connection.post :path => path, :body => encode_form(payload), :headers => post_headers
|
16
|
-
|
17
|
-
return parse_body(response.body)
|
16
|
+
handle_response(response)
|
18
17
|
end
|
19
18
|
|
20
19
|
def put path, payload
|
21
20
|
response = connection.put :path => "#{path}", :body => encode_form(payload), :headers => post_headers
|
22
|
-
|
23
|
-
return parse_body(response.body)
|
21
|
+
handle_response(response)
|
24
22
|
end
|
25
23
|
|
26
24
|
def parse_body body
|
27
|
-
|
25
|
+
if body.empty?
|
26
|
+
{}
|
27
|
+
else
|
28
|
+
JSON.parse(body)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def handle_response response
|
33
|
+
rate_limit_info = extract_rate_limit_info(response)
|
34
|
+
set_rate_limit_status(rate_limit_info[:limit], rate_limit_info[:remaining])
|
35
|
+
return parse_body(response.body)
|
36
|
+
end
|
37
|
+
|
38
|
+
def extract_rate_limit_info response
|
39
|
+
{
|
40
|
+
:limit => response.headers['x-ratelimit-limit'],
|
41
|
+
:remaining => response.headers['x-ratelimit-remaining']
|
42
|
+
}
|
28
43
|
end
|
29
|
-
|
30
44
|
end
|
31
45
|
end
|
32
46
|
end
|
data/lib/da_face/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: da_face
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rayko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- lib/da_face/api/push_log.rb
|
135
135
|
- lib/da_face/api/push_log_entry.rb
|
136
136
|
- lib/da_face/api/push_subscription.rb
|
137
|
+
- lib/da_face/api/rate_limit_info.rb
|
137
138
|
- lib/da_face/configuration.rb
|
138
139
|
- lib/da_face/datasift/da_object.rb
|
139
140
|
- lib/da_face/datasift/demographic.rb
|