rgrove-larch 0.0.1.1 → 0.0.1.2

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.
Files changed (2) hide show
  1. data/lib/larch/imap.rb +33 -27
  2. metadata +1 -1
data/lib/larch/imap.rb CHANGED
@@ -352,42 +352,48 @@ class IMAP
352
352
  def unsafe_connect
353
353
  info "connecting..."
354
354
 
355
- begin
356
- @imap = Net::IMAP.new(host, port, ssl?)
357
- rescue => e
358
- error e.message
359
- raise
360
- end
355
+ exception = nil
361
356
 
362
- info "connected on port #{port}" << (ssl? ? ' using SSL' : '')
357
+ Thread.new do
358
+ begin
359
+ @imap = Net::IMAP.new(host, port, ssl?)
363
360
 
364
- auth_methods = ['PLAIN']
365
- tried = []
361
+ info "connected on port #{port}" << (ssl? ? ' using SSL' : '')
366
362
 
367
- ['LOGIN', 'CRAM-MD5'].each do |method|
368
- auth_methods << method if @imap.capability.include?("AUTH=#{method}")
369
- end
363
+ auth_methods = ['PLAIN']
364
+ tried = []
370
365
 
371
- begin
372
- tried << method = auth_methods.pop
366
+ ['LOGIN', 'CRAM-MD5'].each do |method|
367
+ auth_methods << method if @imap.capability.include?("AUTH=#{method}")
368
+ end
373
369
 
374
- debug "authenticating using #{method}"
370
+ begin
371
+ tried << method = auth_methods.pop
375
372
 
376
- if method == 'PLAIN'
377
- @imap.login(@username, @password)
378
- else
379
- @imap.authenticate(method, @username, @password)
380
- end
373
+ debug "authenticating using #{method}"
381
374
 
382
- info "authenticated using #{method}"
375
+ if method == 'PLAIN'
376
+ @imap.login(@username, @password)
377
+ else
378
+ @imap.authenticate(method, @username, @password)
379
+ end
383
380
 
384
- rescue Net::IMAP::BadResponseError, Net::IMAP::NoResponseError => e
385
- debug "#{method} auth failed: #{e.message}"
386
- retry unless auth_methods.empty?
381
+ info "authenticated using #{method}"
387
382
 
388
- error "authentication failed: #{e.message} (tried #{tried.join(', ')})"
389
- raise
390
- end
383
+ rescue Net::IMAP::BadResponseError, Net::IMAP::NoResponseError => e
384
+ debug "#{method} auth failed: #{e.message}"
385
+ retry unless auth_methods.empty?
386
+
387
+ raise e, "#{e.message} (tried #{tried.join(', ')})"
388
+ end
389
+
390
+ rescue => e
391
+ exception = e
392
+ error e.message
393
+ end
394
+ end.join
395
+
396
+ raise exception if exception
391
397
  end
392
398
 
393
399
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgrove-larch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.1
4
+ version: 0.0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Grove