Learn R Programming

vcr (version 0.2.6)

FileSystem: File system persister

Description

File system persister

Arguments

file_name

(character) Just the file name, not whole path

content

(character) content to record to a cassette

path

(character) Storage directory for cassettes

write2disk

(logical) write to disk or just make a new FileSystem object. Default: FALSE

Details

The only built-in cassette persister. Persists cassettes to the file system.

Methods

get_cassette(file_name = NULL, content = NULL, path = NULL)

Gets the cassette for the given storage key (file name).

set_cassette(file_name = NULL, content)

Sets the cassette for the given storage key (file name).

is_empty()

Checks if a cassette is empty or not. Returns boolean

Private Methods

storage_location()

Get storage location

absolute_path_to_file()

Get absolute path to the storage_location

Examples

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

(yy <- FileSystem$new(file_name = "file4014931b21b.yml"))
yy$set_cassette(content = "hello world!")

# is empty?
yy$is_empty()

# get cassette
yy$get_cassette(file_name = "file4014931b21b.yml")

# clenaup
unlink(file.path(tempdir(), "file4014931b21b.yml"))
# }

Run the code above in your browser using DataLab