geekmail 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/geekmail.gemspec +1 -1
- data/lib/geekmail.rb +25 -23
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/geekmail.gemspec
CHANGED
data/lib/geekmail.rb
CHANGED
@@ -17,32 +17,34 @@ class Geekmail
|
|
17
17
|
|
18
18
|
private
|
19
19
|
def self.check_mail(config)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
tries = 5
|
21
|
+
while (tries > 0) do
|
22
|
+
|
23
|
+
begin
|
24
|
+
# make a connection to imap account
|
25
|
+
imap = Net::IMAP.new(config["host"], config["port"], true)
|
26
|
+
imap.login(config["username"], config["password"])
|
27
|
+
# select inbox as our mailbox to process
|
28
|
+
imap.examine('Inbox')
|
29
|
+
|
30
|
+
number_of_message = 0
|
31
|
+
# count number of emails
|
32
|
+
imap.uid_search(["NOT", "DELETED"]).each do |uid|
|
33
|
+
number_of_message += 1
|
34
|
+
end
|
26
35
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
number_of_message += 1
|
31
|
-
end
|
36
|
+
# Log out
|
37
|
+
imap.logout
|
38
|
+
imap.disconnect
|
32
39
|
|
33
|
-
|
34
|
-
imap.logout
|
35
|
-
imap.disconnect
|
36
|
-
|
37
|
-
number_of_message
|
40
|
+
return number_of_message
|
38
41
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
"Unfortunate error..."
|
42
|
+
# NoResponseError and ByResponseError happen often when imap'ing
|
43
|
+
rescue => e
|
44
|
+
tries -= 1
|
45
|
+
sleep(1)
|
46
|
+
"Failed to get mail count" if (tries == 0)
|
47
|
+
end
|
46
48
|
end
|
47
49
|
end
|
48
50
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geekmail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sebastian Probst Eide
|