Class: Imap::Backup::Account
- Inherits:
-
Object
- Object
- Imap::Backup::Account
- Defined in:
- lib/imap/backup/account.rb,
lib/imap/backup/account/backup.rb,
lib/imap/backup/account/folder.rb,
lib/imap/backup/account/restore.rb,
lib/imap/backup/account/folder_backup.rb,
lib/imap/backup/account/backup_folders.rb,
lib/imap/backup/account/client_factory.rb,
lib/imap/backup/account/folder_ensurer.rb,
lib/imap/backup/account/serialized_folders.rb,
lib/imap/backup/account/local_only_folder_deleter.rb
Defined Under Namespace
Classes: Backup, BackupFolders, ClientFactory, Folder, FolderBackup, FolderEnsurer, LocalOnlyFolderDeleter, Restore, SerializedFolders
Constant Summary collapse
- DEFAULT_MULTI_FETCH_SIZE =
1
Instance Attribute Summary collapse
-
#changes ⇒ Object
readonly
Returns the value of attribute changes.
-
#connection_options ⇒ Object
Returns the value of attribute connection_options.
-
#download_strategy ⇒ Object
Returns the value of attribute download_strategy.
-
#folder_blacklist ⇒ Object
Returns the value of attribute folder_blacklist.
-
#folders ⇒ Object
Returns the value of attribute folders.
-
#local_path ⇒ Object
Returns the value of attribute local_path.
-
#mirror_mode ⇒ Object
Returns the value of attribute mirror_mode.
-
#password ⇒ Object
Returns the value of attribute password.
-
#reset_seen_flags_after_fetch ⇒ Object
Returns the value of attribute reset_seen_flags_after_fetch.
-
#server ⇒ Object
Returns the value of attribute server.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #capabilities ⇒ Object
- #clear_changes ⇒ Object
- #client ⇒ Object
-
#initialize(options) ⇒ Account
constructor
A new instance of Account.
- #mark_for_deletion ⇒ Object
- #marked_for_deletion? ⇒ Boolean
- #modified? ⇒ Boolean
- #multi_fetch_size ⇒ Object
- #multi_fetch_size=(value) ⇒ Object
- #namespaces ⇒ Object
- #restore ⇒ Object
- #to_h ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(options) ⇒ Account
Returns a new instance of Account.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/imap/backup/account.rb', line 22 def initialize() @username = [:username] @password = [:password] @local_path = [:local_path] @folders = [:folders] @folder_blacklist = [:folder_blacklist] @mirror_mode = [:mirror_mode] @server = [:server] @connection_options = [:connection_options] @download_strategy = [:download_strategy] @multi_fetch_size_orignal = [:multi_fetch_size] @reset_seen_flags_after_fetch = [:reset_seen_flags_after_fetch] @client = nil @changes = {} @marked_for_deletion = false end |
Instance Attribute Details
#changes ⇒ Object (readonly)
Returns the value of attribute changes.
20 21 22 |
# File 'lib/imap/backup/account.rb', line 20 def changes @changes end |
#connection_options ⇒ Object
Returns the value of attribute connection_options.
17 18 19 |
# File 'lib/imap/backup/account.rb', line 17 def @connection_options end |
#download_strategy ⇒ Object
Returns the value of attribute download_strategy.
18 19 20 |
# File 'lib/imap/backup/account.rb', line 18 def download_strategy @download_strategy end |
#folder_blacklist ⇒ Object
Returns the value of attribute folder_blacklist.
14 15 16 |
# File 'lib/imap/backup/account.rb', line 14 def folder_blacklist @folder_blacklist end |
#folders ⇒ Object
Returns the value of attribute folders.
13 14 15 |
# File 'lib/imap/backup/account.rb', line 13 def folders @folders end |
#local_path ⇒ Object
Returns the value of attribute local_path.
12 13 14 |
# File 'lib/imap/backup/account.rb', line 12 def local_path @local_path end |
#mirror_mode ⇒ Object
Returns the value of attribute mirror_mode.
15 16 17 |
# File 'lib/imap/backup/account.rb', line 15 def mirror_mode @mirror_mode end |
#password ⇒ Object
Returns the value of attribute password.
11 12 13 |
# File 'lib/imap/backup/account.rb', line 11 def password @password end |
#reset_seen_flags_after_fetch ⇒ Object
Returns the value of attribute reset_seen_flags_after_fetch.
19 20 21 |
# File 'lib/imap/backup/account.rb', line 19 def reset_seen_flags_after_fetch @reset_seen_flags_after_fetch end |
#server ⇒ Object
Returns the value of attribute server.
16 17 18 |
# File 'lib/imap/backup/account.rb', line 16 def server @server end |
#username ⇒ Object
Returns the value of attribute username.
10 11 12 |
# File 'lib/imap/backup/account.rb', line 10 def username @username end |
Instance Method Details
#capabilities ⇒ Object
47 48 49 |
# File 'lib/imap/backup/account.rb', line 47 def capabilities client.capability end |
#clear_changes ⇒ Object
64 65 66 |
# File 'lib/imap/backup/account.rb', line 64 def clear_changes @changes = {} end |
#client ⇒ Object
39 40 41 |
# File 'lib/imap/backup/account.rb', line 39 def client @client ||= Account::ClientFactory.new(account: self).run end |
#mark_for_deletion ⇒ Object
68 69 70 |
# File 'lib/imap/backup/account.rb', line 68 def mark_for_deletion @marked_for_deletion = true end |
#marked_for_deletion? ⇒ Boolean
72 73 74 |
# File 'lib/imap/backup/account.rb', line 72 def marked_for_deletion? @marked_for_deletion end |
#modified? ⇒ Boolean
60 61 62 |
# File 'lib/imap/backup/account.rb', line 60 def modified? changes.any? end |
#multi_fetch_size ⇒ Object
131 132 133 134 135 136 137 138 139 140 |
# File 'lib/imap/backup/account.rb', line 131 def multi_fetch_size @multi_fetch_size ||= begin int = @multi_fetch_size_orignal.to_i if int.positive? int else DEFAULT_MULTI_FETCH_SIZE end end end |
#multi_fetch_size=(value) ⇒ Object
142 143 144 145 146 |
# File 'lib/imap/backup/account.rb', line 142 def multi_fetch_size=(value) parsed = value.to_i parsed = DEFAULT_MULTI_FETCH_SIZE if !parsed.positive? update(:multi_fetch_size, parsed) end |
#namespaces ⇒ Object
43 44 45 |
# File 'lib/imap/backup/account.rb', line 43 def namespaces client.namespace end |
#restore ⇒ Object
51 52 53 54 |
# File 'lib/imap/backup/account.rb', line 51 def restore restore = Account::Restore.new(account: self) restore.run end |
#to_h ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/imap/backup/account.rb', line 76 def to_h h = {username: @username, password: @password} h[:local_path] = @local_path if @local_path h[:folders] = @folders if @folders h[:folder_blacklist] = true if @folder_blacklist h[:mirror_mode] = true if @mirror_mode h[:server] = @server if @server h[:connection_options] = @connection_options if @connection_options h[:multi_fetch_size] = multi_fetch_size if @reset_seen_flags_after_fetch h[:reset_seen_flags_after_fetch] = @reset_seen_flags_after_fetch end h end |
#valid? ⇒ Boolean
56 57 58 |
# File 'lib/imap/backup/account.rb', line 56 def valid? username && password ? true : false end |