Class: Holistics::Helpers::AuthInfo
- Inherits:
-
Object
- Object
- Holistics::Helpers::AuthInfo
- Defined in:
- lib/holistics/helpers/auth_info.rb
Instance Method Summary collapse
- #api_url_for(path, params = {}) ⇒ Object
- #authenticated? ⇒ Boolean
- #get_gconfig_filepath ⇒ Object
- #get_token_from_gconfig ⇒ Object
- #http_request ⇒ Object
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
11 12 13 |
# File 'lib/holistics/helpers/auth_info.rb', line 11 def authenticated? File.exists?(get_gconfig_filepath) end |
#get_gconfig_filepath ⇒ Object
28 29 30 |
# File 'lib/holistics/helpers/auth_info.rb', line 28 def get_gconfig_filepath File.('~/.holistics.yml', __FILE__) end |
#get_token_from_gconfig ⇒ Object
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_request ⇒ Object
7 8 9 |
# File 'lib/holistics/helpers/auth_info.rb', line 7 def http_request @http_helper ||= Helpers::HttpRequest.new end |