Module: FollowMixin
- Defined in:
- lib/twat/follow_mixin.rb
Defined Under Namespace
Classes: PrintNothing
Constant Summary collapse
- POLLING_RESOLUTION =
Readline scan time in hz
20
Instance Method Summary collapse
- #run ⇒ Object
-
#untested ⇒ Object
Shim to bail out if we’re in test.
Instance Method Details
#run ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/twat/follow_mixin.rb', line 10 def run auth! enable_readline! if untested @tweetstack = ::Twat::TweetStack.new @failcount = 0 # Get 5 tweets tweets = retrieve_tweets(:count => 5) while untested do begin last_id = process_followed(tweets) if tweets.any? (config.polling_interval * POLLING_RESOLUTION).times do reader.tick lines = 0 reader.each_line do |i| lines += 1 handle_input(i) end sleep 1.0/POLLING_RESOLUTION if lines == 0 end tweets = retrieve_tweets(:since_id => last_id) @failcount = 0 rescue Interrupt break rescue Twitter::Error::ServiceUnavailable break unless fail_or_bail sleeptime = 60 * (@failcount + 1) reader.puts_above "#{"(__-){".red}: the fail whale has been rolled out, sleeping for #{sleeptime} seconds" reader.wait sleeptime rescue Errno::ECONNRESET, Errno::ETIMEDOUT, SocketError break unless fail_or_bail end end end |
#untested ⇒ Object
Shim to bail out if we’re in test
4 5 6 |
# File 'lib/twat/follow_mixin.rb', line 4 def untested true end |