imap-backup 1.0.4 → 1.0.5

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: 75e9eecc039c7cd2b76fc1fbc1acfbe2e07009fa
4
- data.tar.gz: ce731fe2f0cc8db8af5fb70ce77d5464b46b7066
3
+ metadata.gz: eac9741caa296c80fd63a064ba94efb71757200d
4
+ data.tar.gz: f405d8fb91c9f75cba102587d2867f606aa40c81
5
5
  SHA512:
6
- metadata.gz: 4135cd6ab9a7bd60d5f2e8ea9be63aaad5754621f87b809b6ac611390f1a906faec4019f7289a953509c2d1785f0891018cbd83c2e64da8ae6a30bf6ca8515a4
7
- data.tar.gz: 439df924e96c91c571dc9943f23ccd77a939a83f396e235bf4ca5b5f123a2b1abdffd28f11fb313e1d235625ac681027057b8ef6f3b544560c5d1a92d5688127
6
+ metadata.gz: aa78818bc59cca9065fab40444798db9b107c2b3fb88b2ba6485c8f18dca5a26b0ca85fc51446fa25373bf8bbfb6275db6527c7fe271c8126f59bb68a7878a8a
7
+ data.tar.gz: 9841997c5f74550963486207905676d9f9d4bcfbb149e5055209a84f93869dfb5c45f545058ab87ecbb6c534a944e8706f39cec7dc94a941f310b2999f624b23
@@ -4,11 +4,12 @@ module Imap
4
4
  module Backup
5
5
  module Account
6
6
  class Connection
7
- attr_reader :username, :local_path, :backup_folders
7
+ attr_reader :username, :local_path, :backup_folders, :server
8
8
 
9
9
  def initialize(options)
10
10
  @username, @password = options[:username], options[:password]
11
11
  @local_path, @backup_folders = options[:local_path], options[:folders]
12
+ @server = options[:server] || host_for(username)
12
13
  end
13
14
 
14
15
  def folders
@@ -39,9 +40,8 @@ module Imap
39
40
 
40
41
  def imap
41
42
  return @imap unless @imap.nil?
42
- host = host_for(username)
43
43
  options = options_for(username)
44
- @imap = Net::IMAP.new(host, options)
44
+ @imap = Net::IMAP.new(server, options)
45
45
  @imap.login(username, @password)
46
46
  @imap
47
47
  end
@@ -2,7 +2,7 @@ module Imap
2
2
  module Backup
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- REVISION = 4
5
+ REVISION = 5
6
6
  VERSION = [MAJOR, MINOR, REVISION].map(&:to_s).join('.')
7
7
  end
8
8
  end
@@ -12,7 +12,7 @@ describe Imap::Backup::Account::Connection do
12
12
  :username => username,
13
13
  :password => 'password',
14
14
  :local_path => 'local_path',
15
- :folders => [self.class.folder_config]
15
+ :folders => [self.class.folder_config],
16
16
  }
17
17
  end
18
18
  let(:username) { 'username@gmail.com' }
@@ -23,7 +23,11 @@ describe Imap::Backup::Account::Connection do
23
23
 
24
24
  subject { Imap::Backup::Account::Connection.new(options) }
25
25
 
26
- shared_examples 'connects to IMAP' do |username = 'username@gmail.com', server = 'imap.gmail.com'|
26
+ shared_examples 'connects to IMAP' do |options|
27
+ options ||= {}
28
+ username = options[:username] || 'username@gmail.com'
29
+ server = options[:server] || 'imap.gmail.com'
30
+
27
31
  it 'sets up the IMAP connection' do
28
32
  expect(Net::IMAP).to have_received(:new).with(server, {:port => 993, :ssl => true})
29
33
  end
@@ -37,10 +41,28 @@ describe Imap::Backup::Account::Connection do
37
41
  [
38
42
  [:username, 'username@gmail.com'],
39
43
  [:local_path, 'local_path'],
40
- [:backup_folders, [folder_config]]
44
+ [:backup_folders, [folder_config]],
41
45
  ].each do |attr, expected|
42
46
  its(attr) { should eq(expected) }
43
47
  end
48
+
49
+ context 'server' do
50
+ context 'with a supplied value' do
51
+ before do
52
+ options.merge!(:server => 'imap.example.com')
53
+ end
54
+
55
+ it 'uses the supplied value' do
56
+ expect(subject.server).to eq('imap.example.com')
57
+ end
58
+ end
59
+
60
+ context 'without a supplied value' do
61
+ it 'uses the guesses the value' do
62
+ expect(subject.server).to eq('imap.gmail.com')
63
+ end
64
+ end
65
+ end
44
66
  end
45
67
 
46
68
  [
@@ -53,7 +75,7 @@ describe Imap::Backup::Account::Connection do
53
75
  before { allow(imap).to receive(:disconnect) }
54
76
  before { subject.disconnect }
55
77
 
56
- include_examples 'connects to IMAP', [email_username, server]
78
+ include_examples 'connects to IMAP', {:username => email_username, :server => server}
57
79
  end
58
80
  end
59
81
 
@@ -105,7 +127,7 @@ describe Imap::Backup::Account::Connection do
105
127
  context '#run_backup' do
106
128
  let(:folder) { double('folder') }
107
129
  let(:serializer) { double('serializer') }
108
- let(:downloader) { double('downloader', run: nil) }
130
+ let(:downloader) { double('downloader', :run => nil) }
109
131
 
110
132
  before do
111
133
  allow(Imap::Backup::Account::Folder).to receive(:new).and_return(folder)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imap-backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Yates
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-10 00:00:00.000000000 Z
11
+ date: 2013-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake