Module: Imap::Backup::CLI::Helpers
- Defined in:
- lib/imap/backup/cli/helpers.rb
Instance Method Summary collapse
- #account(email) ⇒ Object
- #connection(email) ⇒ Object
- #each_connection(names) ⇒ Object
- #symbolized(options) ⇒ Object
Instance Method Details
#account(email) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/imap/backup/cli/helpers.rb', line 13 def account(email) accounts = CLI::Accounts.new account = accounts.find { |a| a.username == email } raise "#{email} is not a configured account" if !account account end |
#connection(email) ⇒ Object
21 22 23 24 25 |
# File 'lib/imap/backup/cli/helpers.rb', line 21 def connection(email) account = account(email) Account::Connection.new(account) end |
#each_connection(names) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/imap/backup/cli/helpers.rb', line 27 def each_connection(names) accounts = CLI::Accounts.new(names) accounts.each do |account| yield account.connection end rescue ConfigurationNotFound raise "imap-backup is not configured. Run `imap-backup setup`" end |
#symbolized(options) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/imap/backup/cli/helpers.rb', line 6 def symbolized() .each.with_object({}) do |(k, v), acc| key = k.gsub("-", "_").intern acc[key] = v end end |