Class: FoggyBottom::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/foggy_bottom/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.expand_path( "~/.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

#endpointObject

Returns the value of attribute endpoint.



3
4
5
# File 'lib/foggy_bottom/api.rb', line 3

def endpoint
  @endpoint
end

#loggerObject (readonly)

Returns the value of attribute logger.



4
5
6
# File 'lib/foggy_bottom/api.rb', line 4

def logger
  @logger
end

#tokenObject

Returns the value of attribute token.



3
4
5
# File 'lib/foggy_bottom/api.rb', line 3

def token
  @token
end

#urlObject

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

#find(issue_id) ⇒ Object Also known as: []



24
25
26
# File 'lib/foggy_bottom/api.rb', line 24

def find( issue_id )
  Case.find(issue_id, self)
end

#search(terms) ⇒ Object



29
30
31
# File 'lib/foggy_bottom/api.rb', line 29

def search( terms )
  Case.search(terms, self)
end