Module: Imap::Backup::CLI::Helpers
- Included in:
- Imap::Backup::CLI, Backup, Local, Local::Check, Remote, Restore, Setup, Single, Stats, Transfer, Utils
- Defined in:
- lib/imap/backup/cli/helpers.rb
Instance Method Summary collapse
- #account(config, email) ⇒ Object
- #load_config(**options) ⇒ Object
- #options ⇒ Object
- #requested_accounts(config) ⇒ Object
Instance Method Details
#account(config, email) ⇒ Object
105 106 107 108 109 110 |
# File 'lib/imap/backup/cli/helpers.rb', line 105 def account(config, email) account = config.accounts.find { |a| a.username == email } raise "#{email} is not a configured account" if !account account end |
#load_config(**options) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/imap/backup/cli/helpers.rb', line 92 def load_config(**) path = [:config] require_exists = .key?(:require_exists) ? [:require_exists] : true if require_exists exists = Configuration.exist?(path: path) if !exists expected = path || Configuration.default_pathname raise ConfigurationNotFound, "Configuration file '#{expected}' not found" end end Configuration.new(path: path) end |
#options ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/imap/backup/cli/helpers.rb', line 76 def @symbolized_options ||= # rubocop:disable Naming/MemoizedInstanceVariableName begin = super() .each.with_object({}) do |(k, v), acc| key = if k.is_a?(String) k.gsub("-", "_").intern else k end acc[key] = v end end end |
#requested_accounts(config) ⇒ Object
112 113 114 115 116 117 118 119 |
# File 'lib/imap/backup/cli/helpers.rb', line 112 def requested_accounts(config) emails = ([:accounts] || "").split(",") if emails.any? config.accounts.filter { |a| emails.include?(a.username) } else config.accounts end end |