Class: Imap::Backup::CLI::Transfer

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/imap/backup/cli/transfer.rb

Overview

Implements migration and mirroring

Constant Summary collapse

ACTIONS =

The possible values for the action parameter

%i(migrate mirror).freeze

Instance Method Summary collapse

Methods included from Helpers

#account, included, #load_config, #requested_accounts

Constructor Details

#initialize(action, source_email, destination_email, options) ⇒ Transfer

Returns a new instance of Transfer.



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/imap/backup/cli/transfer.rb', line 18

def initialize(action, source_email, destination_email, options)
  @action = action
  @source_email = source_email
  @destination_email = destination_email
  @options = options
  @automatic_namespaces = nil
  @config_path = nil
  @destination_delimiter = nil
  @destination_prefix = nil
  @reset = nil
  @source_delimiter = nil
  @source_prefix = nil
end

Instance Method Details

#runObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/imap/backup/cli/transfer.rb', line 38

def run
  raise "Unknown action '#{action}'" if !ACTIONS.include?(action)

  process_options!
  prepare_mirror if action == :mirror

  folders.each do |serializer, folder|
    case action
    when :migrate
      Migrator.new(serializer, folder, reset: reset).run
    when :mirror
      Mirror.new(serializer, folder).run
    end
  end
end