catfriend 0.13 → 0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/catfriend +19 -3
- data/lib/catfriend/imap.rb +16 -7
- metadata +5 -5
data/bin/catfriend
CHANGED
@@ -97,10 +97,14 @@ end
|
|
97
97
|
# unrecoverable error. Perhaps I should make it exit if any thread exits.
|
98
98
|
def self.main args
|
99
99
|
work_accounts = false
|
100
|
+
foreground = false
|
100
101
|
Catfriend.verbose = false
|
101
102
|
begin
|
102
103
|
OptionParser.new do |opts|
|
103
104
|
opts.banner = "usage: #{APP_NAME} [options]"
|
105
|
+
opts.on("-f", "--foreground", "run in foreground") do
|
106
|
+
foreground = true
|
107
|
+
end
|
104
108
|
|
105
109
|
opts.on("-w", "--work", "enable work accounts") do
|
106
110
|
work_accounts = true
|
@@ -110,13 +114,20 @@ def self.main args
|
|
110
114
|
end
|
111
115
|
end.parse!
|
112
116
|
|
117
|
+
Catfriend.verbose = false unless foreground
|
118
|
+
|
113
119
|
servers = parse_config
|
114
120
|
servers.reject! { |s| s.work_account } unless work_accounts
|
115
121
|
raise ConfigError, "no servers to check" if servers.empty?
|
116
122
|
|
117
|
-
|
118
|
-
|
119
|
-
|
123
|
+
if foreground
|
124
|
+
start_servers servers
|
125
|
+
else
|
126
|
+
pid = fork do
|
127
|
+
start_servers servers
|
128
|
+
end
|
129
|
+
Process.detach pid
|
130
|
+
end
|
120
131
|
rescue ConfigError => e
|
121
132
|
puts "misconfiguration: #{e.message}"
|
122
133
|
rescue Interrupt
|
@@ -130,6 +141,11 @@ def self.main args
|
|
130
141
|
1
|
131
142
|
end
|
132
143
|
|
144
|
+
def self.start_servers servers
|
145
|
+
servers.each { |s| s.start }
|
146
|
+
servers.each { |s| s.join }
|
147
|
+
end
|
148
|
+
|
133
149
|
end ########################### end module
|
134
150
|
|
135
151
|
exit Catfriend.main ARGV
|
data/lib/catfriend/imap.rb
CHANGED
@@ -62,7 +62,7 @@ class ImapServer
|
|
62
62
|
else
|
63
63
|
loop {
|
64
64
|
check_loop
|
65
|
-
break if
|
65
|
+
break if stopping?
|
66
66
|
}
|
67
67
|
end
|
68
68
|
end
|
@@ -93,11 +93,11 @@ class ImapServer
|
|
93
93
|
Catfriend.whisper "idle loop over"
|
94
94
|
rescue Net::IMAP::Error, IOError
|
95
95
|
# reconnect and carry on
|
96
|
-
reconnect unless
|
96
|
+
reconnect unless stopping?
|
97
97
|
rescue => e
|
98
|
-
unless
|
98
|
+
unless stopping?
|
99
99
|
# todo: see if we have to re-open socket
|
100
|
-
notify_message "error
|
100
|
+
notify_message "#{@message_count} [error: #{e.message}]"
|
101
101
|
puts e.backtrace.join "\n"
|
102
102
|
end
|
103
103
|
end
|
@@ -107,7 +107,12 @@ class ImapServer
|
|
107
107
|
Catfriend.whisper @notification.summary
|
108
108
|
end
|
109
109
|
|
110
|
+
def stopping?
|
111
|
+
stopped? or @stopping
|
112
|
+
end
|
113
|
+
|
110
114
|
def kill
|
115
|
+
@stopping = true
|
111
116
|
disconnect
|
112
117
|
super
|
113
118
|
end
|
@@ -129,10 +134,14 @@ class ImapServer
|
|
129
134
|
end
|
130
135
|
|
131
136
|
def reconnect
|
132
|
-
#
|
133
|
-
Catfriend.whisper "#{id}: reconnecting"
|
137
|
+
notify_message "#{@message_count} [reconnecting]"
|
134
138
|
new_count = connect
|
135
|
-
|
139
|
+
if new_count != @message_count
|
140
|
+
notify_message new_count
|
141
|
+
else
|
142
|
+
# todo: only if it was still open
|
143
|
+
@notification.close
|
144
|
+
end
|
136
145
|
@message_count = new_count
|
137
146
|
end
|
138
147
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: catfriend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.14'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,19 +9,19 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: libnotify
|
16
|
-
requirement: &
|
16
|
+
requirement: &14748540 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 0.7.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *14748540
|
25
25
|
description: E-mail checker with libnotify desktop notifications.
|
26
26
|
email:
|
27
27
|
- catfriend@chilon.net
|