imap-backup 5.1.0 → 5.2.0

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
  SHA256:
3
- metadata.gz: 59babb556b2f47a07590debff15dcd5456f1e61454c3aba2e504610ce4322647
4
- data.tar.gz: 89909077444746e44fe3955070df6b590942da0d44da58c9b08b282e694000d5
3
+ metadata.gz: 164962561883b82372b32826843681c6a802e88982f4906778758a073e1479d8
4
+ data.tar.gz: 8a71ad18952f675f61bc6342a3a9a60c2fc71797444142c2af5f98ef18ac13e9
5
5
  SHA512:
6
- metadata.gz: ea00bb55bb853cef73ec12171a4bdde9b0b5ef88a914065bbe307f48712db3329e8c8f1712cfa48b4a49102d20fb38cc465dc463c2d3ea9e0caba000a184766b
7
- data.tar.gz: 24d368c209c11db4ae7f05a93b9cf4e0435b65eef0cffd7e58f8c669e634ca735aa3187b6a6506b7b10ba3bec961d3aa9d7387df40d4880f1bed73df7f24bbb9
6
+ metadata.gz: 600ff4b72954cecfb2037b9ef12b16029248a6c6e27b2b801661b5c746264a8aed7a99aa689cbeecc8e89f571b9f4c26350669e582bc087a518981bceb677141
7
+ data.tar.gz: b706026f0b8231f10dfbb0a0c39162ccdf6a8671c513b6cbf637352dcd8d99987a3f93d2b523db7f4a8e3ff7178877dc3d84c1ad506245a9773330abea2a792f
data/README.md CHANGED
@@ -1,7 +1,3 @@
1
- [![Build Status](https://circleci.com/gh/joeyates/imap-backup.svg?style=svg)][Continuous Integration]
2
- [![Source Analysis](https://codeclimate.com/github/joeyates/imap-backup/badges/gpa.svg)](https://codeclimate.com/github/joeyates/imap-backup)
3
- [![Test Coverage](https://codeclimate.com/github/joeyates/imap-backup/badges/coverage.svg)](https://codeclimate.com/github/joeyates/imap-backup/coverage)
4
-
5
1
  # imap-backup
6
2
 
7
3
  *Backup GMail (or other IMAP) accounts to disk*
@@ -9,12 +5,10 @@
9
5
  * [Source Code]
10
6
  * [API documentation]
11
7
  * [Rubygem]
12
- * [Continuous Integration]
13
8
 
14
9
  [Source Code]: https://github.com/joeyates/imap-backup "Source code at GitHub"
15
10
  [API documentation]: http://rubydoc.info/gems/imap-backup/frames "RDoc API Documentation at Rubydoc.info"
16
11
  [Rubygem]: http://rubygems.org/gems/imap-backup "Ruby gem at rubygems.org"
17
- [Continuous Integration]: https://circleci.com/gh/joeyates/imap-backup "Build status by CirceCI"
18
12
 
19
13
  # Installation
20
14
 
data/bin/imap-backup CHANGED
@@ -1,6 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  $LOAD_PATH.unshift(File.expand_path("../lib/", __dir__))
4
+
5
+ require "cli_coverage"
6
+ CliCoverage.conditionally_activate
7
+
4
8
  require "imap/backup/cli"
5
9
  require "imap/backup/logger"
6
10
 
data/imap-backup.gemspec CHANGED
@@ -30,14 +30,8 @@ Gem::Specification.new do |gem|
30
30
  gem.add_runtime_dependency "thunderbird", ">= 0.0.0"
31
31
 
32
32
  gem.add_development_dependency "aruba", ">= 0.0.0"
33
- gem.add_development_dependency "codeclimate-test-reporter", "~> 0.4.8"
34
- if RUBY_ENGINE == "jruby"
35
- gem.add_development_dependency "pry-debugger-jruby"
36
- else
37
- gem.add_development_dependency "pry-byebug"
38
- end
33
+ gem.add_development_dependency "pry-byebug"
39
34
  gem.add_development_dependency "rspec", ">= 3.0.0"
40
- gem.add_development_dependency "rspec_junit_formatter"
41
35
  gem.add_development_dependency "rubocop-rspec"
42
36
  gem.add_development_dependency "simplecov"
43
37
  end
@@ -0,0 +1,18 @@
1
+ class CliCoverage
2
+ def self.conditionally_activate
3
+ if ENV["COVERAGE"]
4
+ require "simplecov"
5
+
6
+ # Collect coverage separately
7
+ SimpleCov.command_name "#{ENV['COVERAGE']} coverage"
8
+
9
+ # Silence output
10
+ SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter
11
+ SimpleCov.print_error_status = false
12
+
13
+ # Ensure SimpleCov doesn't filter out all out code
14
+ project_root = File.expand_path("..", __dir__)
15
+ SimpleCov.root project_root
16
+ end
17
+ end
18
+ end
@@ -68,22 +68,6 @@ module Imap::Backup
68
68
  []
69
69
  end
70
70
 
71
- def fetch(uid)
72
- examine
73
- fetch_data_items =
74
- retry_on_error(errors: UID_FETCH_RETRY_CLASSES) do
75
- client.uid_fetch([uid.to_i], [BODY_ATTRIBUTE])
76
- end
77
- return nil if fetch_data_items.nil?
78
-
79
- fetch_data_item = fetch_data_items[0]
80
- attributes = fetch_data_item.attr
81
-
82
- attributes[BODY_ATTRIBUTE]
83
- rescue FolderNotFound
84
- nil
85
- end
86
-
87
71
  def fetch_multi(uids)
88
72
  examine
89
73
  fetch_data_items =
@@ -100,7 +100,7 @@ module Imap::Backup
100
100
  aliases: ["-s"]
101
101
  )
102
102
  def migrate(source_email, destination_email)
103
- Migrate.new(source_email, destination_email, symbolized(options)).run
103
+ Migrate.new(source_email, destination_email, **symbolized(options)).run
104
104
  end
105
105
 
106
106
  desc "remote SUBCOMMAND [OPTIONS]", "View info about online accounts"
@@ -71,8 +71,8 @@ module Imap::Backup
71
71
  digit = 0
72
72
  new_name = nil
73
73
  loop do
74
- extra = digit.zero? ? "" : ".#{digit}"
75
- new_name = "#{folder}.#{store.uid_validity}#{extra}"
74
+ extra = digit.zero? ? "" : "-#{digit}"
75
+ new_name = "#{folder}-#{store.uid_validity}#{extra}"
76
76
  test_store = Serializer::MboxStore.new(path, new_name)
77
77
  break if !test_store.exist?
78
78
 
@@ -2,7 +2,7 @@ module Imap; end
2
2
 
3
3
  module Imap::Backup
4
4
  MAJOR = 5
5
- MINOR = 1
5
+ MINOR = 2
6
6
  REVISION = 0
7
7
  PRE = nil
8
8
  VERSION = [MAJOR, MINOR, REVISION, PRE].compact.map(&:to_s).join(".")
@@ -60,7 +60,7 @@ RSpec.describe "backup", type: :aruba, docker: true do
60
60
  connection.disconnect
61
61
  server_rename_folder folder, new_name
62
62
  end
63
- let(:renamed_folder) { "#{folder}.#{original_folder_uid_validity}" }
63
+ let(:renamed_folder) { "#{folder}-#{original_folder_uid_validity}" }
64
64
 
65
65
  after do
66
66
  server_delete_folder new_name
@@ -83,7 +83,7 @@ RSpec.describe "backup", type: :aruba, docker: true do
83
83
  end
84
84
 
85
85
  it "moves the old backup to a uniquely named directory" do
86
- renamed = "#{folder}.#{original_folder_uid_validity}.1"
86
+ renamed = "#{folder}-#{original_folder_uid_validity}-1"
87
87
  expect(mbox_content(renamed)).to eq(message_as_mbox_entry(msg3))
88
88
  end
89
89
  end
@@ -94,7 +94,7 @@ RSpec.describe "restore", type: :aruba, docker: true do
94
94
  end
95
95
 
96
96
  context "when the folder has content" do
97
- let(:new_folder) { "#{folder}.#{uid_validity}" }
97
+ let(:new_folder) { "#{folder}-#{uid_validity}" }
98
98
  let(:cleanup) do
99
99
  server_delete_folder new_folder
100
100
  super()
@@ -67,6 +67,10 @@ RSpec.configure do |config|
67
67
  FileUtils.rm_rf "./tmp/home"
68
68
  end
69
69
 
70
+ config.before(:example, type: :aruba) do
71
+ set_environment_variable("COVERAGE", "aruba")
72
+ end
73
+
70
74
  config.after do
71
75
  FileUtils.rm_rf "./tmp/home"
72
76
  end
data/spec/spec_helper.rb CHANGED
@@ -1,17 +1,13 @@
1
- require "codeclimate-test-reporter"
2
1
  require "rspec"
3
2
 
4
- CodeClimate::TestReporter.start
5
-
6
3
  $LOAD_PATH << File.expand_path("../lib", __dir__)
7
4
 
8
5
  support_glob = File.join(__dir__, "support", "**", "*.rb")
9
6
  Dir[support_glob].sort.each { |f| require f }
10
7
 
11
8
  require "simplecov"
12
- SimpleCov.start do
13
- add_filter "/spec/"
14
- end
9
+
10
+ SimpleCov.command_name "RSpec tests"
15
11
 
16
12
  require "imap/backup"
17
13
  require "imap/backup/cli"
@@ -66,24 +66,24 @@ describe Imap::Backup::Account::Folder do
66
66
  end
67
67
  end
68
68
 
69
- describe "#fetch" do
69
+ describe "#fetch_multi" do
70
70
  let(:message_body) { instance_double(String, force_encoding: nil) }
71
- let(:attributes) { {"BODY[]" => message_body, "other" => "xxx"} }
71
+ let(:attributes) { {"UID" => "uid", "BODY[]" => message_body, "other" => "xxx"} }
72
72
  let(:fetch_data_item) do
73
73
  instance_double(Net::IMAP::FetchData, attr: attributes)
74
74
  end
75
75
 
76
76
  before { allow(client).to receive(:uid_fetch) { [fetch_data_item] } }
77
77
 
78
- it "returns the message" do
79
- expect(subject.fetch(123)).to eq(message_body)
78
+ it "returns the uid and message" do
79
+ expect(subject.fetch_multi([123])).to eq([{uid: "uid", body: message_body}])
80
80
  end
81
81
 
82
82
  context "when the server responds with nothing" do
83
83
  before { allow(client).to receive(:uid_fetch) { nil } }
84
84
 
85
85
  it "is nil" do
86
- expect(subject.fetch(123)).to be_nil
86
+ expect(subject.fetch_multi([123])).to be_nil
87
87
  end
88
88
  end
89
89
 
@@ -94,15 +94,7 @@ describe Imap::Backup::Account::Folder do
94
94
  end
95
95
 
96
96
  it "is nil" do
97
- expect(subject.fetch(123)).to be_nil
98
- end
99
- end
100
-
101
- context "when the response doesn't include 'BODY[]'" do
102
- let(:attributes) { {} }
103
-
104
- it "is nil" do
105
- expect(subject.fetch(123)).to be_nil
97
+ expect(subject.fetch_multi([123])).to be_nil
106
98
  end
107
99
  end
108
100
 
@@ -113,13 +105,13 @@ describe Imap::Backup::Account::Folder do
113
105
  end
114
106
 
115
107
  it "retries" do
116
- subject.fetch(123)
108
+ subject.fetch_multi([123])
117
109
 
118
110
  expect(client).to have_received(:uid_fetch).twice
119
111
  end
120
112
 
121
113
  it "succeeds" do
122
- subject.fetch(123)
114
+ subject.fetch_multi([123])
123
115
  end
124
116
  end
125
117
  end
@@ -34,8 +34,8 @@ describe Imap::Backup::Downloader do
34
34
 
35
35
  context "with failed fetches" do
36
36
  specify "are skipped" do
37
- allow(folder).to receive(:fetch).with("333") { nil }
38
- expect(serializer).to_not receive(:save).with("333", anything)
37
+ allow(folder).to receive(:fetch_multi) { nil }
38
+ expect(serializer).to_not receive(:save)
39
39
 
40
40
  subject.run
41
41
  end
@@ -39,7 +39,7 @@ module Imap::Backup
39
39
  expect(described_class.logger.level).to eq(::Logger::Severity::ERROR)
40
40
  end
41
41
 
42
- it "sets the Net::IMAP debug flag" do
42
+ it "doesn't set the Net::IMAP debug flag" do
43
43
  expect(Net::IMAP.debug).to be_a(FalseClass)
44
44
  end
45
45
  end
@@ -132,13 +132,13 @@ describe Imap::Backup::Serializer::Mbox do
132
132
 
133
133
  context "when adding the uid validity does not cause a name clash" do
134
134
  it "renames the store, adding the existing uid validity" do
135
- expect(store).to receive(:rename).with("folder.bbb")
135
+ expect(store).to receive(:rename).with("folder-bbb")
136
136
 
137
137
  subject.apply_uid_validity("aaa")
138
138
  end
139
139
 
140
140
  it "returns the new name" do
141
- expect(subject.apply_uid_validity("aaa")).to eq("folder.bbb")
141
+ expect(subject.apply_uid_validity("aaa")).to eq("folder-bbb")
142
142
  end
143
143
  end
144
144
 
@@ -146,13 +146,13 @@ describe Imap::Backup::Serializer::Mbox do
146
146
  let(:exists) { true }
147
147
 
148
148
  it "renames the store, adding the existing uid validity and a digit" do
149
- expect(store).to receive(:rename).with("folder.bbb.1")
149
+ expect(store).to receive(:rename).with("folder-bbb-1")
150
150
 
151
151
  subject.apply_uid_validity("aaa")
152
152
  end
153
153
 
154
154
  it "returns the new name" do
155
- expect(subject.apply_uid_validity("aaa")).to eq("folder.bbb.1")
155
+ expect(subject.apply_uid_validity("aaa")).to eq("folder-bbb-1")
156
156
  end
157
157
  end
158
158
  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: 5.1.0
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Yates
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-12 00:00:00.000000000 Z
11
+ date: 2022-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -108,20 +108,6 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.0.0
111
- - !ruby/object:Gem::Dependency
112
- name: codeclimate-test-reporter
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: 0.4.8
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: 0.4.8
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: pry-byebug
127
113
  requirement: !ruby/object:Gem::Requirement
@@ -150,20 +136,6 @@ dependencies:
150
136
  - - ">="
151
137
  - !ruby/object:Gem::Version
152
138
  version: 3.0.0
153
- - !ruby/object:Gem::Dependency
154
- name: rspec_junit_formatter
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
139
  - !ruby/object:Gem::Dependency
168
140
  name: rubocop-rspec
169
141
  requirement: !ruby/object:Gem::Requirement
@@ -207,6 +179,7 @@ files:
207
179
  - docs/restore.md
208
180
  - docs/setup.md
209
181
  - imap-backup.gemspec
182
+ - lib/cli_coverage.rb
210
183
  - lib/email/mboxrd/message.rb
211
184
  - lib/email/provider.rb
212
185
  - lib/email/provider/apple_mail.rb