Class: Travis::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/travis/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



8
9
10
# File 'lib/travis/client.rb', line 8

def initialize
  @connection = create_connection
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



6
7
8
# File 'lib/travis/client.rb', line 6

def connection
  @connection
end

Instance Method Details

#fetch_config(job_id) ⇒ Object

TODO: this needs to be fixed before going too far, returning body without

ability to inspect response or returning nil on any failure are not
the best ways to deal with API client


15
16
17
18
19
20
21
22
23
# File 'lib/travis/client.rb', line 15

def fetch_config(job_id)
  response = get("/jobs/#{job_id}")
  if (200..299).include?(response.status)
    response.body['job']['config']
  else
    # TODO: I should probably raise here
    nil
  end
end