class Sem::Configuration

Constants

API_URL_PATH
CREDENTIALS_PATH
DEFAULT_API_URL

Public Class Methods

api_url() click to toggle source
# File lib/sem/configuration.rb, line 35
def api_url
  return DEFAULT_API_URL unless File.file?(API_URL_PATH)

  File.read(API_URL_PATH).strip
end
auth_token() click to toggle source
# File lib/sem/configuration.rb, line 29
def auth_token
  raise Sem::Errors::Auth::NoCredentials unless File.file?(CREDENTIALS_PATH)

  File.read(CREDENTIALS_PATH).strip
end
delete_auth_token() click to toggle source
# File lib/sem/configuration.rb, line 25
def delete_auth_token
  FileUtils.rm_f(CREDENTIALS_PATH)
end
export_auth_token(auth_token) click to toggle source
# File lib/sem/configuration.rb, line 17
def export_auth_token(auth_token)
  dirname = File.dirname(CREDENTIALS_PATH)
  FileUtils.mkdir_p(dirname)

  File.write(CREDENTIALS_PATH, auth_token)
  File.chmod(0o0600, CREDENTIALS_PATH)
end
valid_auth_token?(auth_token) click to toggle source
# File lib/sem/configuration.rb, line 9
def valid_auth_token?(auth_token)
  Sem::API::Base.create_new_api_client(api_url, auth_token).orgs.list!

  true
rescue SemaphoreClient::Exceptions::Base
  false
end