Learn R Programming

vcr (version 0.2.6)

Cassette: Cassette handler

Description

Cassette handler

Arguments

name

The name of the cassette. vcr will sanitize this to ensure it is a valid file name.

record

The record mode. Default: "once". In the future we'll support "once", "all", "none", "new_episodes". See recording for more information

serialize_with

(character) Which serializer to use. Valid values are "yaml" (default), the only one supported for now.

persist_with

(character) Which cassette persister to use. Default: "file_system". You can also register and use a custom persister.

match_requests_on

List of request matchers to use to determine what recorded HTTP interaction to replay. Defaults to ["method", "uri"]. The built-in matchers are "method", "uri", "host", "path", "headers" and "body"

update_content_length_header

(logical) Whether or not to overwrite the Content-Length header of the responses to match the length of the response body. Default: FALSE

allow_playback_repeats

(logical) Whether or not to allow a single HTTP interaction to be played back multiple times. Default: FALSE.

preserve_exact_body_bytes

(logical) Whether or not to base64 encode the bytes of the requests and responses for this cassette when serializing it. See also preserve_exact_body_bytes in vcr_configure(). Default: FALSE

Value

an object of class Cassette

Details

Methods

eject()

Coming soon.

file()

Get path to the man file for the cassette.

recording()

Find out whether recording is happening or not.

originally_recorded_at()

Time interaction was originally recorded at.

serializable_hash()

A hash with stuff.

should_remove_matching_existing_interactions()

Set record mode to "all".

storage_key()

Generate file name = cassette name plus file extension.

make_dir()

Make cassette directory.

raw_string()

Get raw string of the cassette (cached interaction).

deserialized_hash()

Get a deserialized hash.

make_args()

Initialize default args.

write_metadata()

Write metadata to disk.

previously_recorded_interactions()

Coming soon.

serialize_to_crul

Serialize interaction on disk/cassette to a crul response

See Also

vcr_configure(), use_cassette(), insert_cassette()

Examples

Run this code
# NOT RUN {
library(vcr)
vcr_configure(dir = tempdir())

res <- Cassette$new(name = "bob")
res$file()
res$originally_recorded_at()
res$recording()
res$serializable_hash()
res$eject()
res$should_remove_matching_existing_interactions()
res$storage_key()
res$match_requests_on

# record all requests
res <- Cassette$new("foobar", record = "all")
res$eject()

# cleanup
unlink(file.path(tempdir(), c("bob.yml", "foobar.yml")))
# }

Run the code above in your browser using DataLab