mailhandler 1.0.32 → 1.0.33

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: bda4cae63669da644921565a6a3d9115efb4e144
4
- data.tar.gz: 383390bcc56099b6c6e3ea37691ebfa29511d78f
3
+ metadata.gz: b888851bd9c92766c8abb3399b4bc7115dfd54ff
4
+ data.tar.gz: 39d2842b2fe5be561a99d6a77bf9c2b99cc8f49f
5
5
  SHA512:
6
- metadata.gz: 95b88b758848fefa1944d4b1db9c719483c6c88ea189f0354aed846d4c8ee8c9dc5eab30705adda517231c8edaca14dc35994ffc767bfd8208440b6799de7bd2
7
- data.tar.gz: a4486d140d015e0b6e5d9413f7f016c70f8ecee3ceebea7d3881b67a117619192af36f273f74141078e4192702291cc479f8a6f30bc9f40946ff4ad5d1e61d05
6
+ metadata.gz: b285a314daaa40d85d5133888b21c7a2340df5906c24f98a6165b38d2b3525fc666f54020a6e79aa9989719474ab9bfc6688f5aad753f1e18010a2c63183fb2d
7
+ data.tar.gz: e55151fa11ab16befe97d21e43463bcdb3e356676c98932b2ec810b5a8d0d3bc6602d2582faff96896f50ddc5f7301d00573ce8f8967bfaaba0928ccce5e476d
@@ -17,7 +17,7 @@ module MailHandler
17
17
  module DEFAULTS
18
18
 
19
19
  MAX_SEARCH_DURATION = 240 # maximum time for search to last in [seconds]
20
- SEARCH_FREQUENCY = 1 # how frequently to check for email in inbox [seconds]
20
+ SEARCH_FREQUENCY = 0.5 # how frequently to check for email in inbox [seconds]
21
21
 
22
22
  end
23
23
 
@@ -51,7 +51,6 @@ module MailHandler
51
51
  received = checker.find(options)
52
52
  update_search_details
53
53
  notify_observers(search)
54
-
55
54
  break if received
56
55
  sleep search_frequency
57
56
 
@@ -63,7 +62,7 @@ module MailHandler
63
62
  ensure
64
63
 
65
64
  checker.stop
66
-
65
+
67
66
  end
68
67
 
69
68
  private
@@ -17,9 +17,14 @@ module MailHandler
17
17
  :authentication,
18
18
  :use_ssl
19
19
 
20
+ # Connection is closed by default after each search.
21
+ # By setting this flag, closing connection is ignored and you need to close it manually.
22
+ attr_accessor :manual_connection_manage
23
+
20
24
  def initialize
21
25
 
22
26
  super
27
+ @manual_connection_manage = false
23
28
  @available_search_options = AVAILABLE_SEARCH_OPTIONS
24
29
 
25
30
  end
@@ -35,41 +40,64 @@ module MailHandler
35
40
 
36
41
  def start
37
42
 
38
- init_retriever
39
- connect
43
+ unless manual_connection_manage
44
+ init_retriever
45
+ connect
46
+ end
40
47
 
41
48
  end
42
49
 
43
50
  def stop
44
51
 
45
- disconnect
52
+ unless manual_connection_manage
53
+ disconnect
54
+ end
46
55
 
47
56
  end
48
57
 
49
- private
58
+ def connect
50
59
 
51
- def mailer
60
+ mailer.connect
52
61
 
53
- @mailer ||= Mail.retriever_method
62
+ end
63
+
64
+ def disconnect
65
+
66
+ mailer.disconnect unless mailer.imap_connection.disconnected?
54
67
 
55
68
  end
56
69
 
57
- def reconnect
70
+ # delegate retrieval details to Mail library
71
+ def init_retriever
58
72
 
59
- mailer.disconnect
60
- mailer.connect
73
+ # set imap settings if they are not set
74
+ unless retriever_set?
75
+
76
+ imap_settings = retriever_settings
77
+
78
+ Mail.defaults do
79
+
80
+ retriever_method :imap,
81
+ imap_settings
82
+
83
+ end
84
+
85
+ end
61
86
 
62
87
  end
63
88
 
64
- def connect
89
+ private
65
90
 
66
- mailer.connect
91
+ def mailer
92
+
93
+ @mailer ||= Mail.retriever_method
67
94
 
68
95
  end
69
96
 
70
- def disconnect
97
+ def reconnect
71
98
 
72
- mailer.disconnect
99
+ disconnect
100
+ connect
73
101
 
74
102
  end
75
103
 
@@ -94,25 +122,6 @@ module MailHandler
94
122
 
95
123
  RETRY_ON_ERROR_COUNT = 3
96
124
 
97
- # delegate retrieval details to Mail library
98
- def init_retriever
99
-
100
- # set imap settings if they are not set
101
- unless retriever_set?
102
-
103
- imap_settings = retriever_settings
104
-
105
- Mail.defaults do
106
-
107
- retriever_method :imap,
108
- imap_settings
109
-
110
- end
111
-
112
- end
113
-
114
- end
115
-
116
125
  def retriever_set?
117
126
 
118
127
  Mail.retriever_method.settings == retriever_settings
@@ -1,5 +1,5 @@
1
1
  module MailHandler
2
2
 
3
- VERSION = '1.0.32'
3
+ VERSION = '1.0.33'
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.32
4
+ version: 1.0.33
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-11-22 00:00:00.000000000 Z
11
+ date: 2017-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  version: 1.9.3
116
116
  requirements: []
117
117
  rubyforge_project:
118
- rubygems_version: 2.5.1
118
+ rubygems_version: 2.6.11
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: Postmark email receiving and sending handler.