Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on assertthat #135

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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