imap-backup 1.0.13 → 1.0.14

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: 03ba4f6a03ae0efc265699ae27662d4089867f60
4
- data.tar.gz: 645ee02996bcf94bddc4d890ce6d22c248584fb3
3
+ metadata.gz: f7b1789e72adf3229dc78e51f865b55b051c1915
4
+ data.tar.gz: 2f6918a2cd223adc68cc37a5cff138cd30332d6e
5
5
  SHA512:
6
- metadata.gz: bd1aea391344bc6a3d66d2748f4de0f8400363e5bfdb747d440aacbd1cc1c67b145ee3025431afaf233e6cab69ec14e84448634c0ba87caaf20f42384fa16847
7
- data.tar.gz: d891fc0666d94a25ee6c9f201944b7f29eea73742e81c6ce44f8e87b44568f1a8a2214eeeef7bff6c977ee79d9be2b591e46592760f79d9690b56d2ed622d34f
6
+ metadata.gz: 0cf0f94758f44e4b5920aea52f363141d10bb3353d92635d8e4285f561498515c60e8c7494bf80245c046a59013c0aa7abf17e1263ebc3aed987479987505b7e
7
+ data.tar.gz: f77e1381ddae8bbcf0e99c93bb337f49ee9d2de5940fa30f450432e890e96fc304829d85c2a68f36cf5b6e3b62dec05859fd14195eb7c1203f2c03fd063afe84
@@ -6,11 +6,11 @@ module Imap::Backup
6
6
  class Account::Connection
7
7
  attr_reader :username
8
8
  attr_reader :local_path
9
- attr_reader :backup_folders
10
9
 
11
10
  def initialize(options)
12
11
  @username, @password = options[:username], options[:password]
13
- @local_path, @backup_folders = options[:local_path], options[:folders]
12
+ @local_path = options[:local_path]
13
+ @backup_folders = options[:folders]
14
14
  @server = options[:server]
15
15
  end
16
16
 
@@ -63,6 +63,11 @@ module Imap::Backup
63
63
  def masked_password
64
64
  password.gsub(/./, 'x')
65
65
  end
66
+
67
+ def backup_folders
68
+ return @backup_folders if @backup_folders and @backup_folders.size > 0
69
+ folders.map { |f| {:name => f} }
70
+ end
66
71
 
67
72
  def host_for(username)
68
73
  case username
@@ -3,6 +3,6 @@ module Imap; end
3
3
  module Imap::Backup
4
4
  MAJOR = 1
5
5
  MINOR = 0
6
- REVISION = 13
6
+ REVISION = 14
7
7
  VERSION = [MAJOR, MINOR, REVISION].map(&:to_s).join('.')
8
8
  end
@@ -2,19 +2,26 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe Imap::Backup::Account::Connection do
5
+ def self.backup_folder
6
+ 'backup_folder'
7
+ end
8
+
5
9
  def self.folder_config
6
- {:name => 'backup_folder'}
10
+ {:name => backup_folder}
7
11
  end
8
12
 
9
- let(:imap) { double('Net::IMAP', :login => nil, :list => []) }
13
+ let(:imap) { double('Net::IMAP', :login => nil, :list => imap_folders) }
14
+ let(:imap_folders) { [] }
10
15
  let(:options) do
11
16
  {
12
17
  :username => username,
13
18
  :password => 'password',
14
- :local_path => 'local_path',
15
- :folders => [self.class.folder_config],
19
+ :local_path => local_path,
20
+ :folders => backup_folders,
16
21
  }
17
22
  end
23
+ let(:local_path) { 'local_path' }
24
+ let(:backup_folders) { [self.class.folder_config] }
18
25
  let(:username) { 'username@gmail.com' }
19
26
 
20
27
  before do
@@ -82,12 +89,12 @@ describe Imap::Backup::Account::Connection do
82
89
  end
83
90
 
84
91
  context '#folders' do
85
- let(:folders) { 'folders' }
92
+ let(:imap_folders) { ['imap_folder'] }
86
93
 
87
- before { allow(imap).to receive(:list).and_return(folders) }
94
+ before { allow(imap).to receive(:list).and_return(imap_folders) }
88
95
 
89
96
  it 'returns the list of folders' do
90
- expect(subject.folders).to eq(folders)
97
+ expect(subject.folders).to eq(imap_folders)
91
98
  end
92
99
  end
93
100
 
@@ -103,7 +110,7 @@ describe Imap::Backup::Account::Connection do
103
110
  end
104
111
 
105
112
  it 'should return the names of folders' do
106
- expect(subject.status[0][:name]).to eq('backup_folder')
113
+ expect(subject.status[0][:name]).to eq(self.class.backup_folder)
107
114
  end
108
115
 
109
116
  it 'returns local message uids' do
@@ -132,15 +139,53 @@ describe Imap::Backup::Account::Connection do
132
139
  let(:downloader) { double('downloader', :run => nil) }
133
140
 
134
141
  before do
135
- allow(Imap::Backup::Account::Folder).to receive(:new).and_return(folder)
136
- allow(Imap::Backup::Serializer::Mbox).to receive(:new).and_return(serializer)
137
142
  allow(Imap::Backup::Downloader).to receive(:new).and_return(downloader)
138
143
  end
139
144
 
140
- before { subject.run_backup }
145
+ context 'with supplied backup_folders' do
146
+ before do
147
+ allow(Imap::Backup::Account::Folder).to receive(:new).
148
+ with(subject, self.class.backup_folder).and_return(folder)
149
+ allow(Imap::Backup::Serializer::Mbox).to receive(:new).
150
+ with(local_path, self.class.backup_folder).and_return(serializer)
151
+ end
152
+
153
+ before { subject.run_backup }
154
+
155
+ it 'runs the downloader' do
156
+ expect(downloader).to have_received(:run)
157
+ end
158
+ end
159
+
160
+ context 'without supplied backup_folders' do
161
+ let(:imap_folders) { ['foo'] }
162
+
163
+ before do
164
+ allow(Imap::Backup::Account::Folder).to receive(:new).
165
+ with(subject, 'foo').and_return(folder)
166
+ allow(Imap::Backup::Serializer::Mbox).to receive(:new).
167
+ with(local_path, 'foo').and_return(serializer)
168
+ end
169
+
170
+ context 'when supplied backup_folders is nil' do
171
+ let(:backup_folders) { nil }
172
+
173
+ before { subject.run_backup }
174
+
175
+ it 'runs the downloader' do
176
+ expect(downloader).to have_received(:run)
177
+ end
178
+ end
179
+
180
+ context 'when supplied backup_folders is an empty list' do
181
+ let(:backup_folders) { [] }
182
+
183
+ before { subject.run_backup }
141
184
 
142
- it 'runs downloaders' do
143
- expect(downloader).to have_received(:run)
185
+ it 'runs the downloader' do
186
+ expect(downloader).to have_received(:run)
187
+ end
188
+ end
144
189
  end
145
190
  end
146
191
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imap-backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.13
4
+ version: 1.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Yates