Class: Televideo::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/televideo/server.rb

Constant Summary collapse

HEADER_PREFIX =
'HTTP_X_TELEVIDEO'
HEADER_CASSETTE_NAME =
"#{HEADER_PREFIX}_CASSETTE_NAME"
CUSTOM_HEADERS =
[
  HEADER_CASSETTE_NAME,
]

Instance Method Summary collapse

Constructor Details

#initialize(cassette:, uri:, https: false, vcr_options: {}) ⇒ Server

Returns a new instance of Server.



11
12
13
14
15
16
# File 'lib/televideo/server.rb', line 11

def initialize(cassette:, uri:, https: false, vcr_options: {})
  @cassette = cassette
  @uri = @uri.is_a?(URI) ? uri : URI(uri)
  @vcr_options = vcr_options
  @https = https
end

Instance Method Details

#call(env) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/televideo/server.rb', line 18

def call(env)
  name = cassette_name_from_env(env)
  res = VCR::use_cassette(name, @vcr_options) { run_request(env) }
  [
    res.code,
    headers_from_response(res),
    [res.body]
  ]
end