fb-support 1.0.0.alpha4 → 1.0.0.alpha5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +5 -0
- data/README.md +10 -0
- data/lib/fb/http_request.rb +15 -0
- data/lib/fb/support/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 90a4cb148ef3c1b148eac8953b611cd63f3034999cb5a1e33795e85085c0c91b
|
4
|
+
data.tar.gz: 71d38e58297da8b68cae44554f381025eba344d187c0db5f5908c8ee07a2d2b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8e9af893c25d8476c2a0cc40a14c0740692055f4275a6c3f7f72bb97f857af3fe5abe800808084498260c0c050d4c0f5f950e63113c56b0e14e0043db251578
|
7
|
+
data.tar.gz: 0e5e1c572d0d07548406c52f225b404f39d450948d4987635b2d587e4770911a1def7d43abe072c27e04413b379f9b546762135217dbd6244ad9a5f35ae060b9
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,11 @@ For more information about changelogs, check
|
|
6
6
|
[Keep a Changelog](http://keepachangelog.com) and
|
7
7
|
[Vandamme](http://tech-angels.github.io/vandamme).
|
8
8
|
|
9
|
+
|
10
|
+
## 1.0.0.alpha5 - 2018-08-23
|
11
|
+
|
12
|
+
* [FEATURE] Wait when usage status is approaching limit.
|
13
|
+
|
9
14
|
## 1.0.0 - 2017-03-17
|
10
15
|
|
11
16
|
* [FEATURE] Added Fb::Configuration and Fb.configure
|
data/README.md
CHANGED
@@ -20,6 +20,16 @@ Fb::Support provides:
|
|
20
20
|
* [Fb::HTTPRequest](http://www.rubydoc.info/gems/fb-support/Fb/HTTPRequest)
|
21
21
|
* [Fb::HTTPError](http://www.rubydoc.info/gems/fb-support/Fb/HTTPError)
|
22
22
|
|
23
|
+
## Waiting Time
|
24
|
+
|
25
|
+
Facebook has [hourly rate limiting](https://developers.facebook.com/docs/graph-api/advanced/rate-limiting/#application-level-rate-limiting). `Fb::HTTPRequest` has `waiting_time` class variable
|
26
|
+
to sleep the amount of time (in seconds) when it is approaching (with 85% of usage)
|
27
|
+
in case the variable is set as follows.
|
28
|
+
|
29
|
+
```rb
|
30
|
+
Fb::HTTPRequest.waiting_time = 360
|
31
|
+
```
|
32
|
+
|
23
33
|
How to test
|
24
34
|
===========
|
25
35
|
|
data/lib/fb/http_request.rb
CHANGED
@@ -34,11 +34,21 @@ module Fb
|
|
34
34
|
@params = options.fetch :params, {}
|
35
35
|
end
|
36
36
|
|
37
|
+
class << self
|
38
|
+
# @return [Integer] time in seconds for waiting when hourly rate limit
|
39
|
+
# for the Facebook app reached over 85%
|
40
|
+
attr_accessor :waiting_time
|
41
|
+
end
|
42
|
+
|
37
43
|
# Sends the request and returns the response with the body parsed from JSON.
|
38
44
|
# @return [Net::HTTPResponse] if the request succeeds.
|
39
45
|
# @raise [Fb::HTTPError] if the request fails.
|
40
46
|
def run
|
41
47
|
if response.is_a? @expected_response
|
48
|
+
if (waiting_time = self.class.waiting_time) &&
|
49
|
+
rate_limiting_header.values.any? {|value| value > 85 }
|
50
|
+
sleep waiting_time
|
51
|
+
end
|
42
52
|
response.tap do
|
43
53
|
parse_response!
|
44
54
|
end
|
@@ -52,6 +62,11 @@ module Fb
|
|
52
62
|
uri.to_s
|
53
63
|
end
|
54
64
|
|
65
|
+
# @return [Hash] rate limit status in the response header.
|
66
|
+
def rate_limiting_header
|
67
|
+
JSON response.to_hash['x-app-usage'][0]
|
68
|
+
end
|
69
|
+
|
55
70
|
private
|
56
71
|
|
57
72
|
# @return [URI::HTTPS] the (memoized) URI of the request.
|
data/lib/fb/support/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fb-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.alpha5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claudio Baccigalupo
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-08-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
142
|
version: 1.3.1
|
143
143
|
requirements: []
|
144
144
|
rubyforge_project:
|
145
|
-
rubygems_version: 2.6
|
145
|
+
rubygems_version: 2.7.6
|
146
146
|
signing_key:
|
147
147
|
specification_version: 4
|
148
148
|
summary: Support utilities for Fb gems
|