funky 0.2.17 → 0.2.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/funky/connections/api.rb +23 -5
- 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: f79e490243da7655f0de7e622a6888db059af5a3
|
4
|
+
data.tar.gz: ac848b830fe8ddc6e1acb4dfe195157f366f25c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb7519f9f86c6b71a9feb16824fb89030a5c06be77167c5b8c9ddb1ab7e6ad25ba2364c54d883f034728c76c9a8e3d8ba385cb7e0a234000826c75379ceb9751
|
7
|
+
data.tar.gz: 3f5d7a338a2b22631d088fff7b50d86bdcca35a4b7b810b6e8ed76c8f292daa76a813a634d6243211e03c79a784fdfe24c522692a7477f263defb3a4f55165da
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ 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.18 - 2017/04/19
|
10
|
+
|
11
|
+
* [ENHANCEMENT] `Funky::Page#videos` now fetches more videos by time-based pagination.
|
12
|
+
|
9
13
|
## 0.2.17 - 2017/04/17
|
10
14
|
|
11
15
|
* [FEATURE] Add `Funky::Page.find` class method to find a page by its page ID.
|
@@ -7,16 +7,34 @@ module Funky
|
|
7
7
|
class API < Base
|
8
8
|
def self.fetch(path_query, is_array: false)
|
9
9
|
uri = URI "https://#{host}/v2.8/#{path_query}&limit=100&access_token=#{app_id}%7C#{app_secret}"
|
10
|
-
is_array ? fetch_multiple_pages(uri) : json_for(uri)
|
10
|
+
is_array ? fetch_multiple_pages(uri).uniq : json_for(uri)
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.fetch_multiple_pages(uri)
|
14
14
|
json = json_for(uri)
|
15
|
-
if json[:
|
16
|
-
|
17
|
-
|
15
|
+
if json[:data].empty?
|
16
|
+
@try_count ||= 0
|
17
|
+
if @previous_timestamp && @try_count < 1 && (Date.parse @previous_timestamp rescue nil)
|
18
|
+
timestamp = (Date.parse(@previous_timestamp) - 1).strftime('%F')
|
19
|
+
@try_count += 1
|
20
|
+
@previous_timestamp = timestamp
|
21
|
+
new_query = URI.decode_www_form(uri.query).to_h.merge('until' => timestamp)
|
22
|
+
uri.query = URI.encode_www_form(new_query)
|
23
|
+
json[:data] + fetch_multiple_pages(uri)
|
24
|
+
else
|
25
|
+
[]
|
26
|
+
end
|
18
27
|
else
|
19
|
-
json[:data]
|
28
|
+
timestamp = if json[:data].count == 1
|
29
|
+
Date.parse(json[:data][-1][:created_time]).strftime('%F')
|
30
|
+
else
|
31
|
+
Time.parse(json[:data][-1][:created_time]).to_i
|
32
|
+
end
|
33
|
+
@try_count = 0
|
34
|
+
@previous_timestamp = timestamp
|
35
|
+
new_query = URI.decode_www_form(uri.query).to_h.merge('until' => timestamp)
|
36
|
+
uri.query = URI.encode_www_form(new_query)
|
37
|
+
json[:data] + fetch_multiple_pages(uri)
|
20
38
|
end
|
21
39
|
end
|
22
40
|
|
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.18
|
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-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|