Class: Imap::Backup::Client::Default
- Inherits:
-
Object
- Object
- Imap::Backup::Client::Default
- Extended by:
- Forwardable
- Defined in:
- lib/imap/backup/client/default.rb
Overview
Wraps a Net::IMAP instance Tracks the latest folder selection in order to avoid repeated calls
Direct Known Subclasses
Instance Method Summary collapse
-
#disconnect ⇒ void
Disconects from the server.
-
#examine(mailbox) ⇒ void
Prepares read-only access to a folder.
-
#initialize(server, account, options) ⇒ Default
constructor
A new instance of Default.
-
#list ⇒ Array<String>
The account folders.
-
#login ⇒ void
Logs in to the account on the IMAP server.
-
#reconnect ⇒ void
Logs out and back in to the server.
-
#select(mailbox) ⇒ void
Prepares read-write access to a folder.
-
#username ⇒ String
The account username.
Constructor Details
#initialize(server, account, options) ⇒ Default
Returns a new instance of Default.
20 21 22 23 24 25 |
# File 'lib/imap/backup/client/default.rb', line 20 def initialize(server, account, ) @account = account @options = @server = server @state = nil end |
Instance Method Details
#disconnect ⇒ void
This method returns an undefined value.
Disconects from the server
60 61 62 63 |
# File 'lib/imap/backup/client/default.rb', line 60 def disconnect imap.disconnect self.state = nil end |
#examine(mailbox) ⇒ void
This method returns an undefined value.
Prepares read-only access to a folder
67 68 69 70 71 72 |
# File 'lib/imap/backup/client/default.rb', line 67 def examine(mailbox) return if state == [:examine, mailbox] imap.examine(mailbox) self.state = [:examine, mailbox] end |
#list ⇒ Array<String>
Returns the account folders.
28 29 30 31 32 33 34 35 36 |
# File 'lib/imap/backup/client/default.rb', line 28 def list root = provider_root Logger.logger.debug "Listing all account folders" mailbox_lists = imap.list(root, "*") return [] if mailbox_lists.nil? mailbox_lists.map { |ml| extract_name(ml) } end |
#login ⇒ void
This method returns an undefined value.
Logs in to the account on the IMAP server
40 41 42 43 44 |
# File 'lib/imap/backup/client/default.rb', line 40 def login Logger.logger.debug "Logging in: #{account.username}/#{masked_password}" imap.login(account.username, account.password) Logger.logger.debug "Login complete" end |
#reconnect ⇒ void
This method returns an undefined value.
Logs out and back in to the server
48 49 50 51 |
# File 'lib/imap/backup/client/default.rb', line 48 def reconnect disconnect login end |
#select(mailbox) ⇒ void
This method returns an undefined value.
Prepares read-write access to a folder
76 77 78 79 80 81 |
# File 'lib/imap/backup/client/default.rb', line 76 def select(mailbox) return if state == [:select, mailbox] imap.select(mailbox) self.state = [:select, mailbox] end |
#username ⇒ String
Returns the account username.
54 55 56 |
# File 'lib/imap/backup/client/default.rb', line 54 def username account.username end |