diff --git a/DESCRIPTION b/DESCRIPTION index cb08edf..8ac4cd9 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: chex Title: Run Checks -Version: 0.1.2 +Version: 0.1.3 Authors@R: person(given = "Shun", family = "Sambongi", @@ -26,10 +26,11 @@ Suggests: logger, mockery, rmarkdown, - testthat + testthat, + withr VignetteBuilder: knitr Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.1.0 +RoxygenNote: 7.1.1 diff --git a/NEWS.md b/NEWS.md index f8c8f43..cf9d392 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# chex 0.1.3 + +* Hotfix: fix package log_appender + # chex 0.1.2 * Bugfix: logging ignores formatting and uses result descriptions as-is. diff --git a/R/logging.R b/R/logging.R index 3eacd7b..cf6e510 100755 --- a/R/logging.R +++ b/R/logging.R @@ -20,3 +20,19 @@ log_result <- function(result) { } invisible(result) } + +init_logging <- function() { + if (!requireNamespace("logger", quietly = TRUE)) { + return(invisible()) + } + + try(silent = TRUE, { + namespaces <- get( + "namespaces", envir = asNamespace("logger"), mode = "environment" + ) + if (!exists("chex", namespaces)) { + logger::log_appender(identity, namespace = "chex") + } + }) + invisible() +} diff --git a/R/zzz.R b/R/zzz.R index c5e2cf6..93a7214 100755 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,5 +1,4 @@ .onLoad <- function(...) { - logger::log_appender(identity, namespace = "chex") + init_logging() vctrs::s3_register("dplyr::filter", "chex_result") } - diff --git a/man/result.Rd b/man/result.Rd index d7a2e64..1896a33 100755 --- a/man/result.Rd +++ b/man/result.Rd @@ -12,7 +12,7 @@ result(status, description) \item logical vector (\code{TRUE} / \code{FALSE}) \item character vector (\code{"PASS"}, \code{"FAIL"}, etc.) \item \code{chex::PASS} or \code{chex::FAIL} -\item value of \code{\link[chex:PASS]{chex::PASS()}} or \code{\link[chex:FAIL]{chex::FAIL()}} +\item value of \code{\link[=PASS]{PASS()}} or \code{\link[=FAIL]{FAIL()}} }} \item{description}{the description of the result} diff --git a/man/run_check.Rd b/man/run_check.Rd index c45a472..4ce518b 100755 --- a/man/run_check.Rd +++ b/man/run_check.Rd @@ -18,7 +18,7 @@ fail value. There are a few types which are recognized as pass or fail. \itemize{ \item logical values \code{TRUE} and \code{FALSE} which are recognized as pass and fail, respectively -\item \code{chex::PASS} or the result of calling \code{\link[chex:PASS]{chex::PASS()}} with a reason +\item \code{chex::PASS} or the result of calling \code{\link[=PASS]{PASS()}} with a reason \item likewise for \code{chex::FAIL} \item A result object created by \code{\link[=result]{result()}} } diff --git a/tests/testthat/test-result.R b/tests/testthat/test-result.R index 51283f2..04cf35a 100755 --- a/tests/testthat/test-result.R +++ b/tests/testthat/test-result.R @@ -86,7 +86,7 @@ test_that("equality works", { test_that("aggregation works", { len <- 20 every <- result(rep(TRUE, len), NA) - some <- vec_assign(every, (1:len) <= 10, result(FALSE, NA)) + some <- result(c(rep(TRUE, len / 2), rep(FALSE, len / 2)), NA) expect_length(every, len) expect_length(some, len) expect_true(any(every)) diff --git a/tests/testthat/test-status.R b/tests/testthat/test-status.R index c281f00..7e78866 100755 --- a/tests/testthat/test-status.R +++ b/tests/testthat/test-status.R @@ -60,7 +60,7 @@ test_that("equality work", { test_that("aggregation works", { n <- 20 every <- status_(rep("PASS", n)) - some <- vec_assign(every, (1:n) <= 10, FALSE) + some <- status_(c(rep("PASS", n / 2), rep("FAIL", n / 2))) expect_length(every, n) expect_length(some, n) diff --git a/vignettes/logging.Rmd b/vignettes/logging.Rmd index 4d60965..1d58ba5 100644 --- a/vignettes/logging.Rmd +++ b/vignettes/logging.Rmd @@ -1,5 +1,10 @@ --- title: "Logging" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Logging} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE}