imap-backup 1.2.1 → 1.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d7ae3ede8a09591fcf4380f2849e47fcae3229f8
4
- data.tar.gz: 627e9eb647200db2ab5417ca0f6de19a9f51e743
2
+ SHA256:
3
+ metadata.gz: 85975662cee269fb87e3de1150cd3a02c123e729e2d2f4e1a2e4905de477a897
4
+ data.tar.gz: 06aa1c25d470bc8f38cf78e124d00f90f498e9ba2e803804ebf7a58ce9f81579
5
5
  SHA512:
6
- metadata.gz: 75cc2e8b096739cd8c3d74f3372df3faa50be3f0373cbf3b0eed2d2a80231ffce4c548e072ab92ac1a17b0def9d831c48df62ba7126654d8fbde7a08d0ab532c
7
- data.tar.gz: 1699f0b9eb410f46a40a8880cc5c0e4e6295cf3e45dbe4a6143fd30db4c30a53bae500e8737291fe7a7953f1c64ea7bc4d2c45c5f3b88e94823dbe46f059e275
6
+ metadata.gz: c75aff4a749a5630fe86bca252f676be0338c30c492ce3fdbe654c895143dcd7846ab654733f2aeb3a4316fe4b8f630d3ca0a1db0227c7d06918e7362d17970b
7
+ data.tar.gz: b3b267870e606d407931ac337c36865aaccf430b1b91ab0a9a3dfe49e1db65ae159ddaeaf2f22041715e6998a8d00db8d76b02dafc6ac0a11dcd91218129a62e
@@ -1,10 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- - 2.1.5
5
- - 2.2.4
6
- - 2.3.0
7
- - 2.4.1
3
+ - 2.1.10
4
+ - 2.2.10
5
+ - 2.3.7
6
+ - 2.4.4
7
+ - 2.5.1
8
8
  branches:
9
9
  only:
10
10
  - master
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 and specify the folders to backup.
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
- The setup system is a menu-driven command line application.
36
+ ## Folders
36
37
 
37
- It creates ~/.imap-backup directory and configuration file. E.g.:
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
@@ -34,6 +34,11 @@ opts = OptionParser.new do |opts|
34
34
  puts opts
35
35
  exit
36
36
  end
37
+
38
+ opts.on_tail("--version", "Show version" ) do
39
+ puts Imap::Backup::VERSION
40
+ exit
41
+ end
37
42
  end
38
43
  opts.parse!
39
44
 
@@ -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
- if RUBY_VERSION > '2'
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'
@@ -8,7 +8,7 @@ module Email::Mboxrd
8
8
 
9
9
  def initialize(supplied_body)
10
10
  @supplied_body = supplied_body.clone
11
- @supplied_body.force_encoding('binary') if RUBY_VERSION >= '1.9.0'
11
+ @supplied_body.force_encoding('binary')
12
12
  end
13
13
 
14
14
  def to_s
@@ -33,9 +33,12 @@ module Imap::Backup
33
33
 
34
34
  def fetch(uid)
35
35
  imap.examine(name)
36
- message = imap.uid_fetch([uid.to_i], REQUESTED_ATTRIBUTES)[0][1]
37
- message['RFC822'].force_encoding('utf-8') if RUBY_VERSION > '1.9'
38
- message
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
@@ -1,5 +1,4 @@
1
1
  # encoding: utf-8
2
- require 'rubygems' if RUBY_VERSION < '1.9'
3
2
  require 'highline'
4
3
 
5
4
  module Imap::Backup
@@ -1,5 +1,4 @@
1
1
  # encoding: utf-8
2
- require 'rubygems' if RUBY_VERSION < '1.9'
3
2
  require 'json'
4
3
 
5
4
  module Imap::Backup
@@ -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
@@ -3,6 +3,6 @@ module Imap; end
3
3
  module Imap::Backup
4
4
  MAJOR = 1
5
5
  MINOR = 2
6
- REVISION = 1
6
+ REVISION = 2
7
7
  VERSION = [MAJOR, MINOR, REVISION].map(&:to_s).join('.')
8
8
  end
@@ -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('downloader', :run => nil) }
108
+ let(:downloader) { double(Imap::Backup::Downloader, :run => nil) }
109
109
 
110
110
  before do
111
- allow(Imap::Backup::Downloader).to receive(:new).and_return(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(:message) { {'RFC822' => message_body, 'other' => 'xxx'} }
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).and_return([[nil, message]]) }
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(message)
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
- if RUBY_VERSION > '1.9'
50
- it 'sets the encoding on the message' do
51
- subject.fetch(123)
60
+ it 'sets the encoding on the message' do
61
+ subject.fetch(123)
52
62
 
53
- expect(message_body).to have_received(:force_encoding).with('utf-8')
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.1
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: 2017-08-20 00:00:00.000000000 Z
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.11
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