Class: Imap::Backup::CLI::Utils

Inherits:
Thor
  • Object
show all
Includes:
Helpers, Thor::Actions
Defined in:
lib/imap/backup/cli/utils.rb

Constant Summary collapse

FAKE_EMAIL =
"[email protected]".freeze

Instance Method Summary collapse

Methods included from Helpers

#account, #connection, #each_connection, #symbolized

Instance Method Details

#export_to_thunderbird(email) ⇒ Object


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/imap/backup/cli/utils.rb', line 41

def export_to_thunderbird(email)
  opts = symbolized(options)
  force = opts.key?(:force) ? opts[:force] : false
  profile_name = opts[:profile]

  connection = connection(email)
  profile = thunderbird_profile(profile_name)

  if !profile
    raise "Thunderbird profile '#{profile_name}' not found" if profile_name

    raise "Default Thunderbird profile not found"
  end

  connection.local_folders.each do |serializer, _folder|
    Thunderbird::MailboxExporter.new(
      email, serializer, profile, force: force
    ).run
  end
end

#ignore_history(email) ⇒ Object


11
12
13
14
15
16
17
18
19
20
# File 'lib/imap/backup/cli/utils.rb', line 11

def ignore_history(email)
  connection = connection(email)

  connection.backup_folders.each do |folder|
    next if !folder.exist?

    serializer = Serializer.new(connection..local_path, folder.name)
    do_ignore_folder_history(folder, serializer)
  end
end