Class: Holistics::Helpers::AuthInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/holistics/helpers/auth_info.rb

Instance Method Summary collapse

Instance Method Details

#api_url_for(path, params = {}) ⇒ Object



15
16
17
# File 'lib/holistics/helpers/auth_info.rb', line 15

def api_url_for(path, params = {})
  "#{http_request.server_url}#{path}?#{URI.encode_www_form(params)}"
end

#authenticated?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/holistics/helpers/auth_info.rb', line 11

def authenticated?
  File.exists?(get_gconfig_filepath)
end

#get_gconfig_filepathObject



28
29
30
# File 'lib/holistics/helpers/auth_info.rb', line 28

def get_gconfig_filepath
  File.expand_path('~/.holistics.yml', __FILE__)
end

#get_token_from_gconfigObject



19
20
21
22
23
24
25
26
# File 'lib/holistics/helpers/auth_info.rb', line 19

def get_token_from_gconfig
  if authenticated?
    string = YAML.load_file(get_gconfig_filepath)
    string['token']
  else
    raise StandardError.new 'Holistics config file not found'
  end
end

#http_requestObject



7
8
9
# File 'lib/holistics/helpers/auth_info.rb', line 7

def http_request
  @http_helper ||= Helpers::HttpRequest.new
end