Learn R Programming

vcr (version 0.2.6)

vcr_configure: Configuration

Description

Configuration

Usage

vcr_configure(dir = ".", record = "once",
  match_requests_on = c("method", "uri"),
  allow_unused_http_interactions = TRUE, serialize_with = "yaml",
  persist_with = "FileSystem", ignore_hosts = NULL,
  ignore_localhost = FALSE, ignore_request = NULL,
  uri_parser = "crul::url_parse", preserve_exact_body_bytes = FALSE,
  turned_off = FALSE, ignore_cassettes = FALSE,
  re_record_interval = NULL, clean_outdated_http_interactions = NULL,
  allow_http_connections_when_no_cassette = FALSE, cassettes = list(),
  linked_context = NULL, log = FALSE, log_opts = list(file =
  "vcr.log", log_prefix = "Cassette", date = TRUE),
  filter_sensitive_data = NULL)

vcr_configure_reset()

vcr_configuration()

vcr_config_defaults()

Arguments

dir

Cassette directory

record

(character) One of 'all', 'none', 'new_episodes', or 'once'. See recording

match_requests_on

vector of matchers. Default: (method, uri) See request-matching for details.

allow_unused_http_interactions

(logical) Default: TRUE

serialize_with

(character) only option is "yaml"

persist_with

(character) only option is "FileSystem"

ignore_hosts

(character) Vector of hosts to ignore. e.g., localhost, or google.com. These hosts are ignored and real HTTP requests allowed to go through

ignore_localhost

(logical) Default: FALSE

ignore_request

List of requests to ignore

uri_parser

the uri parser, default: crul::url_parse()

preserve_exact_body_bytes

(logical) preserve exact body bytes for

turned_off

(logical) VCR is turned on by default. Default: FALSE

ignore_cassettes

(logical) Ignore cassettes. You can set this to TRUE when you don't have a cassette in use but still want to make HTTP requests. Otherwise, you can't make requests unless a cassette is in use. Default: FALSE

re_record_interval

(numeric) When given, the cassette will be re-recorded at the given interval, in seconds.

clean_outdated_http_interactions

(logical) Should outdated interactions be recorded back to file. Default: FALSE

allow_http_connections_when_no_cassette

(logical) Determines how vcr treats HTTP requests that are made when no vcr cassette is in use. When TRUE, requests made when there is no vcr cassette in use will be allowed. When FALSE (default), an UnhandledHTTPRequestError error will be raised for any HTTP request made when there is no cassette in use

cassettes

(list) don't use

linked_context

(logical) linked context

log

(logical) should we log important vcr things? Default: FALSE

log_opts

(list) Additional logging options. Options include:

  • file: one of a file path to log to or "console"

  • log_prefix: default: "Cassette". We insert the cassette name after that prefix, then the rest of the message

  • more to come

filter_sensitive_data

(list) named list of values to replace. format is: list(thing_to_replace = thing_to_replace_it_with). We replace all instances of thing_to_replace with thing_to_replace_it_with. Before recording (writing to a cassette) we do the replacement and then when reading from the cassette we do the reverse replacement to get back to the real data. Before record replacement happens in internal function write_interactions(), while before playback replacement happens in internal function YAML$deserialize_path()

Examples

Run this code
# NOT RUN {
vcr_configure(dir = tempdir())
vcr_configure(dir = tempdir(), record = "all")
vcr_configuration()
vcr_config_defaults()
vcr_configure(tempdir(), ignore_localhost = TRUE)

# logging
vcr_configure(tempdir(), log = TRUE, 
  log_opts = list(file = file.path(tempdir(), "vcr.log")))
vcr_configure(tempdir(), log = TRUE, log_opts = list(file = "console"))
vcr_configure(tempdir(), log = TRUE,
 log_opts = list(
   file = file.path(tempdir(), "vcr.log"), 
   log_prefix = "foobar"
))
vcr_configure(tempdir(), log = FALSE)

# filter sensitive data
vcr_configure(tempdir(), 
  filter_sensitive_data = list(foo = "<bar>")
)
vcr_configure(tempdir(), 
  filter_sensitive_data = list(foo = "<bar>", hello = "<world>")
)
# }

Run the code above in your browser using DataLab