imap-backup 1.0.12 → 1.0.13
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/README.md +1 -1
- data/lib/email/mboxrd/message.rb +5 -1
- data/lib/imap/backup/version.rb +1 -1
- data/spec/unit/downloader_spec.rb +24 -62
- data/spec/unit/email/mboxrd/message_spec.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03ba4f6a03ae0efc265699ae27662d4089867f60
|
4
|
+
data.tar.gz: 645ee02996bcf94bddc4d890ce6d22c248584fb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd1aea391344bc6a3d66d2748f4de0f8400363e5bfdb747d440aacbd1cc1c67b145ee3025431afaf233e6cab69ec14e84448634c0ba87caaf20f42384fa16847
|
7
|
+
data.tar.gz: d891fc0666d94a25ee6c9f201944b7f29eea73742e81c6ce44f8e87b44568f1a8a2214eeeef7bff6c977ee79d9be2b591e46592760f79d9690b56d2ed622d34f
|
data/README.md
CHANGED
data/lib/email/mboxrd/message.rb
CHANGED
data/lib/imap/backup/version.rb
CHANGED
@@ -2,76 +2,38 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Imap::Backup::Downloader do
|
5
|
-
|
6
|
-
let(:
|
7
|
-
let(:stat) { double('File::Stat', :mode => 0700) }
|
8
|
-
let(:message) do
|
9
|
-
{
|
10
|
-
'RFC822' => 'the body',
|
11
|
-
'other' => 'xxx'
|
12
|
-
}
|
13
|
-
end
|
5
|
+
describe '#run' do
|
6
|
+
let(:message) { 'message' }
|
14
7
|
let(:folder) { double('Imap::Backup::Account::Folder', :fetch => message) }
|
15
|
-
let(:
|
16
|
-
|
17
|
-
|
18
|
-
:prepare => nil,
|
19
|
-
:exist? => true,
|
20
|
-
:uids => [],
|
21
|
-
:save => nil,
|
22
|
-
)
|
23
|
-
end
|
24
|
-
|
25
|
-
before { allow(File).to receive(:stat).with(local_path).and_return(stat) }
|
8
|
+
let(:folder_uids) { ['111', '222', '333'] }
|
9
|
+
let(:serializer) { double('Imap::Backup::Serializer', :save => nil) }
|
10
|
+
let(:serializer_uids) { ['222'] }
|
26
11
|
|
27
12
|
subject { described_class.new(folder, serializer) }
|
28
13
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
14
|
+
before do
|
15
|
+
allow(folder).to receive(:uids).and_return(folder_uids)
|
16
|
+
allow(serializer).to receive(:uids).and_return(serializer_uids)
|
17
|
+
allow(folder).to receive(:fetch).with('333').and_return(nil)
|
18
|
+
subject.run
|
19
|
+
end
|
33
20
|
|
34
|
-
|
21
|
+
context '#run' do
|
22
|
+
context 'fetched messages' do
|
23
|
+
it 'are saved' do
|
24
|
+
expect(serializer).to have_received(:save).with('111', message)
|
35
25
|
end
|
26
|
+
end
|
36
27
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
it 'skips failed fetches' do
|
43
|
-
allow(folder).to receive(:fetch).with('999').and_return(nil)
|
44
|
-
|
45
|
-
subject.run
|
46
|
-
|
47
|
-
expect(serializer).to_not have_received(:save).with('999', anything)
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'to download' do
|
51
|
-
before :each do
|
52
|
-
allow(serializer).to receive(:exist?) do |uid|
|
53
|
-
if uid == '123'
|
54
|
-
true
|
55
|
-
else
|
56
|
-
false
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'requests messages' do
|
62
|
-
subject.run
|
63
|
-
|
64
|
-
expect(folder).to have_received(:fetch).with('999')
|
65
|
-
expect(folder).to have_received(:fetch).with('1234')
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'saves messages' do
|
69
|
-
subject.run
|
28
|
+
context 'messages which are already present' do
|
29
|
+
specify 'are skipped' do
|
30
|
+
expect(serializer).to_not have_received(:save).with('222', anything)
|
31
|
+
end
|
32
|
+
end
|
70
33
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
34
|
+
context 'failed fetches' do
|
35
|
+
specify 'are skipped' do
|
36
|
+
expect(serializer).to_not have_received(:save).with('333', anything)
|
75
37
|
end
|
76
38
|
end
|
77
39
|
end
|
@@ -36,5 +36,13 @@ describe Email::Mboxrd::Message do
|
|
36
36
|
it "appends > before '>+From '" do
|
37
37
|
expect(subject.to_s).to include("\n>>>From quoted")
|
38
38
|
end
|
39
|
+
|
40
|
+
context 'when date is missing' do
|
41
|
+
let(:date) { nil }
|
42
|
+
|
43
|
+
it 'does no fail' do
|
44
|
+
expect { subject.to_s }.to_not raise_error
|
45
|
+
end
|
46
|
+
end
|
39
47
|
end
|
40
48
|
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.0.
|
4
|
+
version: 1.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Yates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|