Class: FoggyBottom::Api
- Inherits:
-
Object
- Object
- FoggyBottom::Api
- Defined in:
- lib/foggy_bottom/api.rb
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#token ⇒ Object
Returns the value of attribute token.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #exec(cmd, args = {}) ⇒ Object
- #find(issue_id) ⇒ Object (also: #[])
-
#initialize(url, username, password) ⇒ Api
constructor
A new instance of Api.
- #search(terms) ⇒ Object
Constructor Details
#initialize(url, username, password) ⇒ Api
Returns a new instance of Api.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/foggy_bottom/api.rb', line 6 def initialize( url, username, password ) @logger = Logger.new(STDOUT).tap {|l| l.level = Logger::DEBUG } @url = url[-1] == '/' ? url : "#{url}/" token_filename = File.( "~/.foggy_bottom_token_" + Digest::SHA2.hexdigest("#{username}_#{password}") ) if File.exists?(token_filename) load_details(token_filename) else fetch_endpoint fetch_token(username, password, token_filename) end end |
Instance Attribute Details
#endpoint ⇒ Object
Returns the value of attribute endpoint.
3 4 5 |
# File 'lib/foggy_bottom/api.rb', line 3 def endpoint @endpoint end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
4 5 6 |
# File 'lib/foggy_bottom/api.rb', line 4 def logger @logger end |
#token ⇒ Object
Returns the value of attribute token.
3 4 5 |
# File 'lib/foggy_bottom/api.rb', line 3 def token @token end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/foggy_bottom/api.rb', line 3 def url @url end |
Instance Method Details
#exec(cmd, args = {}) ⇒ Object
20 21 22 |
# File 'lib/foggy_bottom/api.rb', line 20 def exec(cmd, args = {}) get(build_url(cmd, args)) end |