Class: Papermill::ResponseAdapters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/papermill-agent/response_adapters/base.rb

Direct Known Subclasses

Rails, Sinatra

Constant Summary collapse

ENV_CAPTURE_FIELDS =
[
  'PATH_INFO', 'QUERY_STRING', 'REMOTE_ADDR', 'REMOTE_HOST', 'REQUEST_METHOD',
  'REQUEST_URI', 'SCRIPT_NAME', 'SERVER_NAME', 'SERVER_SOFTWARE', 'HTTP_HOST',
  'HTTP_ACCEPT', 'HTTP_USER_AGENT', 'REQUEST_PATH', 'rack.url_scheme',
  'HTTP_REFERER'
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, headers, response, env = {}) ⇒ Base

Returns a new instance of Base.



14
15
16
# File 'lib/papermill-agent/response_adapters/base.rb', line 14

def initialize(status, headers, response, env = {})
  @status, @headers, @response, @env = status, headers, response, env
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



13
14
15
# File 'lib/papermill-agent/response_adapters/base.rb', line 13

def env
  @env
end

#headersObject (readonly)

Returns the value of attribute headers.



13
14
15
# File 'lib/papermill-agent/response_adapters/base.rb', line 13

def headers
  @headers
end

#responseObject (readonly)

Returns the value of attribute response.



13
14
15
# File 'lib/papermill-agent/response_adapters/base.rb', line 13

def response
  @response
end

#statusObject (readonly)

Returns the value of attribute status.



13
14
15
# File 'lib/papermill-agent/response_adapters/base.rb', line 13

def status
  @status
end

Instance Method Details

#parseObject



18
19
20
21
22
23
24
25
# File 'lib/papermill-agent/response_adapters/base.rb', line 18

def parse
  parsed_response = { :headers => extract_env_info, :status => status }
  # if @status != 304 && @response #&& [email protected]_a?(Proc)
  #   parsed_response.merge!(prepare_extra_fields)
  # end
  parsed_response.merge!(additional_response_data)
  Papermill::Storage.store << parsed_response
end