imap_processor 1.2 → 1.3

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.tar.gz.sig CHANGED
Binary file
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ === 1.3 / 2009-08-04
2
+
3
+ * 1 major enhancement
4
+ * IMAP IDLE support now matches ruby trunk's support. See Net::IMAP#idle
5
+ and Net::IMAP#idle_done
6
+
1
7
  === 1.2 / 2009-06-02
2
8
 
3
9
  * 2 major enhancements
@@ -3,6 +3,7 @@ require 'optparse'
3
3
  require 'net/imap'
4
4
  require 'net/imap/date'
5
5
  require 'imap_sasl_plain'
6
+ require 'yaml'
6
7
 
7
8
  ##
8
9
  # IMAPProcessor is a client for processing messages on an IMAP server.
@@ -20,7 +21,7 @@ class IMAPProcessor
20
21
  ##
21
22
  # The version of IMAPProcessor you are using
22
23
 
23
- VERSION = '1.2'
24
+ VERSION = '1.3'
24
25
 
25
26
  ##
26
27
  # Base IMAPProcessor error class
@@ -131,7 +132,7 @@ class IMAPProcessor
131
132
  options.merge! YAML.load_file(opts_file)
132
133
  end
133
134
 
134
- options[:SSL] ||= true
135
+ options[:SSL] = true unless options.key? :SSL
135
136
  options[:Username] ||= ENV['USER']
136
137
  options[:Root] ||= nil
137
138
  options[:Verbose] ||= false
@@ -266,7 +267,7 @@ Example ~/.#{opts_file_name}:
266
267
  options[:Password].nil? or
267
268
  options[:Boxes].nil? or
268
269
  required_options.any? { |k,(v,m)| options[k].nil? } then
269
- $stderr.puts opts
270
+ $stderr.puts op
270
271
  $stderr.puts
271
272
  $stderr.puts "Host name not set" if options[:Host].nil?
272
273
  $stderr.puts "Password not set" if options[:Password].nil?
@@ -287,6 +288,8 @@ Example ~/.#{opts_file_name}:
287
288
  options = process_args args
288
289
  client = new(options, &block)
289
290
  client.run
291
+ rescue Interrupt
292
+ exit
290
293
  rescue SystemExit
291
294
  raise
292
295
  rescue Exception => e
@@ -295,7 +298,7 @@ Example ~/.#{opts_file_name}:
295
298
 
296
299
  exit 1
297
300
  ensure
298
- client.imap.logout if client
301
+ client.imap.logout if client and client.imap
299
302
  end
300
303
 
301
304
  ##
@@ -62,14 +62,12 @@ imap_idle lists messages added or expunged from a mailbox
62
62
 
63
63
  def show_messages_in(mailbox, uids)
64
64
  connect do |connection|
65
- @imap = connection.imap
65
+ imap = connection.imap
66
66
 
67
- @imap.select mailbox
67
+ imap.select mailbox
68
68
 
69
69
  show_messages uids
70
70
  end
71
- ensure
72
- @imap = nil
73
71
  end
74
72
 
75
73
  end
data/lib/net/imap/idle.rb CHANGED
@@ -6,7 +6,7 @@ class Net::IMAP
6
6
  # Sends an IDLE command that waits for notifications of new or expunged
7
7
  # messages. Yields responses from the server during the IDLE.
8
8
  #
9
- # Use +break+ in the response handler to leave IDLE.
9
+ # Use #idle_done to leave IDLE.
10
10
 
11
11
  def idle(&response_handler)
12
12
  raise LocalJumpError, "no block given" unless response_handler
@@ -17,23 +17,32 @@ class Net::IMAP
17
17
  tag = Thread.current[:net_imap_tag] = generate_tag
18
18
  put_string "#{tag} IDLE#{CRLF}"
19
19
 
20
- add_response_handler response_handler
21
-
22
20
  begin
23
- response = get_tagged_response tag
24
- rescue LocalJumpError # can't break cross-threads or something
25
- ensure
26
- unless response then
27
- put_string "DONE#{CRLF}"
28
- response = get_tagged_response tag
29
- end
21
+ add_response_handler response_handler
30
22
 
23
+ @idle_done_cond = new_cond
24
+ @idle_done_cond.wait
25
+ @idle_done_cond = nil
26
+ ensure
31
27
  remove_response_handler response_handler
28
+ put_string "DONE#{CRLF}"
29
+ response = get_tagged_response tag
32
30
  end
33
31
  end
34
32
 
35
33
  response
36
34
  end
37
35
 
38
- end
36
+ ##
37
+ # Leaves IDLE
38
+
39
+ def idle_done
40
+ raise Net::IMAP::Error, 'not during idle' unless @idle_done_cond
41
+
42
+ synchronize do
43
+ @idle_done_cond.signal
44
+ end
45
+ end
46
+
47
+ end unless Net::IMAP.method_defined? :idle
39
48
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imap_processor
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.2"
4
+ version: "1.3"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Hodel
@@ -30,7 +30,7 @@ cert_chain:
30
30
  x52qPcexcYZR7w==
31
31
  -----END CERTIFICATE-----
32
32
 
33
- date: 2009-07-07 00:00:00 -07:00
33
+ date: 2009-08-04 00:00:00 -07:00
34
34
  default_executable:
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  requirements: []
107
107
 
108
108
  rubyforge_project: seattlerb
109
- rubygems_version: 1.3.4
109
+ rubygems_version: 1.3.5
110
110
  signing_key:
111
111
  specification_version: 3
112
112
  summary: IMAPProcessor is a client for processing messages on an IMAP server
metadata.gz.sig CHANGED
Binary file