navi_client 1.4.1 → 1.4.2

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
  SHA256:
3
- metadata.gz: efe6f58321082dffdaf836f0196296e1a0f4b41c9439748bad4584e01b33226d
4
- data.tar.gz: 732080eba8e79e6f3281ca406266ea70921de6aef125d2adb192ace279b37b78
3
+ metadata.gz: 50d073876d1eadbec8a1e79f80aca5026e543559f2648d23c54aaba5997aba7e
4
+ data.tar.gz: e7ecc32401669850c76251e53bcb242be53f3cb5c515813006dbd3b6d2d309cf
5
5
  SHA512:
6
- metadata.gz: 7d87d373def5739937a330fd1eb3dd6d89e146cbd48dc5ec0947e803ee1993e13c9196d8f8a7e981b9ff6ae8e65ed8ebd75c1536f459a5ad677cb007adb24ba7
7
- data.tar.gz: ec03eb54f62a35e6d7532fa56e4cf01eedff95aa76088555ec59d110400d33f869b5a3049c4f0f8a8c1d8633760c4ac64f0204b9840c8d72a6f06f780f3c4372
6
+ metadata.gz: 4ea63491dd0914cee7ad46296c69aaf06aeb7f23a98164e32a74ac4ed93b48afa408884d7fbbcbe73012c0a5c39be3ee770b266aba7d47533c8600399668eb64
7
+ data.tar.gz: a4da4ae35837bd9c0fc612e854c93b1529d4b261577e6fa42cfa1e99eda447b88734f0a29ec80d8f7e0efbb9dcfd5d3a2ef1fe10154975e713b67697f787abaa
@@ -146,7 +146,7 @@ module NaviClient
146
146
  # retrieve any mail from a folder, following specified search condition
147
147
  # for any mail retrieved call a specified block
148
148
  #
149
- def idle_loop(imap, search_condition, folder, server, username, password)
149
+ def idle_loop(imap, search_condition, folder, server, username, password, callback = nil, navi_control = nil)
150
150
 
151
151
  @logger.info "\nwaiting new mails (IDLE loop)..."
152
152
 
@@ -158,8 +158,9 @@ module NaviClient
158
158
  # You'll get all the things from the server. For new emails (EXISTS)
159
159
  if resp.kind_of?(Net::IMAP::UntaggedResponse) and resp.name == "EXISTS"
160
160
 
161
- @logger.debug resp.inspect if @debug
161
+ # @logger.debug resp.inspect if @debug
162
162
  # Got something. Send DONE. This breaks you out of the blocking call
163
+ @logger.debug "New mail received" if @debug
163
164
  imap.idle_done
164
165
  end
165
166
  end
@@ -167,12 +168,20 @@ module NaviClient
167
168
  # We're out, which means there are some emails ready for us.
168
169
  # Go do a search for UNSEEN and fetch them.
169
170
  filenames = []
170
- retrieve_emails(imap, search_condition, folder) { |mail, i, isLast, id| filenames << process_email(mail, id)}
171
+ retrieve_emails(imap, search_condition, folder) { |mail, i, isLast, id|
172
+ callback.call(mail, i, id, false) unless callback.nil?
173
+ filenames << process_email(mail, id)
174
+ callback.call(mail, i, id, true) unless callback.nil?
175
+ }
176
+
177
+ @logger.info "Sending Request for #{filenames.size} emails to Navi AI."
178
+ navi_control.call(true) unless navi_control.nil?
171
179
  self.send_request(filenames)
172
180
 
173
181
  HTTPService::NaviAI.generate_csv("#{@gen_csv_url}?email=#{username}", @token)
174
182
 
175
183
  @logger.debug "Process Completed." if @debug
184
+ navi_control.call(false) unless navi_control.nil?
176
185
 
177
186
  rescue SignalException => e
178
187
  # http://stackoverflow.com/questions/2089421/capturing-ctrl-c-in-ruby
@@ -181,8 +190,6 @@ module NaviClient
181
190
 
182
191
  rescue Net::IMAP::Error => e
183
192
  @logger.error "Net::IMAP::Error at #{time_now}: #{e.class}. #{e.message}"
184
-
185
- # timeout ? reopen connection
186
193
  imap = imap_connection(server, username, password) #if e.message == 'connection closed'
187
194
  @logger.info "reconnected to server: #{server}"
188
195
 
@@ -1,3 +1,3 @@
1
1
  module NaviClient
2
- VERSION = "1.4.1"
2
+ VERSION = "1.4.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: navi_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sujit
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2018-04-25 00:00:00.000000000 Z
13
+ date: 2018-05-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler