Module: Imap::Backup::CLI::Helpers
- Defined in:
- lib/imap/backup/cli/helpers.rb
Class Method Summary collapse
Instance Method Summary collapse
- #account(email) ⇒ Object
- #connection(email) ⇒ Object
- #each_connection(names) ⇒ Object
- #symbolized(options) ⇒ Object
Class Method Details
.included(base) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/imap/backup/cli/helpers.rb', line 6 def self.included(base) base.class_eval do def self.verbose_option method_option( "verbose", type: :boolean, desc: "increase the amount of logging", aliases: ["-v"] ) end def self.quiet_option method_option( "quiet", type: :boolean, desc: "silence all output", aliases: ["-q"] ) end end end |
Instance Method Details
#account(email) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/imap/backup/cli/helpers.rb', line 35 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
43 44 45 46 47 |
# File 'lib/imap/backup/cli/helpers.rb', line 43 def connection(email) account = account(email) Account::Connection.new(account) end |
#each_connection(names) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/imap/backup/cli/helpers.rb', line 49 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
28 29 30 31 32 33 |
# File 'lib/imap/backup/cli/helpers.rb', line 28 def symbolized() .each.with_object({}) do |(k, v), acc| key = k.gsub("-", "_").intern acc[key] = v end end |