mailhandler 1.0.24 → 1.0.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2c92c21a448a3f604ea019ee4ecffe0e89c8ddd
4
- data.tar.gz: 9599f219db0bc2bfbff8898e5be866aebce980ad
3
+ metadata.gz: 923924f2168d404cb5fd28d97b77d19276e41fe7
4
+ data.tar.gz: 31843295da603ab56eccedafefac33fdc5584de6
5
5
  SHA512:
6
- metadata.gz: a6e7dd092250d6c5fd0f1841b6293264b6f71a6322b2b0d787b054e641bc48bbd46a15232785b3198c7b4b5ce0c872e0f83148e76202fd43484d544af3f2c64c
7
- data.tar.gz: b32af98f6af8d2857086ef8a1c9bca05f43b0956e3a852b24af8d62f16d85554f4b685eed262061f350d0518599a453a84141e7099bb8be242425051d07e1866
6
+ metadata.gz: 79e0f23fd3d186e623909cea7e601c1975ccfa157eb5833bc87106dae474b52ac0fd4c9fcce76ceb113df0158585e47fbff2f977261c629fbba9b2dbd24ca3fe
7
+ data.tar.gz: 47ccdcadd144b7b4b68d2e3c5e400c2ff1acec00760e1fb713003a68234290c2d9cf3d45a4859f476c66c79bd62546ce809e8cdbfc1e5d1d941654e48598d736
@@ -182,11 +182,11 @@ module MailHandler
182
182
 
183
183
  when :since
184
184
 
185
- keys << 'SINCE' << Net::IMAP.format_date(options[:since])
185
+ keys << 'SINCE' << Net::IMAP.format_datetime(options[:since])
186
186
 
187
187
  when :before
188
188
 
189
- keys << 'BEFORE' << Net::IMAP.format_date(options[:before])
189
+ keys << 'BEFORE' << Net::IMAP.format_datetime(options[:before])
190
190
 
191
191
  else
192
192
 
@@ -7,41 +7,48 @@ module Mail
7
7
  def find(options={}, &block)
8
8
 
9
9
  options = validate_options(options)
10
-
11
10
  options[:read_only] ? imap.examine(options[:mailbox]) : imap.select(options[:mailbox])
12
-
13
11
  uids = imap.uid_search(options[:keys])
14
- uids.reverse! if options[:what].to_sym == :last
15
- uids = uids.first(options[:count]) if options[:count].is_a?(Integer)
16
- uids.reverse! if (options[:what].to_sym == :last && options[:order].to_sym == :asc) ||
17
- (options[:what].to_sym != :last && options[:order].to_sym == :desc)
18
-
19
-
20
- if block_given?
21
-
22
- uids.each do |uid|
23
- uid = options[:uid].to_i unless options[:uid].nil?
24
- fetchdata = imap.uid_fetch(uid, ['RFC822'])[0]
25
- new_message = Mail.new(fetchdata.attr['RFC822'])
26
- new_message.mark_for_delete = true if options[:delete_after_find]
27
- if block.arity == 3
28
- yield new_message, imap, uid
29
- else
30
- yield new_message
31
- end
32
- imap.uid_store(uid, "+FLAGS", [Net::IMAP::DELETED]) if options[:delete_after_find] && new_message.is_marked_for_delete?
33
- break unless options[:uid].nil?
34
- end
35
12
 
36
- imap.expunge if options[:delete_after_find]
13
+ if uids.nil? || uids.empty?
14
+
15
+ []
37
16
 
38
17
  else
39
18
 
40
- emails = []
19
+ uids.reverse! if options[:what].to_sym == :last
20
+ uids = uids.first(options[:count]) if options[:count].is_a?(Integer)
21
+ uids.reverse! if (options[:what].to_sym == :last && options[:order].to_sym == :asc) ||
22
+ (options[:what].to_sym != :last && options[:order].to_sym == :desc)
23
+
24
+ if block_given?
25
+
26
+ uids.each do |uid|
27
+
28
+ uid = options[:uid].to_i unless options[:uid].nil?
29
+ fetchdata = imap.uid_fetch(uid, ['RFC822'])[0]
30
+ new_message = Mail.new(fetchdata.attr['RFC822'])
31
+ new_message.mark_for_delete = true if options[:delete_after_find]
32
+
33
+ if block.arity == 3
34
+ yield new_message, imap, uid
35
+ else
36
+ yield new_message
37
+ end
38
+
39
+ imap.uid_store(uid, "+FLAGS", [Net::IMAP::DELETED]) if options[:delete_after_find] && new_message.is_marked_for_delete?
40
+ break unless options[:uid].nil?
41
+
42
+ end
41
43
 
42
- unless uids.nil?
44
+ imap.expunge if options[:delete_after_find]
45
+
46
+ else
47
+
48
+ emails = []
43
49
 
44
50
  uids.each do |uid|
51
+
45
52
  uid = options[:uid].to_i unless options[:uid].nil?
46
53
  fetchdata = imap.uid_fetch(uid, ['RFC822'])[0]
47
54
  emails << Mail.new(fetchdata.attr['RFC822'])
@@ -50,10 +57,10 @@ module Mail
50
57
 
51
58
  end
52
59
 
53
- end
60
+ imap.expunge if options[:delete_after_find]
61
+ emails.size == 1 && options[:count] == 1 ? emails.first : emails
54
62
 
55
- imap.expunge if options[:delete_after_find]
56
- emails.size == 1 && options[:count] == 1 ? emails.first : emails
63
+ end
57
64
 
58
65
  end
59
66
 
@@ -62,15 +69,15 @@ module Mail
62
69
  # Start an IMAP session
63
70
  def connect(config=Mail::Configuration.instance)
64
71
 
65
- @imap = Net::IMAP.new(settings[:address], settings[:port], settings[:enable_ssl], nil, false)
72
+ @imap = Net::IMAP.new(settings[:address], settings[:port], settings[:enable_ssl], nil, false)
66
73
 
67
- if settings[:authentication].nil?
68
- imap.login(settings[:user_name], settings[:password])
69
- else
70
- # Note that Net::IMAP#authenticate('LOGIN', ...) is not equal with Net::IMAP#login(...)!
71
- # (see also http://www.ensta.fr/~diam/ruby/online/ruby-doc-stdlib/libdoc/net/imap/rdoc/classes/Net/IMAP.html#M000718)
72
- imap.authenticate(settings[:authentication], settings[:user_name], settings[:password])
73
- end
74
+ if settings[:authentication].nil?
75
+ imap.login(settings[:user_name], settings[:password])
76
+ else
77
+ # Note that Net::IMAP#authenticate('LOGIN', ...) is not equal with Net::IMAP#login(...)!
78
+ # (see also http://www.ensta.fr/~diam/ruby/online/ruby-doc-stdlib/libdoc/net/imap/rdoc/classes/Net/IMAP.html#M000718)
79
+ imap.authenticate(settings[:authentication], settings[:user_name], settings[:password])
80
+ end
74
81
 
75
82
  end
76
83
 
@@ -1,5 +1,5 @@
1
1
  module MailHandler
2
2
 
3
- VERSION = '1.0.24'
3
+ VERSION = '1.0.25'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailhandler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.24
4
+ version: 1.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Balos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-08 00:00:00.000000000 Z
11
+ date: 2016-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail