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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b077596e43b2ac75f4ec36c1d5939128e8eca13e
4
- data.tar.gz: 2fe6f5794eee5ef28fda1f8c90ba5a1a56140e97
3
+ metadata.gz: ff2afbb65117a20ea8ae1fae8889372a292fbe50
4
+ data.tar.gz: 1315cb7fe01bb2d995337929df84934b3c22e167
5
5
  SHA512:
6
- metadata.gz: faaaf5de4811ed3ce6fe1bd6ab34e690587d60e37960830b5a180ee6677bfe3f5c5bc37a88a36702ebf97e0e14610fdb0765d26b46c8351319910db3c2c9d949
7
- data.tar.gz: cbe6d61a5459cbeef51e2d7073385f5a4e3c4e44098f24ad35584c1431a98837dc5b26887c528873f8d1af8bf56f9b0c27e830d9403e2123781985a946f4386a
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
- (self.class.up_to_block.call.to_time - tweet.created_at) / 86_400
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Twords
4
- VERSION = '0.1.7'.freeze
4
+ VERSION = '0.1.8'.freeze
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twords
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - M. Simon Borg