Class: OnlyofficeGmailHelper::EmailAccount
- Inherits:
-
Object
- Object
- OnlyofficeGmailHelper::EmailAccount
- Defined in:
- lib/onlyoffice_gmail_helper/email_account.rb
Overview
Class for storing default mail accounts
Class Method Summary collapse
-
.default_account ⇒ MailAccount
Default account for GMail.
-
.read_defaults ⇒ Hash
Read default values for account.
-
.read_env_defaults ⇒ Hash
Read keys from env variables.
Class Method Details
.default_account ⇒ MailAccount
Returns default account for GMail.
30 31 32 |
# File 'lib/onlyoffice_gmail_helper/email_account.rb', line 30 def self.default_account @default_account ||= MailAccount.new(read_defaults[:user], read_defaults[:password]) end |
.read_defaults ⇒ Hash
Read default values for account
10 11 12 13 14 15 16 17 |
# File 'lib/onlyoffice_gmail_helper/email_account.rb', line 10 def self.read_defaults return read_env_defaults if read_env_defaults yaml = YAML.load_file("#{Dir.home}/.gem-onlyoffice_gmail_helper/config.yml") { user: yaml['user'], password: yaml['password'] } rescue Errno::ENOENT raise Errno::ENOENT, 'No config found. Please create ~/.gem-onlyoffice_gmail_helper/config.yml' end |
.read_env_defaults ⇒ Hash
Read keys from env variables
21 22 23 24 25 26 27 |
# File 'lib/onlyoffice_gmail_helper/email_account.rb', line 21 def self.read_env_defaults return false unless ENV.key?('GMAIL_USER') && ENV.key?('GMAIL_PASSWORD') # rubocop:disable Style/FetchEnvVar { user: ENV['GMAIL_USER'], password: ENV['GMAIL_PASSWORD'] } # rubocop:enable Style/FetchEnvVar end |