Class: Webpagetest::Response

Inherits:
Object
  • Object
show all
Includes:
Connection
Defined in:
lib/webpagetest/response.rb

Overview

Custom response class for Webpagetest test data

Constant Summary collapse

STATUS_BASE =
'testStatus.php'
RESULT_BASE =
'jsonResult.php'

Constants included from Connection

Connection::ENDPOINT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Connection

#get_connection

Constructor Details

#initialize(raw_response, running = true) ⇒ Response

Returns a new instance of Response.



12
13
14
15
# File 'lib/webpagetest/response.rb', line 12

def initialize(raw_response, running=true)
  @raw = raw_response
  @test_id = !running && raw_response.statusCode == 200 ? raw.data.id : raw.data.testId
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



7
8
9
# File 'lib/webpagetest/response.rb', line 7

def raw
  @raw
end

#resultObject (readonly)

Returns the value of attribute result.



7
8
9
# File 'lib/webpagetest/response.rb', line 7

def result
  @result
end

#statusObject (readonly)

Returns the value of attribute status.



7
8
9
# File 'lib/webpagetest/response.rb', line 7

def status
  @status
end

#test_idObject (readonly)

Returns the value of attribute test_id.



7
8
9
# File 'lib/webpagetest/response.rb', line 7

def test_id
  @test_id
end

Instance Method Details

#get_statusObject

Gets the status of the request (code from Susuwatari gem)



18
19
20
21
# File 'lib/webpagetest/response.rb', line 18

def get_status
  fetch_status unless status == :completed
  status
end