imap-backup 4.0.0 → 4.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -49
  3. data/docs/development.md +53 -0
  4. data/docs/restore.md +17 -0
  5. data/imap-backup.gemspec +4 -7
  6. data/lib/email/mboxrd/message.rb +6 -2
  7. data/lib/email/provider/apple_mail.rb +7 -0
  8. data/lib/email/provider/default.rb +12 -0
  9. data/lib/email/provider/fastmail.rb +7 -0
  10. data/lib/email/provider/gmail.rb +7 -0
  11. data/lib/email/provider.rb +16 -26
  12. data/lib/imap/backup/account/connection.rb +19 -29
  13. data/lib/imap/backup/account/folder.rb +9 -10
  14. data/lib/imap/backup/cli/helpers.rb +14 -1
  15. data/lib/imap/backup/cli/local.rb +22 -28
  16. data/lib/imap/backup/cli/setup.rb +1 -1
  17. data/lib/imap/backup/cli/utils.rb +98 -0
  18. data/lib/imap/backup/cli.rb +5 -1
  19. data/lib/imap/backup/client/apple_mail.rb +11 -0
  20. data/lib/imap/backup/client/default.rb +51 -0
  21. data/lib/imap/backup/configuration/account.rb +3 -1
  22. data/lib/imap/backup/configuration/connection_tester.rb +1 -1
  23. data/lib/imap/backup/configuration/store.rb +10 -5
  24. data/lib/imap/backup/downloader.rb +3 -4
  25. data/lib/imap/backup/serializer/mbox.rb +5 -0
  26. data/lib/imap/backup/serializer/mbox_store.rb +8 -8
  27. data/lib/imap/backup/thunderbird/mailbox_exporter.rb +58 -0
  28. data/lib/imap/backup/version.rb +1 -1
  29. data/lib/imap/backup.rb +1 -0
  30. data/lib/thunderbird/install.rb +16 -0
  31. data/lib/thunderbird/local_folder.rb +65 -0
  32. data/lib/thunderbird/profile.rb +30 -0
  33. data/lib/thunderbird/profiles.rb +71 -0
  34. data/lib/thunderbird/subdirectory.rb +96 -0
  35. data/lib/thunderbird/subdirectory_placeholder.rb +21 -0
  36. data/lib/thunderbird.rb +14 -0
  37. data/spec/features/restore_spec.rb +1 -1
  38. data/spec/features/support/email_server.rb +2 -2
  39. data/spec/spec_helper.rb +1 -0
  40. data/spec/unit/email/provider/apple_mail_spec.rb +7 -0
  41. data/spec/unit/email/provider/default_spec.rb +17 -0
  42. data/spec/unit/email/provider/fastmail_spec.rb +7 -0
  43. data/spec/unit/email/provider/gmail_spec.rb +7 -0
  44. data/spec/unit/email/provider_spec.rb +12 -25
  45. data/spec/unit/imap/backup/account/connection_spec.rb +26 -51
  46. data/spec/unit/imap/backup/account/folder_spec.rb +22 -22
  47. data/spec/unit/imap/backup/cli/local_spec.rb +70 -0
  48. data/spec/unit/imap/backup/cli/utils_spec.rb +50 -0
  49. data/spec/unit/imap/backup/client/default_spec.rb +22 -0
  50. data/spec/unit/imap/backup/configuration/connection_tester_spec.rb +3 -3
  51. data/spec/unit/imap/backup/configuration/store_spec.rb +25 -12
  52. data/spec/unit/imap/backup/downloader_spec.rb +1 -2
  53. metadata +71 -28
  54. data/docs/docker-imap.md +0 -18
@@ -1,7 +1,7 @@
1
1
  describe Imap::Backup::Configuration::ConnectionTester do
2
2
  describe ".test" do
3
3
  let(:connection) do
4
- instance_double(Imap::Backup::Account::Connection, imap: nil)
4
+ instance_double(Imap::Backup::Account::Connection, client: nil)
5
5
  end
6
6
 
7
7
  before do
@@ -10,7 +10,7 @@ describe Imap::Backup::Configuration::ConnectionTester do
10
10
 
11
11
  describe "call" do
12
12
  it "tries to connect" do
13
- expect(connection).to receive(:imap)
13
+ expect(connection).to receive(:client)
14
14
 
15
15
  subject.test("foo")
16
16
  end
@@ -24,7 +24,7 @@ describe Imap::Backup::Configuration::ConnectionTester do
24
24
 
25
25
  describe "failure" do
26
26
  before do
27
- allow(connection).to receive(:imap).and_raise(error)
27
+ allow(connection).to receive(:client).and_raise(error)
28
28
  end
29
29
 
30
30
  context "with no connection" do
@@ -1,4 +1,5 @@
1
1
  require "json"
2
+ require "os"
2
3
 
3
4
  # rubocop:disable RSpec/PredicateMatcher
4
5
 
@@ -189,10 +190,16 @@ describe Imap::Backup::Configuration::Store do
189
190
  end
190
191
 
191
192
  context "when file permissions are too open" do
192
- it "sets them to 0600" do
193
- expect(FileUtils).to receive(:chmod).with(0o600, file_path)
193
+ context "when on UNIX" do
194
+ before do
195
+ allow(OS).to receive(:windows?) { false }
196
+ end
194
197
 
195
- subject.save
198
+ it "sets them to 0600" do
199
+ expect(FileUtils).to receive(:chmod).with(0o600, file_path)
200
+
201
+ subject.save
202
+ end
196
203
  end
197
204
  end
198
205
 
@@ -206,18 +213,24 @@ describe Imap::Backup::Configuration::Store do
206
213
  end
207
214
  end
208
215
 
209
- context "when the config file permissions are too lax" do
210
- let(:file_exists) { true }
211
-
216
+ context "when on UNIX" do
212
217
  before do
213
- allow(Imap::Backup::Utils).to receive(:check_permissions).
214
- with(file_path, 0o600).and_raise("Error")
218
+ allow(OS).to receive(:windows?) { false }
215
219
  end
216
220
 
217
- it "fails" do
218
- expect do
219
- subject.save
220
- end.to raise_error(RuntimeError, "Error")
221
+ context "when the config file permissions are too lax" do
222
+ let(:file_exists) { true }
223
+
224
+ before do
225
+ allow(Imap::Backup::Utils).to receive(:check_permissions).
226
+ with(file_path, 0o600).and_raise("Error")
227
+ end
228
+
229
+ it "fails" do
230
+ expect do
231
+ subject.save
232
+ end.to raise_error(RuntimeError, "Error")
233
+ end
221
234
  end
222
235
  end
223
236
  end
@@ -3,11 +3,10 @@ describe Imap::Backup::Downloader do
3
3
  subject { described_class.new(folder, serializer) }
4
4
 
5
5
  let(:body) { "blah" }
6
- let(:message) { {"RFC822" => body} }
7
6
  let(:folder) do
8
7
  instance_double(
9
8
  Imap::Backup::Account::Folder,
10
- fetch: message,
9
+ fetch: body,
11
10
  name: "folder",
12
11
  uids: folder_uids
13
12
  )
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.0
4
+ version: 4.0.4
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-11-22 00:00:00.000000000 Z
11
+ date: 2021-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: os
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -161,12 +175,16 @@ files:
161
175
  - LICENSE
162
176
  - README.md
163
177
  - bin/imap-backup
164
- - docs/docker-imap.md
178
+ - docs/development.md
165
179
  - docs/restore.md
166
180
  - docs/setup.md
167
181
  - imap-backup.gemspec
168
182
  - lib/email/mboxrd/message.rb
169
183
  - lib/email/provider.rb
184
+ - lib/email/provider/apple_mail.rb
185
+ - lib/email/provider/default.rb
186
+ - lib/email/provider/fastmail.rb
187
+ - lib/email/provider/gmail.rb
170
188
  - lib/imap/backup.rb
171
189
  - lib/imap/backup/account/connection.rb
172
190
  - lib/imap/backup/account/folder.rb
@@ -178,6 +196,9 @@ files:
178
196
  - lib/imap/backup/cli/restore.rb
179
197
  - lib/imap/backup/cli/setup.rb
180
198
  - lib/imap/backup/cli/status.rb
199
+ - lib/imap/backup/cli/utils.rb
200
+ - lib/imap/backup/client/apple_mail.rb
201
+ - lib/imap/backup/client/default.rb
181
202
  - lib/imap/backup/configuration/account.rb
182
203
  - lib/imap/backup/configuration/asker.rb
183
204
  - lib/imap/backup/configuration/connection_tester.rb
@@ -190,10 +211,18 @@ files:
190
211
  - lib/imap/backup/serializer/mbox.rb
191
212
  - lib/imap/backup/serializer/mbox_enumerator.rb
192
213
  - lib/imap/backup/serializer/mbox_store.rb
214
+ - lib/imap/backup/thunderbird/mailbox_exporter.rb
193
215
  - lib/imap/backup/uploader.rb
194
216
  - lib/imap/backup/utils.rb
195
217
  - lib/imap/backup/version.rb
196
218
  - lib/retry_on_error.rb
219
+ - lib/thunderbird.rb
220
+ - lib/thunderbird/install.rb
221
+ - lib/thunderbird/local_folder.rb
222
+ - lib/thunderbird/profile.rb
223
+ - lib/thunderbird/profiles.rb
224
+ - lib/thunderbird/subdirectory.rb
225
+ - lib/thunderbird/subdirectory_placeholder.rb
197
226
  - spec/features/backup_spec.rb
198
227
  - spec/features/helper.rb
199
228
  - spec/features/restore_spec.rb
@@ -209,9 +238,16 @@ files:
209
238
  - spec/support/shared_examples/account_flagging.rb
210
239
  - spec/support/silence_logging.rb
211
240
  - spec/unit/email/mboxrd/message_spec.rb
241
+ - spec/unit/email/provider/apple_mail_spec.rb
242
+ - spec/unit/email/provider/default_spec.rb
243
+ - spec/unit/email/provider/fastmail_spec.rb
244
+ - spec/unit/email/provider/gmail_spec.rb
212
245
  - spec/unit/email/provider_spec.rb
213
246
  - spec/unit/imap/backup/account/connection_spec.rb
214
247
  - spec/unit/imap/backup/account/folder_spec.rb
248
+ - spec/unit/imap/backup/cli/local_spec.rb
249
+ - spec/unit/imap/backup/cli/utils_spec.rb
250
+ - spec/unit/imap/backup/client/default_spec.rb
215
251
  - spec/unit/imap/backup/configuration/account_spec.rb
216
252
  - spec/unit/imap/backup/configuration/asker_spec.rb
217
253
  - spec/unit/imap/backup/configuration/connection_tester_spec.rb
@@ -245,40 +281,47 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
281
  - !ruby/object:Gem::Version
246
282
  version: '0'
247
283
  requirements: []
248
- rubygems_version: 3.1.4
284
+ rubygems_version: 3.1.2
249
285
  signing_key:
250
286
  specification_version: 4
251
287
  summary: Backup GMail (or other IMAP) accounts to disk
252
288
  test_files:
253
- - spec/features/backup_spec.rb
254
- - spec/features/helper.rb
255
- - spec/features/restore_spec.rb
256
- - spec/features/support/backup_directory.rb
257
- - spec/features/support/email_server.rb
258
- - spec/features/support/shared/connection_context.rb
259
- - spec/features/support/shared/message_fixtures.rb
260
- - spec/fixtures/connection.yml
261
- - spec/gather_rspec_coverage.rb
262
289
  - spec/spec_helper.rb
263
- - spec/support/fixtures.rb
264
- - spec/support/higline_test_helpers.rb
265
- - spec/support/shared_examples/account_flagging.rb
266
- - spec/support/silence_logging.rb
267
- - spec/unit/email/mboxrd/message_spec.rb
290
+ - spec/fixtures/connection.yml
291
+ - spec/unit/email/provider/gmail_spec.rb
292
+ - spec/unit/email/provider/apple_mail_spec.rb
293
+ - spec/unit/email/provider/default_spec.rb
294
+ - spec/unit/email/provider/fastmail_spec.rb
268
295
  - spec/unit/email/provider_spec.rb
269
- - spec/unit/imap/backup/account/connection_spec.rb
270
- - spec/unit/imap/backup/account/folder_spec.rb
271
- - spec/unit/imap/backup/configuration/account_spec.rb
272
- - spec/unit/imap/backup/configuration/asker_spec.rb
296
+ - spec/unit/email/mboxrd/message_spec.rb
297
+ - spec/unit/imap/backup_spec.rb
298
+ - spec/unit/imap/backup/cli/utils_spec.rb
299
+ - spec/unit/imap/backup/cli/local_spec.rb
300
+ - spec/unit/imap/backup/utils_spec.rb
301
+ - spec/unit/imap/backup/client/default_spec.rb
302
+ - spec/unit/imap/backup/downloader_spec.rb
303
+ - spec/unit/imap/backup/configuration/store_spec.rb
273
304
  - spec/unit/imap/backup/configuration/connection_tester_spec.rb
305
+ - spec/unit/imap/backup/configuration/asker_spec.rb
306
+ - spec/unit/imap/backup/configuration/setup_spec.rb
274
307
  - spec/unit/imap/backup/configuration/folder_chooser_spec.rb
308
+ - spec/unit/imap/backup/configuration/account_spec.rb
275
309
  - spec/unit/imap/backup/configuration/list_spec.rb
276
- - spec/unit/imap/backup/configuration/setup_spec.rb
277
- - spec/unit/imap/backup/configuration/store_spec.rb
278
- - spec/unit/imap/backup/downloader_spec.rb
279
- - spec/unit/imap/backup/serializer/mbox_enumerator_spec.rb
310
+ - spec/unit/imap/backup/account/folder_spec.rb
311
+ - spec/unit/imap/backup/account/connection_spec.rb
280
312
  - spec/unit/imap/backup/serializer/mbox_spec.rb
281
313
  - spec/unit/imap/backup/serializer/mbox_store_spec.rb
314
+ - spec/unit/imap/backup/serializer/mbox_enumerator_spec.rb
282
315
  - spec/unit/imap/backup/uploader_spec.rb
283
- - spec/unit/imap/backup/utils_spec.rb
284
- - spec/unit/imap/backup_spec.rb
316
+ - spec/support/fixtures.rb
317
+ - spec/support/shared_examples/account_flagging.rb
318
+ - spec/support/higline_test_helpers.rb
319
+ - spec/support/silence_logging.rb
320
+ - spec/gather_rspec_coverage.rb
321
+ - spec/features/backup_spec.rb
322
+ - spec/features/helper.rb
323
+ - spec/features/support/backup_directory.rb
324
+ - spec/features/support/shared/message_fixtures.rb
325
+ - spec/features/support/shared/connection_context.rb
326
+ - spec/features/support/email_server.rb
327
+ - spec/features/restore_spec.rb
data/docs/docker-imap.md DELETED
@@ -1,18 +0,0 @@
1
- # Access Docker imap server
2
-
3
- ```ruby
4
- require "net/imap"
5
-
6
- imap = Net::IMAP.new("localhost", {port: 8993, ssl: {verify_mode: 0}})
7
- username = "address@example.org"
8
- imap.login(username, "pass")
9
-
10
- message = "From: #{username}\nSubject: Some Subject\n\nHello!\n"
11
- response = imap.append("INBOX", message, nil, nil)
12
-
13
- imap.examine("INBOX")
14
- uids = imap.uid_search(["ALL"]).sort
15
-
16
- REQUESTED_ATTRIBUTES = ["RFC822", "FLAGS", "INTERNALDATE"].freeze
17
- fetch_data_items = imap.uid_fetch(uids, REQUESTED_ATTRIBUTES)
18
- ```