Class: Imap::Backup::CLI::Utils
- Inherits:
-
Thor
- Object
- Thor
- Imap::Backup::CLI::Utils
- Includes:
- Helpers, Thor::Actions
- Defined in:
- lib/imap/backup/cli/utils.rb
Overview
Implements the CLI utility functions
Instance Method Summary collapse
-
#export_to_thunderbird(email) ⇒ void
Exports the account’s emails to Thunderbird.
-
#ignore_history(email) ⇒ void
Creates fake downloaded emails so that only the account’s future emails will really get backed up.
Methods included from Helpers
#account, included, #load_config, #options, #requested_accounts
Instance Method Details
#export_to_thunderbird(email) ⇒ void
This method returns an undefined value.
Exports the account’s emails to Thunderbird
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/imap/backup/cli/utils.rb', line 68 def export_to_thunderbird(email) Imap::Backup::Logger.setup_logging force = .key?(:force) ? [:force] : false profile_name = [:profile] config = load_config(**) account = account(config, 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 serialized_folders = Account::SerializedFolders.new(account: account) raise "No serialized folders were found for account '#{email}'" if serialized_folders.none? serialized_folders.each do |serializer, _folder| Thunderbird::MailboxExporter.new( email, serializer, profile, force: force ).run end end |
#ignore_history(email) ⇒ void
This method returns an undefined value.
Creates fake downloaded emails so that only the account’s future emails will really get backed up
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/imap/backup/cli/utils.rb', line 28 def ignore_history(email) Logger.setup_logging config = load_config(**) account = account(config, email) backup_folders = Account::BackupFolders.new( client: account.client, account: account ) backup_folders.each do |folder| next if !folder.exist? serializer = Serializer.new(account.local_path, folder.name) do_ignore_folder_history(folder, serializer) end end |