Check where we all are compared to the instructions.
For info, R-universe API docs.
Generate a repository from the template repository1
usethis::create_from_github("YOURUSERNAME/applepie")
.
Open RStudio project.
Optional: look for occurrences of “maelle” (README, DESCRIPTION) and replace them with your username.
get_packages("ggseg")
usethis::use_test("packages")
(testthat expectations)
test_that("get_packages() works", {
pkgs <- get_packages("maelle")
expect_vector(pkgs, character())
})
devtools::test()
or test button on the file or test via the build panel. Possibility to set keyboard shortcuts.
Add a new function use_r("maintainers")
, use_package("withr")
, use_package("tibble")
.
#' Maintainers
#'
#' @inheritParams get_packages
#'
#' @return A character vector.
#' @export
#'
#' @examples
#' get_maintainers("ggseg")
get_maintainers <- function(universe) {
url <- sprintf("https://%s.r-universe.dev/stats/maintainers", universe)
resp <- httr::GET(url)
httr::stop_for_status(resp)
content <- httr::content(resp)
temp_file <- withr::local_tempfile()
writeLines(content, temp_file)
maintainers <- jsonlite::stream_in(file(temp_file), verbose = FALSE)
tibble::as_tibble(maintainers)
}
use_coverage()
usethis::use_github_action("test-coverage-pak")
BACK TO SLIDES.
Read example test, delete it.
Insert vcr::use_cassette("packages")
in a test. Have a look at the files added. If this were not an online tutorial, turn off wifi and run the test again, it works!
test_that("get_packages() works", {
vcr::use_cassette("packages", {
pkgs <- get_packages("maelle")
})
expect_vector(pkgs, character())
})
Why applepie? I nominate "applepie" https://t.co/dBxTjiwYvO{=html}
↩︎