Skip to content

Commit

Permalink
If there is no config fail on initialize level, not on require level (
Browse files Browse the repository at this point in the history
  • Loading branch information
ShockwaveNN authored Jul 27, 2022
1 parent 0ccc207 commit 97e4e95
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2022-06-28 10:15:51 UTC using RuboCop version 1.31.0.
# on 2022-07-27 14:47:27 UTC using RuboCop version 1.32.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -61,7 +61,7 @@ Style/OptionalBooleanParameter:
Exclude:
- 'lib/onlyoffice_gmail_helper.rb'

# Offense count: 3
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
# URISchemes: http, https
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

* Fix `markdownlint` failure because of old `nodejs` in CI
* Remove `codeclimate` support since we don't use it any more
* If there is no config fail on initialize level, not on `require` level

### Changes

Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ DEPENDENCIES
yard (~> 0, >= 0.9.20)

BUNDLED WITH
2.3.16
2.3.18
6 changes: 3 additions & 3 deletions lib/onlyoffice_gmail_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class Gmail_helper
# @return [String] default label
attr_accessor :label

def initialize(user = EmailAccount::GMAIL_DEFAULT.login, password = EmailAccount::GMAIL_DEFAULT.password, timeout_for_mail = 10, label = nil)
@user = user
@password = password
def initialize(user = nil, password = nil, timeout_for_mail = 10, label = nil)
@user = user || EmailAccount.default_account.login
@password = password || EmailAccount.default_account.password
@gmail = Gmail.new(user, password)
@imap = @gmail.instance_variable_get(:@imap)
@timeout_for_mail = timeout_for_mail
Expand Down
6 changes: 4 additions & 2 deletions lib/onlyoffice_gmail_helper/email_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def self.read_env_defaults
# rubocop:enable Style/FetchEnvVar
end

# @return [MailAccount] default account
GMAIL_DEFAULT = MailAccount.new(read_defaults[:user], read_defaults[:password])
# @return [MailAccount] default account for GMail
def self.default_account
@default_account ||= MailAccount.new(read_defaults[:user], read_defaults[:password])
end
end
end

0 comments on commit 97e4e95

Please sign in to comment.