mailhandler 1.0.8 → 1.0.9

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: ccdd586333da46030574a44e6dcb812da650a587
4
- data.tar.gz: 418eab028c86d6e3f0d186b01c412372989a3d10
3
+ metadata.gz: 638f7cfc88aa7e83259905c127723c0ecc5f26ea
4
+ data.tar.gz: cbfdb4fa89e30bfd374e850cf63933f753589cac
5
5
  SHA512:
6
- metadata.gz: f3ba4e02d921daaa54f8d8188cde334877599610956675411fc328e5bd2d7b998905dd810c8a7f0b7e1dbb32da555043ba33f8542e1fe0454514b0ae52199fdd
7
- data.tar.gz: 6ede03e547267d50c50c5dcfa762b0b38ee71d165a63dae979b998be115155759c450157f86219fb5bccd26611c3310d5b7a445a1e0ab55fd0d737c749b8aa75
6
+ metadata.gz: 78c12824348df632bacb66983cc0d0bd582619af1bca973825d4dcc605b29b14f48d39ff6e8ab79bc880f802bf3937750b74c2314c949cc1aee244fc8c7af891
7
+ data.tar.gz: 83c3993bace242b2f05ec806f7a2ab8ef5fb478fe3acbdecb444e6be614ed92bc5a3d27f74ac3e0cf00b7be26e5190e831caaeb1f515ed8364770e162cf3837c
@@ -24,13 +24,12 @@ module MailHandler
24
24
 
25
25
  DEFAULT_SEARCH_OPTIONS = [
26
26
 
27
- :count, :archive
27
+ :archive
28
28
  ]
29
29
 
30
30
  def initialize
31
31
 
32
- # Default number of email results to return, and whether to archive emails.
33
- @search_options = {:count => 50, :archive => false}
32
+ base_search_options
34
33
  reset_found_emails
35
34
 
36
35
  end
@@ -47,12 +46,25 @@ module MailHandler
47
46
 
48
47
  end
49
48
 
49
+ def reset_found_emails
50
+
51
+ @found_emails = []
52
+
53
+ end
54
+
50
55
  protected
51
56
 
57
+ def base_search_options
58
+
59
+ # Default number of email results to return, and whether to archive emails.
60
+ @search_options = {:count => 50, :archive => false}
61
+
62
+ end
63
+
52
64
  def verify_and_set_search_options(options)
53
65
 
66
+ base_search_options
54
67
  validate_used_options(options)
55
- validate_mandatory_options(options)
56
68
 
57
69
  @search_options = search_options.merge options
58
70
  reset_found_emails
@@ -67,24 +79,6 @@ module MailHandler
67
79
 
68
80
  end
69
81
 
70
- def validate_mandatory_options(options)
71
-
72
- search = AVAILABLE_SEARCH_OPTIONS - DEFAULT_SEARCH_OPTIONS
73
-
74
- unless search.any? { |e| options[e] != nil }
75
-
76
- raise StandardError, "At least one of the following search options has to be used: #{search}"
77
-
78
- end
79
-
80
- end
81
-
82
- def reset_found_emails
83
-
84
- @found_emails = []
85
-
86
- end
87
-
88
82
  end
89
83
 
90
84
  end
@@ -85,14 +85,16 @@ module MailHandler
85
85
 
86
86
  if options[:archive]
87
87
 
88
- Mail.find_and_delete(:what => :last, :count => search_options[:count], :order => :desc, :keys => imap_filter_keys(options))
88
+ result = Mail.find_and_delete(:what => :last, :count => search_options[:count], :order => :desc, :keys => imap_filter_keys(options))
89
89
 
90
90
  else
91
91
 
92
- Mail.find(:what => :last, :count => search_options[:count], :order => :desc, :keys => imap_filter_keys(options))
92
+ result = Mail.find(:what => :last, :count => search_options[:count], :order => :desc, :keys => imap_filter_keys(options))
93
93
 
94
94
  end
95
95
 
96
+ (result.kind_of? Array)? result : [result]
97
+
96
98
  end
97
99
 
98
100
  def imap_filter_keys(options)
@@ -111,11 +113,15 @@ module MailHandler
111
113
 
112
114
  keys << 'SUBJECT' << options[:by_subject]
113
115
 
116
+ else
117
+
118
+
114
119
  end
115
120
 
116
121
  end
117
122
 
118
- keys
123
+ (keys.empty?)? nil : keys
124
+
119
125
 
120
126
  end
121
127
 
@@ -1,5 +1,5 @@
1
1
  module MailHandler
2
2
 
3
- VERSION = '1.0.8'
3
+ VERSION = '1.0.9'
4
4
 
5
5
  end
data/mailhandler.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.license = 'MIT'
12
12
 
13
13
  s.authors = ["Igor Balos"]
14
- s.email = "ibalosh@gmail.com"
14
+ s.email = ["ibalosh@gmail.com", "igor@wildbit.com"]
15
15
 
16
16
  s.summary = "Postmark email receiving and sending handler."
17
17
  s.description = "Use this gem to send emails through SMTP and Postmark API. Check if email arrived by imap or folder check."
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
 
20
20
  s.files = `git ls-files`.split($/)
21
21
  s.test_files = `git ls-files -- {spec}/*`.split("\n")
22
- s.homepage = 'https://github.com/ibalosh'
22
+ s.homepage = 'https://github.com/wildbit'
23
23
  s.require_paths = ["lib"]
24
24
 
25
25
  s.post_install_message = %q{
data/readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MailHandler Gem
2
2
 
3
- [![Build Status](https://travis-ci.org/ibalosh/MailHandler.svg?branch=master)](https://travis-ci.org/ibalosh/MailHandler)
3
+ [![Build Status](https://travis-ci.org/wildbit/mailhandler.svg?branch=master)](https://travis-ci.org/wildbit/mailhandler)
4
4
 
5
5
  MailHandler is a simple wrapper for [mail](https://github.com/mikel/mail) and [postmark](https://github.com/wildbit/postmark-gem) libraries which allows you to send and retrieve emails,
6
6
  and get more details about email sending and delivery. Main purpose of the gem is easier email sending/delivery testing.
@@ -41,7 +41,7 @@ If you plan to check for an email in your inbox which support IMAP, you can use
41
41
 
42
42
  ``` ruby
43
43
  email_receiver = MailHandler.receiver(:imap) do |checker|
44
- checker.address = 'imap.googlemail.com'
44
+ checker.address = 'imap.example.com'
45
45
  checker.port = 993
46
46
  checker.username = 'username'
47
47
  checker.password = 'password'
@@ -13,6 +13,7 @@ describe MailHandler::Receiver do
13
13
  allow(checker).to receive(:find) { sleep receiving_duration; true }
14
14
  allow(checker).to receive(:search_result) { true }
15
15
  allow(checker).to receive(:found_emails) { [found_email] }
16
+ allow(checker).to receive(:reset_found_emails) { [] }
16
17
  checker
17
18
 
18
19
  }
@@ -70,6 +71,7 @@ describe MailHandler::Receiver do
70
71
  allow(checker).to receive(:find) { sleep 1; false }
71
72
  allow(checker).to receive(:search_result) { false }
72
73
  allow(checker).to receive(:found_emails) { [] }
74
+ allow(checker).to receive(:reset_found_emails) { [] }
73
75
  checker
74
76
 
75
77
  }
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.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Balos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-10 00:00:00.000000000 Z
11
+ date: 2015-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail
@@ -46,7 +46,9 @@ dependencies:
46
46
  version: 1.7.0
47
47
  description: Use this gem to send emails through SMTP and Postmark API. Check if email
48
48
  arrived by imap or folder check.
49
- email: ibalosh@gmail.com
49
+ email:
50
+ - ibalosh@gmail.com
51
+ - igor@wildbit.com
50
52
  executables: []
51
53
  extensions: []
52
54
  extra_rdoc_files: []
@@ -88,7 +90,7 @@ files:
88
90
  - spec/unit/mailhandler/sending/sender_api_batch_spec.rb
89
91
  - spec/unit/mailhandler/sending/sender_api_spec.rb
90
92
  - spec/unit/mailhandler_spec.rb
91
- homepage: https://github.com/ibalosh
93
+ homepage: https://github.com/wildbit
92
94
  licenses:
93
95
  - MIT
94
96
  metadata: {}