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
8 9 10 11 12 13 |
# File 'lib/imap/backup/cli/helpers.rb', line 8 def account(email) connections = Imap::Backup::Configuration::List.new account = connections.accounts.find { |a| a[:username] == email } raise "#{email} is not a configured account" if !account account end |
#connection(email) ⇒ Object
15 16 17 18 19 |
# File 'lib/imap/backup/cli/helpers.rb', line 15 def connection(email) account = account(email) Imap::Backup::Account::Connection.new(account) end |
#each_connection(names) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/imap/backup/cli/helpers.rb', line 21 def each_connection(names) begin connections = Imap::Backup::Configuration::List.new(names) rescue Imap::Backup::ConfigurationNotFound raise "imap-backup is not configured. Run `imap-backup setup`" end connections.each_connection do |connection| yield connection end end |
#symbolized(options) ⇒ Object
4 5 6 |
# File 'lib/imap/backup/cli/helpers.rb', line 4 def symbolized() .each.with_object({}) { |(k, v), acc| acc[k.intern] = v } end |