funky 0.2.18 → 0.2.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +3 -3
- data/lib/funky/connections/api.rb +3 -1
- data/lib/funky/connections/base.rb +19 -8
- data/lib/funky/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0cc82139ba77645ca8723e3aa7ca8ffd5fdb4e0
|
4
|
+
data.tar.gz: 2dbead2613813de4aea2dd1ef1f067fd07482298
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72c3b1d0fe5ca08a8eb6e4c0406ec715b8973f0e2fd9d3f7496fff1f01a8c63df5eb5e46cd8de3b969f113394612d9fc9abf7fd0bf5682c11d37809ec777c8d8
|
7
|
+
data.tar.gz: 2e889e3efb8e57161daa8a6e384628b62d18bd44cf9b2ac7b5290115d01a7a543bff9a1e3f79f4a39f40081b70a219bdae511769127d859e4f777fedd0fc044d
|
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
|
+
## 0.2.19 - 2017/04/20
|
10
|
+
|
11
|
+
* [IMPROVEMENT] Retry 3 times after a server error or a socket error, to fetch
|
12
|
+
data even with any temporary issue from Facebook.
|
13
|
+
|
9
14
|
## 0.2.18 - 2017/04/19
|
10
15
|
|
11
16
|
* [ENHANCEMENT] `Funky::Page#videos` now fetches more videos by time-based pagination.
|
data/README.md
CHANGED
@@ -47,12 +47,12 @@ There are two ways to configure Funky with your App ID and App Secret:
|
|
47
47
|
end
|
48
48
|
```
|
49
49
|
|
50
|
-
##API Overview
|
50
|
+
## API Overview
|
51
51
|
|
52
52
|
Funky consists of 2 different surface APIs - one to fetch video data
|
53
53
|
from Facebook and one to fetch page data from Facebook.
|
54
54
|
|
55
|
-
##Pages API
|
55
|
+
## Pages API
|
56
56
|
|
57
57
|
### Use #where clause to get an array of videos
|
58
58
|
|
@@ -65,7 +65,7 @@ pages.first.username # => 'SonyPicturesGlobal'
|
|
65
65
|
|
66
66
|
```
|
67
67
|
|
68
|
-
##Videos API
|
68
|
+
## Videos API
|
69
69
|
|
70
70
|
### Use #where clause to get an array of videos
|
71
71
|
|
@@ -9,23 +9,34 @@ module Funky
|
|
9
9
|
Net::HTTP::Get.new(uri.request_uri)
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.response_for(http_request, uri)
|
12
|
+
def self.response_for(http_request, uri, max_retries = 3)
|
13
13
|
response = Net::HTTP.start(uri.host, 443, use_ssl: true) do |http|
|
14
14
|
http.request http_request
|
15
15
|
end
|
16
|
-
response
|
16
|
+
if response.is_a? Net::HTTPSuccess
|
17
|
+
response
|
18
|
+
elsif response.is_a? Net::HTTPServerError
|
19
|
+
sleep_and_retry_response_for(http_request, uri, max_retries, response.body)
|
20
|
+
else
|
21
|
+
raise ContentNotFound, "Error #{response.code}: #{response.body}"
|
22
|
+
end
|
17
23
|
rescue SocketError => e
|
18
|
-
|
24
|
+
sleep_and_retry_response_for(http_request, uri, max_retries, e.message)
|
19
25
|
end
|
20
26
|
|
21
|
-
def self.
|
22
|
-
|
23
|
-
|
24
|
-
|
27
|
+
def self.sleep_and_retry_response_for(http_request, uri, retries, message)
|
28
|
+
if retries > 0
|
29
|
+
sleep (4 - retries) ** 2
|
30
|
+
response_for http_request, uri, retries - 1
|
25
31
|
else
|
26
|
-
raise
|
32
|
+
raise ConnectionError, message
|
27
33
|
end
|
28
34
|
end
|
35
|
+
|
36
|
+
def self.json_for(uri, max_retries = 3)
|
37
|
+
response = response_for(get_http_request(uri), uri)
|
38
|
+
JSON.parse(response.body, symbolize_names: true)
|
39
|
+
end
|
29
40
|
end
|
30
41
|
end
|
31
42
|
end
|
data/lib/funky/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: funky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philip Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|