Created
December 12, 2011 23:14
-
-
Save sxua/1469599 to your computer and use it in GitHub Desktop.
Doesn't work after few (4-5) loops
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' unless defined?(Gem) | |
require 'forever' | |
require 'gmail' | |
USER_NAME = '********@gmail.com' | |
PASSWORD = '********' | |
Forever.run do | |
before :all do | |
@gmail = Gmail.new(USER_NAME, PASSWORD) | |
end | |
every 10.seconds, :at => "#{Time.now.hour}:#{Time.now.min}:#{Time.now.sec + 5}" do | |
unread = @gmail.inbox.count(:unread) | |
puts unread.inspect | |
unless unread.zero? | |
@gmail.inbox.emails(:unread).each do |email| | |
email.mark(:read) | |
puts email.subject | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Because
:at
will not be updated. Why you need it?