1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
## ----echo=FALSE---------------------------------------------------------------
knitr::opts_chunk$set(
comment = "#>",
collapse = TRUE,
warning = FALSE,
message = FALSE,
eval = FALSE
)
## ----eval=FALSE---------------------------------------------------------------
# install.packages("vcr")
## ----eval=FALSE---------------------------------------------------------------
# remotes::install_github("ropensci/vcr")
## -----------------------------------------------------------------------------
# library("vcr")
## ---- echo=FALSE, message=FALSE-----------------------------------------------
library("vcr")
## ----echo=FALSE, results='hide', eval=identical(Sys.getenv("IN_PKGDOWN"), "true")----
# suppressPackageStartupMessages(require(vcr, quietly = TRUE))
# unlink(file.path(cassette_path(), "helloworld.yml"))
# vcr_configure(dir = tempdir())
## ---- eval=identical(Sys.getenv("IN_PKGDOWN"), "true")------------------------
# library(vcr)
# library(crul)
#
# cli <- crul::HttpClient$new(url = "https://eu.httpbin.org")
# system.time(
# use_cassette(name = "helloworld", {
# cli$get("get")
# })
# )
## ---- eval=identical(Sys.getenv("IN_PKGDOWN"), "true")------------------------
# system.time(
# use_cassette(name = "helloworld", {
# cli$get("get")
# })
# )
## ----echo=FALSE, eval=identical(Sys.getenv("IN_PKGDOWN"), "true")-------------
# unlink(file.path(cassette_path(), "helloworld.yml"))
## ---- echo = FALSE, results='asis', collapse=TRUE-----------------------------
defaults <- rev(vcr_config_defaults())
defaults[unlist(lapply(defaults, is.character))] <- paste0('"', defaults[unlist(lapply(defaults, is.character))], '"')
cat(sprintf("* %s = `%s`\n", names(defaults), defaults))
## -----------------------------------------------------------------------------
vcr_configuration()
## ----echo=FALSE---------------------------------------------------------------
unlink(file.path(cassette_path(), "one.yml"))
## ----eval = FALSE-------------------------------------------------------------
# use_cassette(name = "one", {
# cli$post("post", body = list(a = 5))
# },
# match_requests_on = c('method', 'headers', 'body')
# )
|