lib/deploygate/session.rb in deploygate-0.2.0 vs lib/deploygate/session.rb in deploygate-0.2.1

- old
+ new

@@ -3,10 +3,15 @@ class LoginError < DeployGate::NotIssueError end attr_reader :name, :token + module ENVKey + DG_USER_NAME = 'DG_USER_NAME' + DG_TOKEN = 'DG_TOKEN' + end + @@login = nil # @return [DeployGate::Session] def initialize load_setting @@ -53,13 +58,23 @@ private # @return [void] def load_setting + return if load_env return unless Config::Credential.exist? settings = Config::Credential.read + @name = settings['name'] @token = settings['token'] + end + + # @return [Boolean] + def load_env + @name = ENV[ENVKey::DG_USER_NAME] + @token = ENV[ENVKey::DG_TOKEN] + + @name.present? && @token.present? end end end