imap-backup 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +5 -5
- data/README.md +9 -3
- data/Rakefile +0 -8
- data/bin/imap-backup +5 -0
- data/imap-backup.gemspec +1 -6
- data/lib/email/mboxrd/message.rb +1 -1
- data/lib/imap/backup/account/folder.rb +6 -3
- data/lib/imap/backup/configuration/setup.rb +0 -1
- data/lib/imap/backup/configuration/store.rb +0 -1
- data/lib/imap/backup/serializer/mbox.rb +1 -1
- data/lib/imap/backup/version.rb +1 -1
- data/spec/unit/account/connection_spec.rb +7 -6
- data/spec/unit/account/folder_spec.rb +17 -8
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 85975662cee269fb87e3de1150cd3a02c123e729e2d2f4e1a2e4905de477a897
|
4
|
+
data.tar.gz: 06aa1c25d470bc8f38cf78e124d00f90f498e9ba2e803804ebf7a58ce9f81579
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c75aff4a749a5630fe86bca252f676be0338c30c492ce3fdbe654c895143dcd7846ab654733f2aeb3a4316fe4b8f630d3ca0a1db0227c7d06918e7362d17970b
|
7
|
+
data.tar.gz: b3b267870e606d407931ac337c36865aaccf430b1b91ab0a9a3dfe49e1db65ae159ddaeaf2f22041715e6998a8d00db8d76b02dafc6ac0a11dcd91218129a62e
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -24,7 +24,8 @@ $ gem install 'imap-backup'
|
|
24
24
|
|
25
25
|
# Setup
|
26
26
|
|
27
|
-
In order to do backups, you need to add accounts
|
27
|
+
In order to do backups, you need to add accounts via a menu-driven command
|
28
|
+
line program:
|
28
29
|
|
29
30
|
Run:
|
30
31
|
|
@@ -32,9 +33,14 @@ Run:
|
|
32
33
|
$ imap-backup setup
|
33
34
|
```
|
34
35
|
|
35
|
-
|
36
|
+
## Folders
|
36
37
|
|
37
|
-
|
38
|
+
By default, all folders are backed-up. You can override this by choosing
|
39
|
+
specific folders.
|
40
|
+
|
41
|
+
## Configuration file
|
42
|
+
|
43
|
+
`setup` creates ~/.imap-backup directory and configuration file. E.g.:
|
38
44
|
|
39
45
|
```json
|
40
46
|
{
|
data/Rakefile
CHANGED
@@ -7,11 +7,3 @@ task :default => :spec
|
|
7
7
|
RSpec::Core::RakeTask.new do |t|
|
8
8
|
t.pattern = 'spec/**/*_spec.rb'
|
9
9
|
end
|
10
|
-
|
11
|
-
if RUBY_VERSION < '1.9'
|
12
|
-
RSpec::Core::RakeTask.new('spec:coverage') do |t|
|
13
|
-
t.pattern = 'spec/**/*_spec.rb'
|
14
|
-
t.rcov = true
|
15
|
-
t.rcov_opts = ['--exclude', 'spec/,/gems/,vendor/']
|
16
|
-
end
|
17
|
-
end
|
data/bin/imap-backup
CHANGED
data/imap-backup.gemspec
CHANGED
@@ -18,12 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
|
19
19
|
gem.add_runtime_dependency 'rake'
|
20
20
|
gem.add_runtime_dependency 'highline'
|
21
|
-
|
22
|
-
gem.add_runtime_dependency 'mail'
|
23
|
-
else
|
24
|
-
gem.add_runtime_dependency 'mime-types', '~> 2.6'
|
25
|
-
gem.add_runtime_dependency 'mail', '~> 2.6.3'
|
26
|
-
end
|
21
|
+
gem.add_runtime_dependency 'mail'
|
27
22
|
|
28
23
|
gem.add_development_dependency 'codeclimate-test-reporter', '~> 0.4.8'
|
29
24
|
gem.add_development_dependency 'rspec', '>= 3.0.0'
|
data/lib/email/mboxrd/message.rb
CHANGED
@@ -33,9 +33,12 @@ module Imap::Backup
|
|
33
33
|
|
34
34
|
def fetch(uid)
|
35
35
|
imap.examine(name)
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
fetch_data_items = imap.uid_fetch([uid.to_i], REQUESTED_ATTRIBUTES)
|
37
|
+
return nil if fetch_data_items.nil?
|
38
|
+
fetch_data_item = fetch_data_items[0]
|
39
|
+
attributes = fetch_data_item.attr
|
40
|
+
attributes['RFC822'].force_encoding('utf-8')
|
41
|
+
attributes
|
39
42
|
rescue Net::IMAP::NoResponseError => e
|
40
43
|
Imap::Backup.logger.warn "Folder '#{name}' does not exist"
|
41
44
|
nil
|
@@ -46,7 +46,7 @@ module Imap::Backup
|
|
46
46
|
mbox.write mboxrd_message.to_s
|
47
47
|
imap.write uid + "\n"
|
48
48
|
rescue => e
|
49
|
-
Imap::Backup.logger.warn "[#{folder}] failed to save message #{uid}:\n#{body}. #{e}"
|
49
|
+
Imap::Backup.logger.warn "[#{folder}] failed to save message #{uid}:\n#{body}. #{e}:\n#{e.backtrace.join("\n")}"
|
50
50
|
ensure
|
51
51
|
mbox.close if mbox
|
52
52
|
imap.close if imap
|
data/lib/imap/backup/version.rb
CHANGED
@@ -105,10 +105,11 @@ describe Imap::Backup::Account::Connection do
|
|
105
105
|
context '#run_backup' do
|
106
106
|
let(:folder) { double('folder', name: 'folder') }
|
107
107
|
let(:serializer) { double('serializer') }
|
108
|
-
let(:downloader) { double(
|
108
|
+
let(:downloader) { double(Imap::Backup::Downloader, :run => nil) }
|
109
109
|
|
110
110
|
before do
|
111
|
-
allow(Imap::Backup::Downloader).
|
111
|
+
allow(Imap::Backup::Downloader).
|
112
|
+
to receive(:new).with(folder, serializer) { downloader }
|
112
113
|
end
|
113
114
|
|
114
115
|
context 'with supplied backup_folders' do
|
@@ -141,8 +142,8 @@ describe Imap::Backup::Account::Connection do
|
|
141
142
|
|
142
143
|
before { subject.run_backup }
|
143
144
|
|
144
|
-
it 'runs the downloader' do
|
145
|
-
expect(downloader).to have_received(:run)
|
145
|
+
it 'runs the downloader for each folder' do
|
146
|
+
expect(downloader).to have_received(:run).exactly(:once)
|
146
147
|
end
|
147
148
|
end
|
148
149
|
|
@@ -151,8 +152,8 @@ describe Imap::Backup::Account::Connection do
|
|
151
152
|
|
152
153
|
before { subject.run_backup }
|
153
154
|
|
154
|
-
it 'runs the downloader' do
|
155
|
-
expect(downloader).to have_received(:run)
|
155
|
+
it 'runs the downloader for each folder' do
|
156
|
+
expect(downloader).to have_received(:run).exactly(:once)
|
156
157
|
end
|
157
158
|
end
|
158
159
|
|
@@ -30,12 +30,23 @@ describe Imap::Backup::Account::Folder do
|
|
30
30
|
|
31
31
|
context '#fetch' do
|
32
32
|
let(:message_body) { double('the body', :force_encoding => nil) }
|
33
|
-
let(:
|
33
|
+
let(:attributes) { {'RFC822' => message_body, 'other' => 'xxx'} }
|
34
|
+
let(:fetch_data_item) do
|
35
|
+
instance_double(Net::IMAP::FetchData, attr: attributes)
|
36
|
+
end
|
34
37
|
|
35
|
-
before { allow(imap).to receive(:uid_fetch)
|
38
|
+
before { allow(imap).to receive(:uid_fetch) { [fetch_data_item] } }
|
36
39
|
|
37
40
|
it 'returns the message' do
|
38
|
-
expect(subject.fetch(123)).to eq(
|
41
|
+
expect(subject.fetch(123)).to eq(attributes)
|
42
|
+
end
|
43
|
+
|
44
|
+
context "if the server responds with nothing" do
|
45
|
+
before { allow(imap).to receive(:uid_fetch) { nil } }
|
46
|
+
|
47
|
+
it 'is nil' do
|
48
|
+
expect(subject.fetch(123)).to be_nil
|
49
|
+
end
|
39
50
|
end
|
40
51
|
|
41
52
|
context "if the mailbox doesn't exist" do
|
@@ -46,12 +57,10 @@ describe Imap::Backup::Account::Folder do
|
|
46
57
|
end
|
47
58
|
end
|
48
59
|
|
49
|
-
|
50
|
-
|
51
|
-
subject.fetch(123)
|
60
|
+
it 'sets the encoding on the message' do
|
61
|
+
subject.fetch(123)
|
52
62
|
|
53
|
-
|
54
|
-
end
|
63
|
+
expect(message_body).to have_received(:force_encoding).with('utf-8')
|
55
64
|
end
|
56
65
|
end
|
57
66
|
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: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Yates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
170
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.6
|
171
|
+
rubygems_version: 2.7.6
|
172
172
|
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: Backup GMail (or other IMAP) accounts to disk
|