Class: Imap::Backup::Client::Default

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/imap/backup/client/default.rb

Direct Known Subclasses

AppleMail

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, account, options) ⇒ Default

Returns a new instance of Default.



19
20
21
22
23
24
# File 'lib/imap/backup/client/default.rb', line 19

def initialize(server, , options)
  @account = 
  @options = options
  @server = server
  @state = nil
end

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



14
15
16
# File 'lib/imap/backup/client/default.rb', line 14

def 
  @account
end

#optionsObject (readonly)

Returns the value of attribute options.



15
16
17
# File 'lib/imap/backup/client/default.rb', line 15

def options
  @options
end

#serverObject (readonly)

Returns the value of attribute server.



16
17
18
# File 'lib/imap/backup/client/default.rb', line 16

def server
  @server
end

#stateObject

Returns the value of attribute state.



17
18
19
# File 'lib/imap/backup/client/default.rb', line 17

def state
  @state
end

Instance Method Details

#disconnectObject

Track mailbox selection during delegation to Net::IMAP instance



52
53
54
55
# File 'lib/imap/backup/client/default.rb', line 52

def disconnect
  imap.disconnect
  self.state = nil
end

#examine(mailbox) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/imap/backup/client/default.rb', line 57

def examine(mailbox)
  return if state == [:examine, mailbox]

  result = imap.examine(mailbox)
  self.state = [:examine, mailbox]
  result
end

#listObject



26
27
28
29
30
31
32
33
# File 'lib/imap/backup/client/default.rb', line 26

def list
  root = provider_root
  mailbox_lists = imap.list(root, "*")

  return [] if mailbox_lists.nil?

  mailbox_lists.map { |ml| extract_name(ml) }
end

#loginObject



35
36
37
38
39
# File 'lib/imap/backup/client/default.rb', line 35

def 
  Logger.logger.debug "Logging in: #{account.username}/#{masked_password}"
  imap.(.username, .password)
  Logger.logger.debug "Login complete"
end

#reconnectObject



41
42
43
44
# File 'lib/imap/backup/client/default.rb', line 41

def reconnect
  disconnect
  
end

#select(mailbox) ⇒ Object



65
66
67
68
69
70
# File 'lib/imap/backup/client/default.rb', line 65

def select(mailbox)
  return if state == [:select, mailbox]

  imap.select(mailbox)
  self.state = [:select, mailbox]
end

#usernameObject



46
47
48
# File 'lib/imap/backup/client/default.rb', line 46

def username
  .username
end