yatc 0.0.2 → 0.0.3
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 +4 -4
- data/lib/yatc.rb +8 -3
- 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: fdde419625a0f9898f99ad2f1d0f9be5426ad0ac
|
4
|
+
data.tar.gz: 17b81c837d586085388cdf83a3a97a6efef58c52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c715c88addf673087eb41951e642d4586f3c152c20256473686c9394b5f368efd6b30e580f904d4094b98180237386e9f57b76d73ed6cebe23ec633764dba12a
|
7
|
+
data.tar.gz: b689adc5683c4e60b1ac3c215b797973185c5cbcac42bfc5a62251f159d69cc277a828d79f2ac53b18d3514f7aaf4060bfc4fec2f33182e66b3b4e5356bc65cc
|
data/lib/yatc.rb
CHANGED
@@ -13,6 +13,7 @@ class TwitterClient
|
|
13
13
|
attr_accessor :consumer_secret
|
14
14
|
attr_accessor :should_wait
|
15
15
|
attr_accessor :access_token
|
16
|
+
attr_accessor :force_retrieval
|
16
17
|
|
17
18
|
def test_access(ck, cs)
|
18
19
|
!request_access_token(ck, cs).empty?
|
@@ -27,6 +28,7 @@ class TwitterClient
|
|
27
28
|
end
|
28
29
|
ids = []
|
29
30
|
cursor = nil
|
31
|
+
force_retrieval = true
|
30
32
|
while count > 0
|
31
33
|
params[:count] = [Yatc::Settings::MAX_FOLLOWER_IDS, count].min
|
32
34
|
count -= params[:count]
|
@@ -39,7 +41,9 @@ class TwitterClient
|
|
39
41
|
data = JSON.parse(execute(:get, url, access_token))
|
40
42
|
ids += data['ids']
|
41
43
|
cursor = data['next_cursor']
|
44
|
+
break if cursor == 0
|
42
45
|
end
|
46
|
+
force_retrieval = false
|
43
47
|
ids
|
44
48
|
end
|
45
49
|
|
@@ -111,6 +115,7 @@ class TwitterClient
|
|
111
115
|
@consumer_secret = cs
|
112
116
|
@access_token = request_access_token(consumer_key, consumer_secret)
|
113
117
|
@should_wait = wait
|
118
|
+
@force_retrieval = false
|
114
119
|
end
|
115
120
|
|
116
121
|
def bearer_token(ck, cs)
|
@@ -158,10 +163,10 @@ class TwitterClient
|
|
158
163
|
}
|
159
164
|
)
|
160
165
|
rescue RestClient::TooManyRequests => e
|
161
|
-
|
162
|
-
if should_wait &&
|
166
|
+
limit_reset = e.response.headers[:x_rate_limit_reset]
|
167
|
+
if should_wait && limit_reset && (tries == 0 || force_retrieval)
|
163
168
|
tries += 1
|
164
|
-
delta = (Time.at(
|
169
|
+
delta = (Time.at(limit_reset.to_i) - Time.now).to_i
|
165
170
|
sleep(delta + 1)
|
166
171
|
retry
|
167
172
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yatc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Rendón Pablo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Twitter client.
|
14
14
|
email: rafaelrendonpablo@gmail.com
|