imap-backup 3.4.1 → 4.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/.rubocop_todo.yml +1 -1
- data/CHANGELOG.md +11 -0
- data/bin/imap-backup +3 -93
- data/imap-backup +9 -0
- data/imap-backup.gemspec +1 -0
- data/lib/email/mboxrd/message.rb +2 -2
- data/lib/imap/backup/account/connection.rb +14 -12
- data/lib/imap/backup/cli/backup.rb +21 -0
- data/lib/imap/backup/cli/folders.rb +27 -0
- data/lib/imap/backup/cli/helpers.rb +20 -0
- data/lib/imap/backup/cli/local.rb +70 -0
- data/lib/imap/backup/cli/restore.rb +19 -0
- data/lib/imap/backup/cli/setup.rb +13 -0
- data/lib/imap/backup/cli/status.rb +26 -0
- data/lib/imap/backup/cli.rb +87 -0
- data/lib/imap/backup/configuration/list.rb +12 -12
- data/lib/imap/backup/version.rb +4 -4
- data/spec/unit/imap/backup/account/connection_spec.rb +31 -6
- data/spec/unit/imap/backup/configuration/list_spec.rb +1 -0
- metadata +28 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba3f202308a586f7ec54b28d66ea2f9422cf30f706c118ab02f362346351f268
|
4
|
+
data.tar.gz: 585bd29f2d2f836aad27c6ac58855649b7621eff770d5e2b40bfdd3f6aa774f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6270660f55ab52e3a3d8242bdfbb2d044ce7428ccc75daabf25b6753a7c91f9c3f4d8b2be4db517f44fb887663a40e946f128c2bf06f4d1006cd02182d9f477e
|
7
|
+
data.tar.gz: f94af41fee60be97e15e0d2aa3da5a0696b9d8bab5cb03cb42c805881b13e8a38fc5be42ee30efd26576d5cadb10d2f53b0c46c00fc94ca72cf23f94e05d602b
|
data/.circleci/config.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -63,7 +63,7 @@ Metrics/AbcSize:
|
|
63
63
|
# Offense count: 3
|
64
64
|
# Configuration parameters: CountComments, CountAsOne.
|
65
65
|
Metrics/ClassLength:
|
66
|
-
Max:
|
66
|
+
Max: 172
|
67
67
|
|
68
68
|
# Offense count: 19
|
69
69
|
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
|
+
|
7
|
+
## [4.0.0.rc1] - 2021-11-17
|
8
|
+
|
9
|
+
### Added
|
10
|
+
* `local` commands to list accounts, folders and emails and to view single
|
11
|
+
emails.
|
data/bin/imap-backup
CHANGED
@@ -1,98 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require "optparse"
|
3
2
|
|
4
3
|
$LOAD_PATH.unshift(File.expand_path("../lib/", __dir__))
|
5
|
-
require "imap/backup"
|
4
|
+
require "imap/backup/cli"
|
6
5
|
|
7
|
-
|
8
|
-
{name: "setup", help: "Create/edit the configuration file"},
|
9
|
-
{name: "backup", help: "Do the backup (default)"},
|
10
|
-
{name: "folders", help: "List folders for all (or selected) accounts"},
|
11
|
-
{name: "restore", help: "Restore emails to server"},
|
12
|
-
{name: "status", help: "List count of non backed-up emails per folder"},
|
13
|
-
{name: "help", help: "Show usage"}
|
14
|
-
].freeze
|
6
|
+
Imap::Backup::Configuration::List.new.setup_logging
|
15
7
|
|
16
|
-
|
17
|
-
parser = OptionParser.new do |opts|
|
18
|
-
opts.banner = "Usage: #{$PROGRAM_NAME} [options] COMMAND"
|
19
|
-
|
20
|
-
opts.separator ""
|
21
|
-
opts.separator "Commands:"
|
22
|
-
KNOWN_COMMANDS.each do |command|
|
23
|
-
opts.separator format("\t%- 20<name>s %<help>s", command)
|
24
|
-
end
|
25
|
-
opts.separator ""
|
26
|
-
opts.separator "Common options:"
|
27
|
-
|
28
|
-
opts.on(
|
29
|
-
"-a",
|
30
|
-
"--accounts ACCOUNT1[,ACCOUNT2,...]",
|
31
|
-
Array,
|
32
|
-
"only these accounts"
|
33
|
-
) do |account|
|
34
|
-
options[:accounts] = account
|
35
|
-
end
|
36
|
-
|
37
|
-
opts.on_tail("-h", "--help", "Show usage") do
|
38
|
-
puts opts
|
39
|
-
exit
|
40
|
-
end
|
41
|
-
|
42
|
-
opts.on_tail("--version", "Show version") do
|
43
|
-
puts Imap::Backup::VERSION
|
44
|
-
exit
|
45
|
-
end
|
46
|
-
end
|
47
|
-
parser.parse!
|
48
|
-
|
49
|
-
options[:command] = ARGV.shift if !ARGV.empty?
|
50
|
-
|
51
|
-
# rubocop:disable Style/IfUnlessModifier
|
52
|
-
if KNOWN_COMMANDS.find { |c| c[:name] == options[:command] }.nil?
|
53
|
-
raise "Unknown command '#{options[:command]}'"
|
54
|
-
end
|
55
|
-
|
56
|
-
# rubocop:enable Style/IfUnlessModifier
|
57
|
-
|
58
|
-
if options[:command] == "help"
|
59
|
-
puts parser
|
60
|
-
exit
|
61
|
-
end
|
62
|
-
|
63
|
-
begin
|
64
|
-
configuration = Imap::Backup::Configuration::List.new(options[:accounts])
|
65
|
-
rescue Imap::Backup::ConfigurationNotFound
|
66
|
-
Imap::Backup::Configuration::Setup.new.run
|
67
|
-
exit
|
68
|
-
end
|
69
|
-
|
70
|
-
configuration.setup_logging
|
71
|
-
|
72
|
-
case options[:command]
|
73
|
-
when "setup"
|
74
|
-
Imap::Backup::Configuration::Setup.new.run
|
75
|
-
when "backup"
|
76
|
-
configuration.each_connection(&:run_backup)
|
77
|
-
when "folders"
|
78
|
-
configuration.each_connection do |connection|
|
79
|
-
puts connection.username
|
80
|
-
folders = connection.folders
|
81
|
-
if folders.nil?
|
82
|
-
warn "Unable to list account folders"
|
83
|
-
exit 1
|
84
|
-
end
|
85
|
-
folders.each { |f| puts "\t#{f}" }
|
86
|
-
end
|
87
|
-
when "restore"
|
88
|
-
configuration.each_connection(&:restore)
|
89
|
-
when "status"
|
90
|
-
configuration.each_connection do |connection|
|
91
|
-
puts connection.username
|
92
|
-
folders = connection.status
|
93
|
-
folders.each do |f|
|
94
|
-
missing_locally = f[:remote] - f[:local]
|
95
|
-
puts "#{f[:name]}: #{missing_locally.size}"
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
8
|
+
Imap::Backup::CLI.start(ARGV)
|
data/imap-backup
ADDED
data/imap-backup.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.add_runtime_dependency "highline"
|
22
22
|
gem.add_runtime_dependency "mail"
|
23
23
|
gem.add_runtime_dependency "rake"
|
24
|
+
gem.add_runtime_dependency "thor", "~> 1.1"
|
24
25
|
|
25
26
|
gem.add_development_dependency "codeclimate-test-reporter", "~> 0.4.8"
|
26
27
|
if RUBY_ENGINE == "jruby"
|
data/lib/email/mboxrd/message.rb
CHANGED
@@ -73,6 +73,19 @@ module Imap::Backup
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
+
def local_folders
|
77
|
+
return enum_for(:local_folders) if !block_given?
|
78
|
+
|
79
|
+
glob = File.join(local_path, "**", "*.imap")
|
80
|
+
base = Pathname.new(local_path)
|
81
|
+
Pathname.glob(glob) do |path|
|
82
|
+
name = path.relative_path_from(base).to_s[0..-6]
|
83
|
+
serializer = Serializer::Mbox.new(local_path, name)
|
84
|
+
folder = Account::Folder.new(self, name)
|
85
|
+
yield serializer, folder
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
76
89
|
def restore
|
77
90
|
local_folders do |serializer, folder|
|
78
91
|
restore_folder serializer, folder
|
@@ -80,7 +93,7 @@ module Imap::Backup
|
|
80
93
|
end
|
81
94
|
|
82
95
|
def disconnect
|
83
|
-
imap.disconnect
|
96
|
+
imap.disconnect if @imap
|
84
97
|
end
|
85
98
|
|
86
99
|
def reconnect
|
@@ -174,17 +187,6 @@ module Imap::Backup
|
|
174
187
|
ENV["IMAP_BACKUP_ENABLE_GMAIL_OAUTH2"]
|
175
188
|
end
|
176
189
|
|
177
|
-
def local_folders
|
178
|
-
glob = File.join(local_path, "**", "*.imap")
|
179
|
-
base = Pathname.new(local_path)
|
180
|
-
Pathname.glob(glob) do |path|
|
181
|
-
name = path.relative_path_from(base).to_s[0..-6]
|
182
|
-
serializer = Serializer::Mbox.new(local_path, name)
|
183
|
-
folder = Account::Folder.new(self, name)
|
184
|
-
yield serializer, folder
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
190
|
def backup_folders
|
189
191
|
@backup_folders ||=
|
190
192
|
begin
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Imap::Backup
|
2
|
+
class CLI::Backup < Thor
|
3
|
+
include Thor::Actions
|
4
|
+
include CLI::Helpers
|
5
|
+
|
6
|
+
attr_reader :account_names
|
7
|
+
|
8
|
+
def initialize(options)
|
9
|
+
super([])
|
10
|
+
@account_names = (options[:accounts] || "").split(",")
|
11
|
+
end
|
12
|
+
|
13
|
+
no_commands do
|
14
|
+
def run
|
15
|
+
each_connection(account_names) do |connection|
|
16
|
+
connection.run_backup
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Imap::Backup
|
2
|
+
class CLI::Folders < Thor
|
3
|
+
include Thor::Actions
|
4
|
+
include CLI::Helpers
|
5
|
+
|
6
|
+
attr_reader :account_names
|
7
|
+
|
8
|
+
def initialize(options)
|
9
|
+
super([])
|
10
|
+
@account_names = (options[:accounts] || "").split(",")
|
11
|
+
end
|
12
|
+
|
13
|
+
no_commands do
|
14
|
+
def run
|
15
|
+
each_connection(account_names) do |connection|
|
16
|
+
puts connection.username
|
17
|
+
folders = connection.folders
|
18
|
+
if folders.nil?
|
19
|
+
warn "Unable to list account folders"
|
20
|
+
return false
|
21
|
+
end
|
22
|
+
folders.each { |f| puts "\t#{f}" }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "imap/backup"
|
2
|
+
|
3
|
+
module Imap::Backup::CLI::Helpers
|
4
|
+
def symbolized(options)
|
5
|
+
options.each.with_object({}) { |(k, v), acc| acc[k.intern] = v }
|
6
|
+
end
|
7
|
+
|
8
|
+
def each_connection(names)
|
9
|
+
begin
|
10
|
+
connections = Imap::Backup::Configuration::List.new(names)
|
11
|
+
rescue Imap::Backup::ConfigurationNotFound
|
12
|
+
raise "imap-backup is not configured. Run `imap-backup setup`"
|
13
|
+
return
|
14
|
+
end
|
15
|
+
|
16
|
+
connections.each_connection do |connection|
|
17
|
+
yield connection
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Imap::Backup
|
2
|
+
class CLI::Local < Thor
|
3
|
+
include Thor::Actions
|
4
|
+
include CLI::Helpers
|
5
|
+
|
6
|
+
desc "accounts", "list locally backed-up accounts"
|
7
|
+
def accounts
|
8
|
+
connections = Imap::Backup::Configuration::List.new
|
9
|
+
connections.accounts.each { |a| puts a[:username] }
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "folders EMAIL", "list account folders"
|
13
|
+
def folders(email)
|
14
|
+
connections = Imap::Backup::Configuration::List.new
|
15
|
+
account = connections.accounts.find { |a| a[:username] == email }
|
16
|
+
raise "#{email} is not a configured account" if !account
|
17
|
+
|
18
|
+
account_connection = Imap::Backup::Account::Connection.new(account)
|
19
|
+
account_connection.local_folders.each do |_s, f|
|
20
|
+
puts %("#{f.name}")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "emails EMAIL FOLDER", "list emails in a folder"
|
25
|
+
def emails(email, folder_name)
|
26
|
+
connections = Imap::Backup::Configuration::List.new
|
27
|
+
account = connections.accounts.find { |a| a[:username] == email }
|
28
|
+
raise "#{email} is not a configured account" if !account
|
29
|
+
|
30
|
+
account_connection = Imap::Backup::Account::Connection.new(account)
|
31
|
+
folder_serializer, folder = account_connection.local_folders.find do |(_s, f)|
|
32
|
+
f.name == folder_name
|
33
|
+
end
|
34
|
+
raise "Folder '#{folder_name}' not found" if !folder_serializer
|
35
|
+
|
36
|
+
max_subject = 60
|
37
|
+
puts format("%-10<uid>s %-#{max_subject}<subject>s - %<date>s", {uid: "UID", subject: "Subject", date: "Date"})
|
38
|
+
puts "-" * (12 + max_subject + 28)
|
39
|
+
|
40
|
+
uids = folder_serializer.uids
|
41
|
+
|
42
|
+
folder_serializer.each_message(uids).map do |uid, message|
|
43
|
+
m = {uid: uid, date: message.parsed.date.to_s, subject: message.parsed.subject}
|
44
|
+
if m[:subject].length > max_subject
|
45
|
+
puts format("% 10<uid>u: %.#{max_subject - 3}<subject>s... - %<date>s", m)
|
46
|
+
else
|
47
|
+
puts format("% 10<uid>u: %-#{max_subject}<subject>s - %<date>s", m)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "email EMAIL FOLDER UID", "show an email"
|
53
|
+
def email(email, folder_name, uid)
|
54
|
+
connections = Imap::Backup::Configuration::List.new
|
55
|
+
account = connections.accounts.find { |a| a[:username] == email }
|
56
|
+
raise "#{email} is not a configured account" if !account
|
57
|
+
|
58
|
+
account_connection = Imap::Backup::Account::Connection.new(account)
|
59
|
+
folder_serializer, _folder = account_connection.local_folders.find do |(_s, f)|
|
60
|
+
f.name == folder_name
|
61
|
+
end
|
62
|
+
raise "Folder '#{folder_name}' not found" if !folder_serializer
|
63
|
+
|
64
|
+
loaded_message = folder_serializer.load(uid)
|
65
|
+
raise "Message #{uid} not found in folder '#{folder_name}'" if !loaded_message
|
66
|
+
|
67
|
+
puts loaded_message.supplied_body
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Imap::Backup
|
2
|
+
class CLI::Restore < Thor
|
3
|
+
include Thor::Actions
|
4
|
+
include CLI::Helpers
|
5
|
+
|
6
|
+
attr_reader :account_names
|
7
|
+
|
8
|
+
def initialize(options)
|
9
|
+
super([])
|
10
|
+
@account_names = (options[:accounts] || "").split(",")
|
11
|
+
end
|
12
|
+
|
13
|
+
no_commands do
|
14
|
+
def run
|
15
|
+
each_connection(account_names) { |connection| connection.restore }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Imap::Backup
|
2
|
+
class CLI::Status < Thor
|
3
|
+
include Thor::Actions
|
4
|
+
include CLI::Helpers
|
5
|
+
|
6
|
+
attr_reader :account_names
|
7
|
+
|
8
|
+
def initialize(options)
|
9
|
+
super([])
|
10
|
+
@account_names = (options[:accounts] || "").split(",")
|
11
|
+
end
|
12
|
+
|
13
|
+
no_commands do
|
14
|
+
def run
|
15
|
+
each_connection(account_names) do |connection|
|
16
|
+
puts connection.username
|
17
|
+
folders = connection.status
|
18
|
+
folders.each do |f|
|
19
|
+
missing_locally = f[:remote] - f[:local]
|
20
|
+
puts "#{f[:name]}: #{missing_locally.size}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
class Imap::Backup::CLI < Thor
|
4
|
+
require "imap/backup/cli/helpers"
|
5
|
+
|
6
|
+
autoload :Backup, "imap/backup/cli/backup"
|
7
|
+
autoload :Folders, "imap/backup/cli/folders"
|
8
|
+
autoload :Local, "imap/backup/cli/local"
|
9
|
+
autoload :Remote, "imap/backup/cli/remote"
|
10
|
+
autoload :Restore, "imap/backup/cli/restore"
|
11
|
+
autoload :Setup, "imap/backup/cli/setup"
|
12
|
+
autoload :Status, "imap/backup/cli/status"
|
13
|
+
|
14
|
+
include Helpers
|
15
|
+
|
16
|
+
default_task :backup
|
17
|
+
|
18
|
+
def self.exit_on_failure?
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.accounts_option
|
23
|
+
method_option(
|
24
|
+
"accounts",
|
25
|
+
type: :string,
|
26
|
+
banner: "a comma-separated list of accounts (defaults to all configured accounts)",
|
27
|
+
aliases: ["-a"]
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "backup [OPTIONS]", "Run the backup"
|
32
|
+
long_desc <<~DESC
|
33
|
+
Downloads any emails not yet present locally.
|
34
|
+
Runs the backup for each configured account,
|
35
|
+
or for those requested via the --accounts option.
|
36
|
+
By default all folders, are backed up.
|
37
|
+
The setup tool can be used to choose a specific list of folders to back up.
|
38
|
+
DESC
|
39
|
+
accounts_option
|
40
|
+
def backup
|
41
|
+
Backup.new(symbolized(options)).run
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "folders [OPTIONS]", "This command is deprecated, use `imap-backup remote folders ACCOUNT`"
|
45
|
+
long_desc <<~DESC
|
46
|
+
Lists all folders of all configured accounts.
|
47
|
+
This command is deprecated.
|
48
|
+
Instead, use a combination of `imap-backup local accounts` to get the list of accounts,
|
49
|
+
and `imap-backup remote folders ACCOUNT` to get the folder list.
|
50
|
+
DESC
|
51
|
+
accounts_option
|
52
|
+
def folders
|
53
|
+
Folders.new(symbolized(options)).run
|
54
|
+
end
|
55
|
+
|
56
|
+
desc "restore [OPTIONS]", "This command is deprecated, use `imap-backup restore ACCOUNT`"
|
57
|
+
long_desc <<~DESC
|
58
|
+
By default, restores all local emails to their respective servers.
|
59
|
+
This command is deprecated.
|
60
|
+
Instead, use `imap-backup restore ACCOUNT` to restore a single account.
|
61
|
+
DESC
|
62
|
+
accounts_option
|
63
|
+
def restore
|
64
|
+
Restore.new(symbolized(options)).run
|
65
|
+
end
|
66
|
+
|
67
|
+
desc "setup", "Configure imap-backup"
|
68
|
+
long_desc <<~DESC
|
69
|
+
A menu-driven command-line application used to configure imap-backup.
|
70
|
+
Configure email accounts to back up.
|
71
|
+
DESC
|
72
|
+
def setup
|
73
|
+
Setup.new().run
|
74
|
+
end
|
75
|
+
|
76
|
+
desc "status", "Show backup status"
|
77
|
+
long_desc <<~DESC
|
78
|
+
For each configured account and folder, lists the number of emails yet to be downloaded.
|
79
|
+
DESC
|
80
|
+
accounts_option
|
81
|
+
def status
|
82
|
+
Status.new(symbolized(options)).run
|
83
|
+
end
|
84
|
+
|
85
|
+
desc "local subcommand ...ARGS", "View local info"
|
86
|
+
subcommand "local", Local
|
87
|
+
end
|
@@ -4,7 +4,7 @@ module Imap::Backup
|
|
4
4
|
class Configuration::List
|
5
5
|
attr_reader :required_accounts
|
6
6
|
|
7
|
-
def initialize(required_accounts =
|
7
|
+
def initialize(required_accounts = [])
|
8
8
|
@required_accounts = required_accounts
|
9
9
|
end
|
10
10
|
|
@@ -23,6 +23,17 @@ module Imap::Backup
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
def accounts
|
27
|
+
@accounts ||=
|
28
|
+
if required_accounts.empty?
|
29
|
+
config.accounts
|
30
|
+
else
|
31
|
+
config.accounts.select do |account|
|
32
|
+
required_accounts.include?(account[:username])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
26
37
|
private
|
27
38
|
|
28
39
|
def config
|
@@ -38,16 +49,5 @@ module Imap::Backup
|
|
38
49
|
def config_exists?
|
39
50
|
Configuration::Store.exist?
|
40
51
|
end
|
41
|
-
|
42
|
-
def accounts
|
43
|
-
@accounts ||=
|
44
|
-
if required_accounts.nil?
|
45
|
-
config.accounts
|
46
|
-
else
|
47
|
-
config.accounts.select do |account|
|
48
|
-
required_accounts.include?(account[:username])
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
52
|
end
|
53
53
|
end
|
data/lib/imap/backup/version.rb
CHANGED
@@ -433,24 +433,49 @@ describe Imap::Backup::Account::Connection do
|
|
433
433
|
end
|
434
434
|
|
435
435
|
describe "#reconnect" do
|
436
|
-
|
437
|
-
|
436
|
+
context "when the IMAP connection has been used" do
|
437
|
+
before { subject.imap }
|
438
438
|
|
439
|
-
|
439
|
+
it "disconnects from the server" do
|
440
|
+
expect(imap).to receive(:disconnect)
|
441
|
+
|
442
|
+
subject.reconnect
|
443
|
+
end
|
444
|
+
end
|
445
|
+
|
446
|
+
context "when the IMAP connection has not been used" do
|
447
|
+
it "does not disconnect from the server" do
|
448
|
+
expect(imap).to_not receive(:disconnect)
|
449
|
+
|
450
|
+
subject.reconnect
|
451
|
+
end
|
440
452
|
end
|
441
453
|
|
442
454
|
it "causes reconnection on future access" do
|
443
455
|
expect(Net::IMAP).to receive(:new)
|
444
456
|
|
445
457
|
subject.reconnect
|
458
|
+
subject.imap
|
446
459
|
end
|
447
460
|
end
|
448
461
|
|
449
462
|
describe "#disconnect" do
|
450
|
-
|
451
|
-
|
463
|
+
context "when the IMAP connection has been used" do
|
464
|
+
it "disconnects from the server" do
|
465
|
+
subject.imap
|
466
|
+
|
467
|
+
expect(imap).to receive(:disconnect)
|
452
468
|
|
453
|
-
|
469
|
+
subject.disconnect
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
context "when the IMAP connection has not been used" do
|
474
|
+
it "does not disconnect from the server" do
|
475
|
+
expect(imap).to_not receive(:disconnect)
|
476
|
+
|
477
|
+
subject.disconnect
|
478
|
+
end
|
454
479
|
end
|
455
480
|
end
|
456
481
|
end
|
@@ -35,6 +35,7 @@ describe Imap::Backup::Configuration::List do
|
|
35
35
|
allow(Imap::Backup::Configuration::Store).
|
36
36
|
to receive(:exist?) { config_exists }
|
37
37
|
allow(Imap::Backup).to receive(:setup_logging)
|
38
|
+
allow(store).to receive(:debug?)
|
38
39
|
end
|
39
40
|
|
40
41
|
it "sets global logging level" do
|
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:
|
4
|
+
version: 4.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Yates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gmail_xoauth
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: thor
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.1'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.1'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: codeclimate-test-reporter
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,6 +192,7 @@ files:
|
|
178
192
|
- ".rspec-all"
|
179
193
|
- ".rubocop.yml"
|
180
194
|
- ".rubocop_todo.yml"
|
195
|
+
- CHANGELOG.md
|
181
196
|
- Gemfile
|
182
197
|
- LICENSE
|
183
198
|
- README.md
|
@@ -211,6 +226,7 @@ files:
|
|
211
226
|
- docs/27-success.png
|
212
227
|
- docs/docker-imap.md
|
213
228
|
- docs/setting-up-gmail-with-oauth2.md
|
229
|
+
- imap-backup
|
214
230
|
- imap-backup.gemspec
|
215
231
|
- lib/email/mboxrd/message.rb
|
216
232
|
- lib/email/provider.rb
|
@@ -219,6 +235,14 @@ files:
|
|
219
235
|
- lib/imap/backup.rb
|
220
236
|
- lib/imap/backup/account/connection.rb
|
221
237
|
- lib/imap/backup/account/folder.rb
|
238
|
+
- lib/imap/backup/cli.rb
|
239
|
+
- lib/imap/backup/cli/backup.rb
|
240
|
+
- lib/imap/backup/cli/folders.rb
|
241
|
+
- lib/imap/backup/cli/helpers.rb
|
242
|
+
- lib/imap/backup/cli/local.rb
|
243
|
+
- lib/imap/backup/cli/restore.rb
|
244
|
+
- lib/imap/backup/cli/setup.rb
|
245
|
+
- lib/imap/backup/cli/status.rb
|
222
246
|
- lib/imap/backup/configuration/account.rb
|
223
247
|
- lib/imap/backup/configuration/asker.rb
|
224
248
|
- lib/imap/backup/configuration/connection_tester.rb
|
@@ -286,9 +310,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
286
310
|
version: '2.5'
|
287
311
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
288
312
|
requirements:
|
289
|
-
- - "
|
313
|
+
- - ">"
|
290
314
|
- !ruby/object:Gem::Version
|
291
|
-
version:
|
315
|
+
version: 1.3.1
|
292
316
|
requirements: []
|
293
317
|
rubygems_version: 3.1.4
|
294
318
|
signing_key:
|