imap-backup 4.0.3 → 4.0.7
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 +4 -4
- data/lib/email/provider/apple_mail.rb +2 -2
- data/lib/email/provider/base.rb +8 -0
- data/lib/email/provider/fastmail.rb +2 -2
- data/lib/email/provider/gmail.rb +2 -2
- data/lib/email/provider/{default.rb → unknown.rb} +2 -3
- data/lib/email/provider.rb +2 -2
- data/lib/imap/backup/account/connection.rb +23 -31
- data/lib/imap/backup/account/folder.rb +1 -1
- data/lib/imap/backup/account.rb +98 -0
- data/lib/imap/backup/cli/helpers.rb +1 -1
- data/lib/imap/backup/cli/local.rb +1 -1
- data/lib/imap/backup/configuration/account.rb +38 -30
- data/lib/imap/backup/configuration/folder_chooser.rb +7 -9
- data/lib/imap/backup/configuration/list.rb +1 -1
- data/lib/imap/backup/configuration/setup.rb +10 -8
- data/lib/imap/backup/configuration/store.rb +33 -11
- data/lib/imap/backup/version.rb +1 -1
- data/lib/imap/backup.rb +1 -0
- data/spec/features/support/shared/connection_context.rb +7 -5
- data/spec/unit/email/provider/{default_spec.rb → base_spec.rb} +1 -7
- data/spec/unit/email/provider_spec.rb +2 -2
- data/spec/unit/imap/backup/account/connection_spec.rb +8 -17
- data/spec/unit/imap/backup/cli/local_spec.rb +9 -2
- data/spec/unit/imap/backup/cli/utils_spec.rb +44 -42
- data/spec/unit/imap/backup/configuration/account_spec.rb +47 -46
- data/spec/unit/imap/backup/configuration/folder_chooser_spec.rb +17 -18
- data/spec/unit/imap/backup/configuration/list_spec.rb +12 -5
- data/spec/unit/imap/backup/configuration/setup_spec.rb +33 -12
- data/spec/unit/imap/backup/configuration/store_spec.rb +21 -22
- metadata +32 -32
- data/spec/support/shared_examples/account_flagging.rb +0 -23
@@ -3,8 +3,31 @@ describe Imap::Backup::Configuration::Setup do
|
|
3
3
|
|
4
4
|
subject { described_class.new }
|
5
5
|
|
6
|
-
let(:
|
7
|
-
|
6
|
+
let(:normal_account) do
|
7
|
+
instance_double(
|
8
|
+
Imap::Backup::Account,
|
9
|
+
username: "account@example.com",
|
10
|
+
marked_for_deletion?: false,
|
11
|
+
modified?: false
|
12
|
+
)
|
13
|
+
end
|
14
|
+
let(:modified_account) do
|
15
|
+
instance_double(
|
16
|
+
Imap::Backup::Account,
|
17
|
+
username: "modified@example.com",
|
18
|
+
marked_for_deletion?: false,
|
19
|
+
modified?: true
|
20
|
+
)
|
21
|
+
end
|
22
|
+
let(:deleted_account) do
|
23
|
+
instance_double(
|
24
|
+
Imap::Backup::Account,
|
25
|
+
username: "delete@example.com",
|
26
|
+
marked_for_deletion?: true,
|
27
|
+
modified?: false
|
28
|
+
)
|
29
|
+
end
|
30
|
+
let(:accounts) { [normal_account] }
|
8
31
|
let(:store) do
|
9
32
|
instance_double(
|
10
33
|
Imap::Backup::Configuration::Store,
|
@@ -63,9 +86,7 @@ describe Imap::Backup::Configuration::Setup do
|
|
63
86
|
end
|
64
87
|
|
65
88
|
describe "listing" do
|
66
|
-
let(:accounts) { [
|
67
|
-
let(:modified) { {username: "modified@example.com", modified: true} }
|
68
|
-
let(:deleted) { {username: "deleted@example.com", delete: true} }
|
89
|
+
let(:accounts) { [normal_account, modified_account, deleted_account] }
|
69
90
|
|
70
91
|
before { subject.run }
|
71
92
|
|
@@ -98,7 +119,7 @@ describe Imap::Backup::Configuration::Setup do
|
|
98
119
|
allow(Imap::Backup::Configuration::Asker).to receive(:email).
|
99
120
|
with(no_args) { "new@example.com" }
|
100
121
|
allow(Imap::Backup::Configuration::Account).to receive(:new).
|
101
|
-
with(store,
|
122
|
+
with(store, normal_account, anything) { account }
|
102
123
|
end
|
103
124
|
|
104
125
|
it "edits the account" do
|
@@ -134,19 +155,19 @@ describe Imap::Backup::Configuration::Setup do
|
|
134
155
|
end
|
135
156
|
|
136
157
|
it "sets username" do
|
137
|
-
expect(accounts[1]
|
158
|
+
expect(accounts[1].username).to eq(added_email)
|
138
159
|
end
|
139
160
|
|
140
161
|
it "sets blank password" do
|
141
|
-
expect(accounts[1]
|
162
|
+
expect(accounts[1].password).to eq("")
|
142
163
|
end
|
143
164
|
|
144
165
|
it "sets local_path" do
|
145
|
-
expect(accounts[1]
|
166
|
+
expect(accounts[1].local_path).to eq(local_path)
|
146
167
|
end
|
147
168
|
|
148
169
|
it "sets folders" do
|
149
|
-
expect(accounts[1]
|
170
|
+
expect(accounts[1].folders).to eq([])
|
150
171
|
end
|
151
172
|
|
152
173
|
context "when the account is a GMail account" do
|
@@ -154,12 +175,12 @@ describe Imap::Backup::Configuration::Setup do
|
|
154
175
|
let(:local_path) { "/base/path/new_gmail.com" }
|
155
176
|
|
156
177
|
it "sets the server" do
|
157
|
-
expect(accounts[1]
|
178
|
+
expect(accounts[1].server).to eq(gmail_imap_server)
|
158
179
|
end
|
159
180
|
end
|
160
181
|
|
161
182
|
it "doesn't flag the unedited account as modified" do
|
162
|
-
expect(accounts[1]
|
183
|
+
expect(accounts[1].modified?).to be_falsey
|
163
184
|
end
|
164
185
|
end
|
165
186
|
|
@@ -8,10 +8,12 @@ describe Imap::Backup::Configuration::Store do
|
|
8
8
|
let(:file_path) { File.join(directory, "/config.json") }
|
9
9
|
let(:file_exists) { true }
|
10
10
|
let(:directory_exists) { true }
|
11
|
-
let(:data) { {debug: debug, accounts: accounts} }
|
12
11
|
let(:debug) { true }
|
13
|
-
let(:accounts) { [] }
|
14
12
|
let(:configuration) { data.to_json }
|
13
|
+
let(:data) { {debug: debug, accounts: accounts.map(&:to_h)} }
|
14
|
+
let(:accounts) { [account1, account2] }
|
15
|
+
let(:account1) { Imap::Backup::Account.new({username: "username1"}) }
|
16
|
+
let(:account2) { Imap::Backup::Account.new({username: "username2"}) }
|
15
17
|
|
16
18
|
before do
|
17
19
|
stub_const(
|
@@ -48,8 +50,8 @@ describe Imap::Backup::Configuration::Store do
|
|
48
50
|
end
|
49
51
|
|
50
52
|
describe "#modified?" do
|
51
|
-
context "with accounts
|
52
|
-
|
53
|
+
context "with modified accounts" do
|
54
|
+
before { subject.accounts[0].username = "changed" }
|
53
55
|
|
54
56
|
it "is true" do
|
55
57
|
expect(subject.modified?).to be_truthy
|
@@ -57,7 +59,7 @@ describe Imap::Backup::Configuration::Store do
|
|
57
59
|
end
|
58
60
|
|
59
61
|
context "with accounts flagged 'delete'" do
|
60
|
-
|
62
|
+
before { subject.accounts[0].mark_for_deletion! }
|
61
63
|
|
62
64
|
it "is true" do
|
63
65
|
expect(subject.modified?).to be_truthy
|
@@ -65,8 +67,6 @@ describe Imap::Backup::Configuration::Store do
|
|
65
67
|
end
|
66
68
|
|
67
69
|
context "without accounts flagged 'modified'" do
|
68
|
-
let(:accounts) { [{name: "foo"}] }
|
69
|
-
|
70
70
|
it "is false" do
|
71
71
|
expect(subject.modified?).to be_falsey
|
72
72
|
end
|
@@ -156,19 +156,14 @@ describe Imap::Backup::Configuration::Store do
|
|
156
156
|
subject.save
|
157
157
|
end
|
158
158
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
before { subject.save }
|
163
|
-
|
164
|
-
it "skips the 'modified' flag" do
|
165
|
-
expected = Marshal.load(Marshal.dump(data))
|
166
|
-
expected[:accounts][0].delete(:modified)
|
159
|
+
it "uses the Account#to_h method" do
|
160
|
+
allow(subject.accounts[0]).to receive(:to_h) { "Account1" }
|
161
|
+
allow(subject.accounts[1]).to receive(:to_h) { "Account2" }
|
167
162
|
|
168
|
-
|
163
|
+
expect(JSON).to receive(:pretty_generate).
|
164
|
+
with(hash_including({accounts: ["Account1", "Account2"]}))
|
169
165
|
|
170
|
-
|
171
|
-
end
|
166
|
+
subject.save
|
172
167
|
end
|
173
168
|
|
174
169
|
context "when accounts are to be deleted" do
|
@@ -179,11 +174,15 @@ describe Imap::Backup::Configuration::Store do
|
|
179
174
|
]
|
180
175
|
end
|
181
176
|
|
182
|
-
|
183
|
-
|
184
|
-
|
177
|
+
before do
|
178
|
+
allow(subject.accounts[0]).to receive(:to_h) { "Account1" }
|
179
|
+
allow(subject.accounts[1]).to receive(:to_h) { "Account2" }
|
180
|
+
subject.accounts[0].mark_for_deletion!
|
181
|
+
end
|
185
182
|
|
186
|
-
|
183
|
+
it "does not save them" do
|
184
|
+
expect(JSON).to receive(:pretty_generate).
|
185
|
+
with(hash_including({accounts: ["Account2"]}))
|
187
186
|
|
188
187
|
subject.save
|
189
188
|
end
|
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: 4.0.
|
4
|
+
version: 4.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Yates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|
@@ -182,10 +182,12 @@ files:
|
|
182
182
|
- lib/email/mboxrd/message.rb
|
183
183
|
- lib/email/provider.rb
|
184
184
|
- lib/email/provider/apple_mail.rb
|
185
|
-
- lib/email/provider/
|
185
|
+
- lib/email/provider/base.rb
|
186
186
|
- lib/email/provider/fastmail.rb
|
187
187
|
- lib/email/provider/gmail.rb
|
188
|
+
- lib/email/provider/unknown.rb
|
188
189
|
- lib/imap/backup.rb
|
190
|
+
- lib/imap/backup/account.rb
|
189
191
|
- lib/imap/backup/account/connection.rb
|
190
192
|
- lib/imap/backup/account/folder.rb
|
191
193
|
- lib/imap/backup/cli.rb
|
@@ -235,11 +237,10 @@ files:
|
|
235
237
|
- spec/spec_helper.rb
|
236
238
|
- spec/support/fixtures.rb
|
237
239
|
- spec/support/higline_test_helpers.rb
|
238
|
-
- spec/support/shared_examples/account_flagging.rb
|
239
240
|
- spec/support/silence_logging.rb
|
240
241
|
- spec/unit/email/mboxrd/message_spec.rb
|
241
242
|
- spec/unit/email/provider/apple_mail_spec.rb
|
242
|
-
- spec/unit/email/provider/
|
243
|
+
- spec/unit/email/provider/base_spec.rb
|
243
244
|
- spec/unit/email/provider/fastmail_spec.rb
|
244
245
|
- spec/unit/email/provider/gmail_spec.rb
|
245
246
|
- spec/unit/email/provider_spec.rb
|
@@ -281,47 +282,46 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
281
282
|
- !ruby/object:Gem::Version
|
282
283
|
version: '0'
|
283
284
|
requirements: []
|
284
|
-
rubygems_version: 3.1.
|
285
|
+
rubygems_version: 3.1.2
|
285
286
|
signing_key:
|
286
287
|
specification_version: 4
|
287
288
|
summary: Backup GMail (or other IMAP) accounts to disk
|
288
289
|
test_files:
|
289
290
|
- spec/spec_helper.rb
|
291
|
+
- spec/fixtures/connection.yml
|
292
|
+
- spec/unit/email/provider/gmail_spec.rb
|
293
|
+
- spec/unit/email/provider/apple_mail_spec.rb
|
294
|
+
- spec/unit/email/provider/fastmail_spec.rb
|
295
|
+
- spec/unit/email/provider/base_spec.rb
|
296
|
+
- spec/unit/email/provider_spec.rb
|
297
|
+
- spec/unit/email/mboxrd/message_spec.rb
|
290
298
|
- spec/unit/imap/backup_spec.rb
|
291
|
-
- spec/unit/imap/backup/
|
292
|
-
- spec/unit/imap/backup/
|
299
|
+
- spec/unit/imap/backup/cli/utils_spec.rb
|
300
|
+
- spec/unit/imap/backup/cli/local_spec.rb
|
301
|
+
- spec/unit/imap/backup/utils_spec.rb
|
302
|
+
- spec/unit/imap/backup/client/default_spec.rb
|
303
|
+
- spec/unit/imap/backup/downloader_spec.rb
|
304
|
+
- spec/unit/imap/backup/configuration/store_spec.rb
|
293
305
|
- spec/unit/imap/backup/configuration/connection_tester_spec.rb
|
294
|
-
- spec/unit/imap/backup/configuration/setup_spec.rb
|
295
306
|
- spec/unit/imap/backup/configuration/asker_spec.rb
|
307
|
+
- spec/unit/imap/backup/configuration/setup_spec.rb
|
296
308
|
- spec/unit/imap/backup/configuration/folder_chooser_spec.rb
|
297
|
-
- spec/unit/imap/backup/configuration/
|
309
|
+
- spec/unit/imap/backup/configuration/account_spec.rb
|
310
|
+
- spec/unit/imap/backup/configuration/list_spec.rb
|
311
|
+
- spec/unit/imap/backup/account/folder_spec.rb
|
312
|
+
- spec/unit/imap/backup/account/connection_spec.rb
|
298
313
|
- spec/unit/imap/backup/serializer/mbox_spec.rb
|
299
314
|
- spec/unit/imap/backup/serializer/mbox_store_spec.rb
|
300
315
|
- spec/unit/imap/backup/serializer/mbox_enumerator_spec.rb
|
301
|
-
- spec/unit/imap/backup/cli/utils_spec.rb
|
302
|
-
- spec/unit/imap/backup/cli/local_spec.rb
|
303
|
-
- spec/unit/imap/backup/downloader_spec.rb
|
304
316
|
- spec/unit/imap/backup/uploader_spec.rb
|
305
|
-
- spec/
|
306
|
-
- spec/
|
307
|
-
- spec/
|
308
|
-
- spec/
|
309
|
-
- spec/unit/email/mboxrd/message_spec.rb
|
310
|
-
- spec/unit/email/provider/gmail_spec.rb
|
311
|
-
- spec/unit/email/provider/default_spec.rb
|
312
|
-
- spec/unit/email/provider/apple_mail_spec.rb
|
313
|
-
- spec/unit/email/provider/fastmail_spec.rb
|
314
|
-
- spec/unit/email/provider_spec.rb
|
317
|
+
- spec/support/fixtures.rb
|
318
|
+
- spec/support/higline_test_helpers.rb
|
319
|
+
- spec/support/silence_logging.rb
|
320
|
+
- spec/gather_rspec_coverage.rb
|
315
321
|
- spec/features/backup_spec.rb
|
316
322
|
- spec/features/helper.rb
|
317
|
-
- spec/features/restore_spec.rb
|
318
|
-
- spec/features/support/email_server.rb
|
319
323
|
- spec/features/support/backup_directory.rb
|
320
|
-
- spec/features/support/shared/connection_context.rb
|
321
324
|
- spec/features/support/shared/message_fixtures.rb
|
322
|
-
- spec/support/
|
323
|
-
- spec/support/
|
324
|
-
- spec/
|
325
|
-
- spec/support/shared_examples/account_flagging.rb
|
326
|
-
- spec/fixtures/connection.yml
|
327
|
-
- spec/gather_rspec_coverage.rb
|
325
|
+
- spec/features/support/shared/connection_context.rb
|
326
|
+
- spec/features/support/email_server.rb
|
327
|
+
- spec/features/restore_spec.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
shared_examples "it flags the account as modified" do
|
2
|
-
it "flags that the account has changed" do
|
3
|
-
expect(account[:modified]).to be_truthy
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
shared_examples "it doesn't flag the account as modified" do
|
8
|
-
it "does not flag that the account has changed" do
|
9
|
-
expect(account[:modified]).to be_falsey
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
shared_examples "it flags the account to be deleted" do
|
14
|
-
it "flags that the account is to be deleted" do
|
15
|
-
expect(account[:delete]).to be_truthy
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
shared_examples "it doesn't flag the account to be deleted" do
|
20
|
-
it "does not flags that the account is to be deleted" do
|
21
|
-
expect(account[:delete]).to be_falsey
|
22
|
-
end
|
23
|
-
end
|