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(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
28 29 30 31 |
# File 'lib/stratagem/authentication.rb', line 28 def base_url protocol = Stratagem.ssl? ? 'https' : 'http' "#{protocol}://#{Stratagem.domain}" end |
#credentials ⇒ Object
37 38 39 |
# File 'lib/stratagem/authentication.rb', line 37 def credentials @credentials ||= load_credentials end |
#project_url ⇒ Object
33 34 35 |
# File 'lib/stratagem/authentication.rb', line 33 def project_url "#{base_url}/projects/#{credentials[:project]}?auth_token=#{credentials[:token]}" end |
#store_credentials(token, project) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/stratagem/authentication.rb', line 12 def store_credentials(token, project) File.open(FILENAME, 'w') do |f| f.puts token f.puts project end reload_credentials end |
#url ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/stratagem/authentication.rb', line 20 def url if (credentials.nil?) base_url+"/project_links/new" else base_url+"/project_links/validate/#{credentials[:project]}?auth_token=#{credentials[:token]}" end end |