Class: Stratagem::Authentication
- Includes:
- Singleton
- Defined in:
- lib/stratagem/authentication.rb
Constant Summary collapse
- FILENAME =
'.stratagem'
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #base_url ⇒ Object
- #credentials ⇒ Object
- #project_url ⇒ Object
- #store_credentials(account, token, project) ⇒ Object
- #url ⇒ Object
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
10 11 12 |
# File 'lib/stratagem/authentication.rb', line 10 def project @project end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
10 11 12 |
# File 'lib/stratagem/authentication.rb', line 10 def token @token end |
Instance Method Details
#base_url ⇒ Object
29 30 31 32 |
# File 'lib/stratagem/authentication.rb', line 29 def base_url subdomain = credentials ? credentials[:account] : 'www' "https://#{subdomain}.stratagemapp.com" end |
#credentials ⇒ Object
38 39 40 |
# File 'lib/stratagem/authentication.rb', line 38 def credentials @credentials ||= load_credentials end |
#project_url ⇒ Object
34 35 36 |
# File 'lib/stratagem/authentication.rb', line 34 def project_url "#{base_url}/projects/#{credentials[:project]}?auth_token=#{credentials[:token]}" end |
#store_credentials(account, token, project) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/stratagem/authentication.rb', line 12 def store_credentials(account, token, project) File.open(FILENAME, 'w') do |f| f.puts account f.puts token f.puts project end reload_credentials end |
#url ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/stratagem/authentication.rb', line 21 def url if (credentials.nil?) base_url+"/project_links/new" else base_url+"/project_links/validate/#{credentials[:project]}?auth_token=#{credentials[:token]}" end end |