twords 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/twords.rb +9 -1
- data/lib/twords/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff2afbb65117a20ea8ae1fae8889372a292fbe50
|
4
|
+
data.tar.gz: 1315cb7fe01bb2d995337929df84934b3c22e167
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b26b32f09d1b70c235da6c0fd8af11660b25412d39489e84022caed28d5ec64033e5f78adf9ffb617182d52322161fc7fab54e873366346c8a04af3544481b9
|
7
|
+
data.tar.gz: 5d4161ecb3543542b1622817e9079e373d5a0222db3c12f35afbef2332876887a4ad86c858856b606d7f9450ac4cba333c8f1a9972cb0d215e4ca0126427830d
|
data/lib/twords.rb
CHANGED
@@ -143,17 +143,21 @@ class Twords
|
|
143
143
|
def fetch_older_tweets(timeline, screen_name)
|
144
144
|
return timeline if age_of_tweet_in_days(timeline.last) > range
|
145
145
|
@requests += 1
|
146
|
+
first_count = timeline.count
|
146
147
|
timeline += client.user_timeline(
|
147
148
|
screen_name,
|
148
149
|
tweet_mode: 'extended',
|
149
150
|
max_id: timeline.last.id - 1,
|
150
151
|
count: 200
|
151
152
|
)
|
153
|
+
second_count = timeline.count
|
154
|
+
return timeline if second_count == first_count
|
152
155
|
fetch_older_tweets(timeline, screen_name)
|
153
156
|
end
|
154
157
|
|
155
158
|
def tweets
|
156
159
|
@_tweets ||= timeline.each_with_object([]) do |tweet, memo|
|
160
|
+
next if tweet.created_at > up_to_time
|
157
161
|
memo << tweet if age_of_tweet_in_days(tweet) <= range
|
158
162
|
end
|
159
163
|
end
|
@@ -167,7 +171,11 @@ class Twords
|
|
167
171
|
end
|
168
172
|
|
169
173
|
def age_of_tweet_in_days(tweet)
|
170
|
-
(
|
174
|
+
(up_to_time - tweet.created_at) / 86_400
|
175
|
+
end
|
176
|
+
|
177
|
+
def up_to_time
|
178
|
+
self.class.up_to_block.call.to_time
|
171
179
|
end
|
172
180
|
|
173
181
|
def count_words
|
data/lib/twords/version.rb
CHANGED