Class: Imap::Backup::Thunderbird::MailboxExporter

Inherits:
Object
  • Object
show all
Defined in:
lib/imap/backup/thunderbird/mailbox_exporter.rb

Overview

Exports an account’s emails to Thunderbird

Instance Method Summary collapse

Constructor Details

#initialize(email, serializer, profile, force: false) ⇒ MailboxExporter

Returns a new instance of MailboxExporter.

Parameters:

  • email (String)

    an email address

  • serializer (Serializer)

    a local folder backup

  • profile (Thunderbird::Profile)

    an existing Thunderbird profile



15
16
17
18
19
20
# File 'lib/imap/backup/thunderbird/mailbox_exporter.rb', line 15

def initialize(email, serializer, profile, force: false)
  @email = email
  @serializer = serializer
  @profile = profile
  @force = force
end

Instance Method Details

#runvoid

This method returns an undefined value.

Copies the account’s messages to the Thunderbird directory in the format expected by Thunderbird



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/imap/backup/thunderbird/mailbox_exporter.rb', line 25

def run
  if !profile_set_up
    error "The Thunderbird profile '#{profile.title}' " \
          "has not been set up. " \
          "Please set it up before trying to export"
    return false
  end

  local_folder_ok = local_folder.set_up
  if !local_folder_ok
    error "Failed to set up local folder"
    return false
  end

  skip_for_msf = check_msf
  return false if skip_for_msf

  skip_for_local_folder = check_local_folder
  return false if skip_for_local_folder

  info "Exporting account '#{email}' to folder '#{local_folder.full_path}'"
  copy_messages

  true
end