mailhandler 1.0.25 → 1.0.26

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 923924f2168d404cb5fd28d97b77d19276e41fe7
4
- data.tar.gz: 31843295da603ab56eccedafefac33fdc5584de6
3
+ metadata.gz: c2ddb338b7a52cc1426f32afaaaeab6db6c33b7d
4
+ data.tar.gz: e79fff22bcc348aa7ecd8c3c6027172f5926f265
5
5
  SHA512:
6
- metadata.gz: 79e0f23fd3d186e623909cea7e601c1975ccfa157eb5833bc87106dae474b52ac0fd4c9fcce76ceb113df0158585e47fbff2f977261c629fbba9b2dbd24ca3fe
7
- data.tar.gz: 47ccdcadd144b7b4b68d2e3c5e400c2ff1acec00760e1fb713003a68234290c2d9cf3d45a4859f476c66c79bd62546ce809e8cdbfc1e5d1d941654e48598d736
6
+ metadata.gz: 40bfafd947ed23c6562519d1427da8c491097a7d7eeeb2b48c9cdf04c8d169d14d146d509530b264c65b982eb53f3d7fc81f479028c781361f928e834a748d26
7
+ data.tar.gz: a2dde2cb11e392fb60d5947671dc390f67094535154e0fe3eb8174925be7663c60f401d62f4c88b0a431fd8d25c90db8e255c6b9931ddbf7ff95c6a404a0e9b3
@@ -10,58 +10,50 @@ module Mail
10
10
  options[:read_only] ? imap.examine(options[:mailbox]) : imap.select(options[:mailbox])
11
11
  uids = imap.uid_search(options[:keys])
12
12
 
13
- if uids.nil? || uids.empty?
13
+ uids.reverse! if options[:what].to_sym == :last
14
+ uids = uids.first(options[:count]) if options[:count].is_a?(Integer)
15
+ uids.reverse! if (options[:what].to_sym == :last && options[:order].to_sym == :asc) ||
16
+ (options[:what].to_sym != :last && options[:order].to_sym == :desc)
14
17
 
15
- []
18
+ if block_given?
16
19
 
17
- else
18
-
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]
20
+ uids.each do |uid|
32
21
 
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?
22
+ uid = options[:uid].to_i unless options[:uid].nil?
23
+ fetchdata = imap.uid_fetch(uid, ['RFC822'])[0]
24
+ new_message = Mail.new(fetchdata.attr['RFC822'])
25
+ new_message.mark_for_delete = true if options[:delete_after_find]
41
26
 
27
+ if block.arity == 3
28
+ yield new_message, imap, uid
29
+ else
30
+ yield new_message
42
31
  end
43
32
 
44
- imap.expunge if options[:delete_after_find]
33
+ imap.uid_store(uid, "+FLAGS", [Net::IMAP::DELETED]) if options[:delete_after_find] && new_message.is_marked_for_delete?
34
+ break unless options[:uid].nil?
45
35
 
46
- else
36
+ end
47
37
 
48
- emails = []
38
+ imap.expunge if options[:delete_after_find]
49
39
 
50
- uids.each do |uid|
40
+ else
51
41
 
52
- uid = options[:uid].to_i unless options[:uid].nil?
53
- fetchdata = imap.uid_fetch(uid, ['RFC822'])[0]
54
- emails << Mail.new(fetchdata.attr['RFC822'])
55
- imap.uid_store(uid, "+FLAGS", [Net::IMAP::DELETED]) if options[:delete_after_find]
56
- break unless options[:uid].nil?
42
+ emails = []
57
43
 
58
- end
44
+ uids.each do |uid|
59
45
 
60
- imap.expunge if options[:delete_after_find]
61
- emails.size == 1 && options[:count] == 1 ? emails.first : emails
46
+ uid = options[:uid].to_i unless options[:uid].nil?
47
+ fetchdata = imap.uid_fetch(uid, ['RFC822'])[0]
48
+ emails << Mail.new(fetchdata.attr['RFC822'])
49
+ imap.uid_store(uid, "+FLAGS", [Net::IMAP::DELETED]) if options[:delete_after_find]
50
+ break unless options[:uid].nil?
62
51
 
63
52
  end
64
53
 
54
+ imap.expunge if options[:delete_after_find]
55
+ emails.size == 1 && options[:count] == 1 ? emails.first : emails
56
+
65
57
  end
66
58
 
67
59
  end
@@ -1,5 +1,5 @@
1
1
  module MailHandler
2
2
 
3
- VERSION = '1.0.25'
3
+ VERSION = '1.0.26'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailhandler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.25
4
+ version: 1.0.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Balos