imap-backup 1.0.12 → 1.0.13

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
  SHA1:
3
- metadata.gz: 7c42e0f05b9fe1321562fd54446d99f765ad1544
4
- data.tar.gz: 6e005f9c0605e371063ea1b2eec65e04ad6bd71c
3
+ metadata.gz: 03ba4f6a03ae0efc265699ae27662d4089867f60
4
+ data.tar.gz: 645ee02996bcf94bddc4d890ce6d22c248584fb3
5
5
  SHA512:
6
- metadata.gz: ea5b48a3cbbf5b9513efbb0f453941bf33e96e1f6008b8d4af4414ef5b03a8502c30393c512e630186c0ba49e6d232facc93433fa86616aaab97716ac5082d8d
7
- data.tar.gz: c9d9a35daf1ed227922de3e7601a30a383ea4cc5d87259a546a1a8914db48206909b6c75c60993db12ee147a50ae204fe5d9bff41ca0ffd427fa72aa86a3cc24
6
+ metadata.gz: bd1aea391344bc6a3d66d2748f4de0f8400363e5bfdb747d440aacbd1cc1c67b145ee3025431afaf233e6cab69ec14e84448634c0ba87caaf20f42384fa16847
7
+ data.tar.gz: d891fc0666d94a25ee6c9f201944b7f29eea73742e81c6ce44f8e87b44568f1a8a2214eeeef7bff6c977ee79d9be2b591e46592760f79d9690b56d2ed622d34f
data/README.md CHANGED
@@ -93,7 +93,7 @@ Manually, from the command line:
93
93
  $ imap-backup
94
94
  ```
95
95
 
96
- Altertatively, add it to your crontab.
96
+ Alternatively, add it to your crontab.
97
97
 
98
98
  # Result
99
99
 
@@ -33,7 +33,11 @@ module Email::Mboxrd
33
33
  end
34
34
 
35
35
  def asctime
36
- parsed.date.asctime
36
+ date ? date.asctime : ''
37
+ end
38
+
39
+ def date
40
+ parsed.date
37
41
  end
38
42
  end
39
43
  end
@@ -3,6 +3,6 @@ module Imap; end
3
3
  module Imap::Backup
4
4
  MAJOR = 1
5
5
  MINOR = 0
6
- REVISION = 12
6
+ REVISION = 13
7
7
  VERSION = [MAJOR, MINOR, REVISION].map(&:to_s).join('.')
8
8
  end
@@ -2,76 +2,38 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe Imap::Backup::Downloader do
5
- context 'with account and downloader' do
6
- let(:local_path) { '/base/path' }
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(:serializer) do
16
- double(
17
- 'Imap::Backup::Serializer',
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
- context '#run' do
30
- context 'with folder' do
31
- it 'should list messages' do
32
- allow(folder).to receive(:uids).and_return([])
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
- subject.run
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
- context 'with messages' do
38
- before :each do
39
- allow(folder).to receive(:uids).and_return(['123', '999', '1234'])
40
- end
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
- expect(serializer).to have_received(:save).with('999', message)
72
- expect(serializer).to have_received(:save).with('1234', message)
73
- end
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.12
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-08-19 00:00:00.000000000 Z
11
+ date: 2014-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake