From 37978dcc3cf09a9da28fa531d40f6fe84e0d8cb3 Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Thu, 25 Apr 2024 16:48:19 -0700 Subject: [PATCH] rm dependency on assertthat --- DESCRIPTION | 1 - NAMESPACE | 1 - R/processData.R | 14 +++++++------- R/prompt.R | 4 ++-- R/skeleton.R | 15 +++++++-------- 5 files changed, 16 insertions(+), 19 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 195ef80..d9daf16 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -55,7 +55,6 @@ Imports: purrr, roxygen2 (>= 6.0.1), devtools (>= 1.12.0), - assertthat, stringr, futile.logger, rprojroot, diff --git a/NAMESPACE b/NAMESPACE index 9422444..95d74d0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -27,7 +27,6 @@ export(yml_list_objects) export(yml_remove_files) export(yml_remove_objects) export(yml_write) -importFrom(assertthat,assert_that) importFrom(crayon,bold) importFrom(crayon,green) importFrom(desc,desc) diff --git a/R/processData.R b/R/processData.R index fb8e987..06770f3 100644 --- a/R/processData.R +++ b/R/processData.R @@ -107,9 +107,9 @@ DataPackageR <- function(arg = NULL, deps = TRUE) { knit = FALSE ) r_files[i] <- paste0(tools::file_path_sans_ext(r_files[i]), ".Rmd") - assert_that(file.exists(r_files[i]), - msg = paste0("File: ", r_files[i], " does not exist!") - ) + if (! file.exists(r_files[i])){ + stop(paste0("File: ", r_files[i], " does not exist!")) + } lines <- readLines(r_files[i]) # do we likely have a yaml header? If not, add one. if (lines[1] != "---") { @@ -247,9 +247,9 @@ validate_yml <- function(pkg_dir){ } .multilog_trace("Reading yaml configuration") # files that have enable: TRUE - assert_that("configuration" %in% names(ymlconf)) - assert_that("files" %in% names(ymlconf[["configuration"]])) - assert_that(!is.null(names(ymlconf[["configuration"]][["files"]]))) + stopifnot("configuration" %in% names(ymlconf)) + stopifnot("files" %in% names(ymlconf[["configuration"]])) + stopifnot(!is.null(names(ymlconf[["configuration"]][["files"]]))) # object with same name as package causes problems with # overwriting documentation files @@ -751,7 +751,7 @@ document <- function(path = ".", install = FALSE, ...) { if (getOption('DataPackageR_verbose', TRUE)) cat("\n") usethis::proj_set(path = path) path <- usethis::proj_get() - assert_that(file.exists(file.path(path, "data-raw", "documentation.R"))) + stopifnot(file.exists(file.path(path, "data-raw", "documentation.R"))) desc <- desc::desc(file.path(path, "DESCRIPTION")) docfile <- paste0(desc$get("Package"), ".R") file.copy( diff --git a/R/prompt.R b/R/prompt.R index 70ec43c..ea4a806 100644 --- a/R/prompt.R +++ b/R/prompt.R @@ -71,8 +71,8 @@ # header_2 <- grep("DataVersion", news_file_data)[2] ul_1 <- grep("=====", news_file_data)[1] # ul_2 <- grep("=====", news_file_data)[2] - assert_that(header_1 == ul_1 - 1) - # assert_that(header_2 == ul_2 - 1) + stopifnot(header_1 == ul_1 - 1) + # stopifnot(header_2 == ul_2 - 1) header <- news_file_data[header_1:ul_1] news_file_data <- news_file_data[-c(header_1:ul_1)] #write header diff --git a/R/skeleton.R b/R/skeleton.R index f87cd2a..6730acb 100644 --- a/R/skeleton.R +++ b/R/skeleton.R @@ -1,16 +1,15 @@ -#' @importFrom assertthat assert_that #' @importFrom purrr map #' @importFrom usethis create_package .codefile_validate <- function(code_files) { # do they exist? - assertthat::assert_that(all(unlist(purrr::map( - code_files, file.exists - ))), msg = "code_files do not all exist!") + if (! all(unlist(purrr::map(code_files, file.exists)))){ + stop("code_files do not all exist!") + } # are the .Rmd files? - assertthat::assert_that(all(grepl(".*\\.r$", tolower(code_files)) | - grepl(".*\\.rmd$", tolower(code_files))), - msg = "code files are not Rmd or R files!" - ) + if (! all(grepl(".*\\.r$", tolower(code_files)) | + grepl(".*\\.rmd$", tolower(code_files)))){ + stop("code files are not Rmd or R files!") + } } #' Create a Data Package skeleton for use with DataPackageR.