imap-backup 6.0.0.rc2 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/imap-backup.gemspec +5 -1
  3. data/lib/cli_coverage.rb +11 -11
  4. data/lib/email/provider/apple_mail.rb +4 -0
  5. data/lib/email/provider/base.rb +6 -0
  6. data/lib/email/provider/purelymail.rb +11 -0
  7. data/lib/email/provider/unknown.rb +2 -0
  8. data/lib/email/provider.rb +5 -0
  9. data/lib/imap/backup/account/connection/backup_folders.rb +27 -0
  10. data/lib/imap/backup/account/connection/client_factory.rb +55 -0
  11. data/lib/imap/backup/account/connection/folder_names.rb +26 -0
  12. data/lib/imap/backup/account/connection.rb +16 -96
  13. data/lib/imap/backup/account/folder.rb +31 -9
  14. data/lib/imap/backup/account.rb +15 -6
  15. data/lib/imap/backup/cli/backup.rb +1 -3
  16. data/lib/imap/backup/cli/helpers.rb +24 -22
  17. data/lib/imap/backup/cli/local.rb +20 -13
  18. data/lib/imap/backup/cli/migrate.rb +4 -10
  19. data/lib/imap/backup/cli/restore.rb +8 -7
  20. data/lib/imap/backup/cli/setup.rb +10 -8
  21. data/lib/imap/backup/cli/stats.rb +78 -0
  22. data/lib/imap/backup/cli/status.rb +2 -2
  23. data/lib/imap/backup/cli/utils.rb +4 -6
  24. data/lib/imap/backup/cli.rb +24 -3
  25. data/lib/imap/backup/configuration.rb +9 -11
  26. data/lib/imap/backup/downloader.rb +75 -31
  27. data/lib/imap/backup/migrator.rb +5 -5
  28. data/lib/imap/backup/sanitizer.rb +3 -2
  29. data/lib/imap/backup/serializer/appender.rb +49 -0
  30. data/lib/imap/backup/serializer/imap.rb +27 -3
  31. data/lib/imap/backup/serializer/mbox.rb +18 -2
  32. data/lib/imap/backup/serializer/message_enumerator.rb +29 -0
  33. data/lib/imap/backup/serializer/unused_name_finder.rb +25 -0
  34. data/lib/imap/backup/serializer.rb +64 -84
  35. data/lib/imap/backup/setup/account/header.rb +81 -0
  36. data/lib/imap/backup/setup/account.rb +28 -91
  37. data/lib/imap/backup/setup/asker.rb +4 -15
  38. data/lib/imap/backup/setup/backup_path.rb +45 -0
  39. data/lib/imap/backup/setup/email.rb +45 -0
  40. data/lib/imap/backup/setup/folder_chooser.rb +3 -3
  41. data/lib/imap/backup/setup/helpers.rb +1 -1
  42. data/lib/imap/backup/setup.rb +7 -6
  43. data/lib/imap/backup/thunderbird/mailbox_exporter.rb +39 -20
  44. data/lib/imap/backup/uploader.rb +46 -8
  45. data/lib/imap/backup/utils.rb +1 -1
  46. data/lib/imap/backup/version.rb +2 -2
  47. data/lib/imap/backup.rb +0 -1
  48. metadata +32 -134
  49. data/spec/features/backup_spec.rb +0 -100
  50. data/spec/features/configuration/minimal_configuration.rb +0 -15
  51. data/spec/features/configuration/missing_configuration.rb +0 -14
  52. data/spec/features/folders_spec.rb +0 -36
  53. data/spec/features/helper.rb +0 -2
  54. data/spec/features/local/list_accounts_spec.rb +0 -12
  55. data/spec/features/local/list_emails_spec.rb +0 -21
  56. data/spec/features/local/list_folders_spec.rb +0 -21
  57. data/spec/features/local/show_an_email_spec.rb +0 -34
  58. data/spec/features/migrate_spec.rb +0 -35
  59. data/spec/features/remote/list_account_folders_spec.rb +0 -16
  60. data/spec/features/restore_spec.rb +0 -162
  61. data/spec/features/status_spec.rb +0 -43
  62. data/spec/features/support/aruba.rb +0 -78
  63. data/spec/features/support/backup_directory.rb +0 -43
  64. data/spec/features/support/email_server.rb +0 -110
  65. data/spec/features/support/shared/connection_context.rb +0 -14
  66. data/spec/features/support/shared/message_fixtures.rb +0 -16
  67. data/spec/fixtures/connection.yml +0 -7
  68. data/spec/spec_helper.rb +0 -15
  69. data/spec/support/fixtures.rb +0 -11
  70. data/spec/support/higline_test_helpers.rb +0 -8
  71. data/spec/support/silence_logging.rb +0 -7
  72. data/spec/unit/email/mboxrd/message_spec.rb +0 -177
  73. data/spec/unit/email/provider/apple_mail_spec.rb +0 -7
  74. data/spec/unit/email/provider/base_spec.rb +0 -11
  75. data/spec/unit/email/provider/fastmail_spec.rb +0 -7
  76. data/spec/unit/email/provider/gmail_spec.rb +0 -7
  77. data/spec/unit/email/provider_spec.rb +0 -27
  78. data/spec/unit/imap/backup/account/connection_spec.rb +0 -433
  79. data/spec/unit/imap/backup/account/folder_spec.rb +0 -261
  80. data/spec/unit/imap/backup/account_spec.rb +0 -246
  81. data/spec/unit/imap/backup/cli/accounts_spec.rb +0 -58
  82. data/spec/unit/imap/backup/cli/backup_spec.rb +0 -19
  83. data/spec/unit/imap/backup/cli/folders_spec.rb +0 -39
  84. data/spec/unit/imap/backup/cli/helpers_spec.rb +0 -87
  85. data/spec/unit/imap/backup/cli/local_spec.rb +0 -100
  86. data/spec/unit/imap/backup/cli/migrate_spec.rb +0 -80
  87. data/spec/unit/imap/backup/cli/restore_spec.rb +0 -67
  88. data/spec/unit/imap/backup/cli/setup_spec.rb +0 -17
  89. data/spec/unit/imap/backup/cli/utils_spec.rb +0 -125
  90. data/spec/unit/imap/backup/cli_spec.rb +0 -93
  91. data/spec/unit/imap/backup/client/apple_mail_spec.rb +0 -9
  92. data/spec/unit/imap/backup/client/default_spec.rb +0 -22
  93. data/spec/unit/imap/backup/configuration_spec.rb +0 -238
  94. data/spec/unit/imap/backup/downloader_spec.rb +0 -96
  95. data/spec/unit/imap/backup/logger_spec.rb +0 -48
  96. data/spec/unit/imap/backup/migrator_spec.rb +0 -58
  97. data/spec/unit/imap/backup/sanitizer_spec.rb +0 -42
  98. data/spec/unit/imap/backup/serializer/directory_spec.rb +0 -37
  99. data/spec/unit/imap/backup/serializer/imap_spec.rb +0 -218
  100. data/spec/unit/imap/backup/serializer/mbox_enumerator_spec.rb +0 -45
  101. data/spec/unit/imap/backup/serializer/mbox_spec.rb +0 -101
  102. data/spec/unit/imap/backup/serializer_spec.rb +0 -296
  103. data/spec/unit/imap/backup/setup/account_spec.rb +0 -461
  104. data/spec/unit/imap/backup/setup/asker_spec.rb +0 -137
  105. data/spec/unit/imap/backup/setup/connection_tester_spec.rb +0 -51
  106. data/spec/unit/imap/backup/setup/folder_chooser_spec.rb +0 -146
  107. data/spec/unit/imap/backup/setup/helpers_spec.rb +0 -15
  108. data/spec/unit/imap/backup/setup_spec.rb +0 -301
  109. data/spec/unit/imap/backup/thunderbird/mailbox_exporter_spec.rb +0 -116
  110. data/spec/unit/imap/backup/uploader_spec.rb +0 -54
  111. data/spec/unit/imap/backup/utils_spec.rb +0 -92
  112. data/spec/unit/retry_on_error_spec.rb +0 -34
@@ -1,92 +0,0 @@
1
- describe Imap::Backup::Utils do
2
- let(:filename) { "foobar" }
3
- let(:stat) { instance_double(File::Stat, mode: mode) }
4
- let(:mode) { 0o777 }
5
- let(:exists) { true }
6
-
7
- before do
8
- allow(File).to receive(:stat) { stat }
9
- allow(File).to receive(:exist?).with(filename) { exists }
10
- end
11
-
12
- describe ".check_permissions" do
13
- let(:requested) { 0o345 }
14
-
15
- context "with existing files" do
16
- [
17
- [0o100, "less than the limit", true],
18
- [0o345, "equal to the limit", true],
19
- [0o777, "over the limit", false]
20
- ].each do |mode, description, success|
21
- context "when permissions are #{description}" do
22
- let(:mode) { mode }
23
-
24
- if success
25
- it "succeeds" do
26
- described_class.check_permissions(filename, requested)
27
- end
28
- else
29
- it "fails" do
30
- message = /Permissions on '.*?' should be .*?, not .*?/
31
- expect do
32
- described_class.check_permissions(filename, requested)
33
- end.to raise_error(RuntimeError, message)
34
- end
35
- end
36
- end
37
- end
38
- end
39
-
40
- context "with non-existent files" do
41
- let(:exists) { false }
42
- let(:mode) { 0o111 }
43
-
44
- it "succeeds" do
45
- described_class.check_permissions(filename, requested)
46
- end
47
- end
48
- end
49
-
50
- describe ".mode" do
51
- context "with existing files" do
52
- let(:mode) { 0o2345 }
53
-
54
- it "is the last 9 bits of the file mode" do
55
- expect(described_class.mode(filename)).to eq(0o345)
56
- end
57
- end
58
-
59
- context "with non-existent files" do
60
- let(:exists) { false }
61
-
62
- it "is nil" do
63
- expect(described_class.mode(filename)).to be_nil
64
- end
65
- end
66
- end
67
-
68
- describe ".make_folder" do
69
- before do
70
- allow(FileUtils).to receive(:mkdir_p)
71
- allow(FileUtils).to receive(:chmod)
72
- end
73
-
74
- it "does nothing if an empty path is supplied" do
75
- expect(FileUtils).to_not receive(:mkdir_p)
76
-
77
- described_class.make_folder("aaa", "", 0o222)
78
- end
79
-
80
- it "creates the path" do
81
- expect(FileUtils).to receive(:mkdir_p).with("/base/path/new/folder")
82
-
83
- described_class.make_folder("/base/path", "new/folder", 0o222)
84
- end
85
-
86
- it "sets permissions on the path" do
87
- expect(FileUtils).to receive(:chmod).with(0o222, "/base/path/new/folder")
88
-
89
- described_class.make_folder("/base/path/new", "folder", 0o222)
90
- end
91
- end
92
- end
@@ -1,34 +0,0 @@
1
- class Retrier
2
- class FooError < StandardError; end
3
-
4
- include RetryOnError
5
-
6
- def do_stuff(errors:, limit:)
7
- calls = 0
8
-
9
- retry_on_error(errors: errors, limit: limit) do
10
- calls += 1
11
- raise FooError if calls < 3
12
-
13
- 42
14
- end
15
- end
16
- end
17
-
18
- RSpec.describe RetryOnError do
19
- describe "#retry_on_error" do
20
- subject { Retrier.new }
21
-
22
- it "retries" do
23
- expect(subject.do_stuff(errors: [Retrier::FooError], limit: 3)).to eq(42)
24
- end
25
-
26
- context "when the block fails more than the limit" do
27
- it "fails" do
28
- expect do
29
- subject.do_stuff(errors: [Retrier::FooError], limit: 1)
30
- end.to raise_error(Retrier::FooError)
31
- end
32
- end
33
- end
34
- end