Skip to content
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ Suggests:
lifecycle,
mockr,
rmarkdown,
testthat,
testthat (>= 3.0.0),
withr
VignetteBuilder:
knitr
Config/testthat/edition: 3
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
Expand Down
61 changes: 0 additions & 61 deletions R/criterion.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,64 +122,3 @@ check_testfun <- function(testfun) {

testfun
}

#' @rdname root_criterion
#' @param x An object
#' @export
is_root_criterion <- function(x) {
inherits(x, "root_criterion")
}

#' @rdname root_criterion
#' @export
as_root_criterion <- function(x) UseMethod("as_root_criterion", x)

#' @details
#' The `as_root_criterion()` function accepts objects of class
#' `root_criterion`, and character values; the latter will be
#' converted to criteria using `has_file`.
#'
#' @rdname root_criterion
#' @export
as_root_criterion.character <- function(x) {
has_file(x)
}

#' @rdname root_criterion
#' @export
as_root_criterion.root_criterion <- identity

#' @export
as_root_criterion.default <- function(x) {
stop("Cannot coerce ", x, " to type root_criterion.", call. = FALSE)
}

#' @export
format.root_criterion <- function(x, ...) {
if (length(x$desc) > 1) {
c("Root criterion: one of", paste0("- ", x$desc))
} else {
paste0("Root criterion: ", x$desc)
}
}

#' @export
print.root_criterion <- function(x, ...) {
cat(format(x), sep = "\n")
invisible(x)
}

#' @export
#' @rdname root_criterion
#' @details Root criteria can be combined with the `|` operator. The result is a
#' composite root criterion that requires either of the original criteria to
#' match.
#' @param y An object
`|.root_criterion` <- function(x, y) {
stopifnot(is_root_criterion(y))

root_criterion(
c(x$testfun, y$testfun),
c(x$desc, y$desc)
)
}
276 changes: 0 additions & 276 deletions R/has-file.R

This file was deleted.

7 changes: 5 additions & 2 deletions R/path.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ path <- function(...) {
}

# Side effect: check recycling rules
components <- as.data.frame(dots, stringsAsFactors = FALSE)
component_df <- as.data.frame(dots, stringsAsFactors = FALSE)

missing <- apply(is.na(components), 1, any)
missing <- apply(is.na(component_df), 1, any)

components <- lapply(component_df, function(x) enc2utf8(as.character(x)))

out <- do.call(file.path, components)
out[missing] <- NA_character_
Encoding(out) <- "UTF-8"
out
}
Loading