Skip to content

Commit

Permalink
Merge pull request #135 from ropensci/assertthatnot
Browse files Browse the repository at this point in the history
Remove dependency on assertthat
  • Loading branch information
slager committed Apr 26, 2024
2 parents abd0baa + 37978dc commit 73b8111
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Expand Up @@ -55,7 +55,6 @@ Imports:
purrr,
roxygen2 (>= 6.0.1),
devtools (>= 1.12.0),
assertthat,
stringr,
futile.logger,
rprojroot,
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions R/processData.R
Expand Up @@ -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] != "---") {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions R/prompt.R
Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions 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.
Expand Down

0 comments on commit 73b8111

Please sign in to comment.