From 0e46346aec1df284a3efa7999415a6de0217a88b Mon Sep 17 00:00:00 2001 From: Brandon Moretz Date: Sat, 12 Mar 2022 12:21:24 -0500 Subject: [PATCH] removed vscode dev (temp); addressed CRAN submission freedback removed vscode dev (temp); addressed CRAN submission freedback --- .lintr | 14 +-- .vscode/launch.json | 50 --------- DESCRIPTION | 10 +- NEWS.md | 19 ++++ R/config.R | 13 ++- R/context.R | 18 ++-- R/dispatch.R | 14 +-- R/layout.R | 4 +- R/level.R | 2 +- README.Rmd | 28 +++-- README.md | 45 ++++++--- cran-comments.md | 10 +- man/exec_context.Rd | 4 +- man/get_call_stack.Rd | 6 +- renv.lock | 146 +++------------------------ renv/activate.R | 94 +++++++---------- tests/testthat/helper-log-dispatch.R | 16 +-- tests/testthat/test-config.R | 4 +- tests/testthat/test-context.R | 10 +- tests/testthat/test-dispatch.R | 6 +- vignettes/Formats.Rmd | 2 + 21 files changed, 188 insertions(+), 327 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.lintr b/.lintr index 00c472f..d0dbf8f 100644 --- a/.lintr +++ b/.lintr @@ -1,10 +1,12 @@ linters: with_defaults( line_length_linter = NULL, # 53 - dummy_linter = NULL + dummy_linter = NULL, + T_and_F_symbol_linter, + equals_na_linter, + nonportable_path_linter ) exclusions: list( "docs/404.html", - "docs/articles/Formats.html", "docs/articles/index.html", "docs/articles/Layouts.html", "docs/articles/Levels.html", @@ -163,12 +165,6 @@ exclusions: list( "man/value.fmt_timestamp.Rd", "man/value.Rd", "vignettes/Formats.html", - "vignettes/Formats.R", - "vignettes/Formats.Rmd", "vignettes/Layouts.html", - "vignettes/Layouts.R", - "vignettes/Layouts.Rmd", - "vignettes/Levels.html", - "vignettes/Levels.R", - "vignettes/Levels.Rmd" + "vignettes/Levels.html" ) diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 1a638a4..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "R-Debugger", - "name": "Launch R-Workspace", - "request": "launch", - "debugMode": "workspace", - "workingDirectory": "${workspaceFolder}" - }, - { - "type": "R-Debugger", - "name": "Debug R-File", - "request": "launch", - "debugMode": "file", - "workingDirectory": "${workspaceFolder}", - "file": "${file}" - }, - { - "type": "R-Debugger", - "name": "Debug R-Function", - "request": "launch", - "debugMode": "function", - "workingDirectory": "${workspaceFolder}", - "file": "${file}", - "mainFunction": "main", - "allowGlobalDebugging": false - }, - { - "type": "R-Debugger", - "name": "Debug R-Package", - "request": "launch", - "debugMode": "workspace", - "workingDirectory": "${workspaceFolder}", - "includePackageScopes": true, - "loadPackages": [ - "." - ] - }, - { - "type": "R-Debugger", - "request": "attach", - "name": "Attach to R process", - "splitOverwrittenOutput": true - } - ] -} \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index f7ac44f..9562a62 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: dyn.log Type: Package Title: Dynamic Logging for R Inspired by Configuration Driven Development -Version: 0.3.2 +Version: 0.3.3 Authors@R: c(person(given = "Brandon", family = "Moretz", @@ -14,7 +14,7 @@ Description: A comprehensive and dynamic configuration driven logging package fo are several excellent logging solutions already in the R ecosystem, I always feel constrained in some way by each of them. Every project is designed differently to solve it's domain specific problem, and ultimately the utility of a logging solution is its ability to adapt to this design. This is the - rai-son de' tre for dyn.log: to provide a modular design, template mechanics and a configuration-based + raison d'être for 'dyn.log': to provide a modular design, template mechanics and a configuration-based integration model, so that the logger can integrate deeply into your design, even though it knows nothing about it. License: MIT + file LICENSE @@ -32,7 +32,6 @@ Imports: Roxygen: list(markdown = TRUE) URL: https://bmoretz.github.io/dyn.log/ BugReports: https://github.com/bmoretz/dyn.log/issues -RoxygenNote: 7.1.2 Suggests: devtools, usethis, @@ -48,9 +47,8 @@ Suggests: here, fansi, pander, - DT, - languageserver, - httpgd + DT Config/testthat/edition: 3 +RoxygenNote: 7.1.2 Language: en-US VignetteBuilder: knitr diff --git a/NEWS.md b/NEWS.md index b6a5b22..84e3191 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,24 @@ # Release Summaries +# dyn.log 0.3.3 + +## What's Changed + +* New Features + + N/A + +* Enhancements + + additional linters: + + T_and_F_symbol_linter + + equals_na_linter + + nonportable_path_linter + + resolved all warnings produced by including the new lintrs. + + updated the README.md to be more reflective of the overall goal of the package. + +* Other + + vscode support + + moved the development configuration that supports vscode into a separate branch and cleaned up all the additional dependencies. + # dyn.log 0.3.2 ## What's Changed diff --git a/R/config.R b/R/config.R index 1349896..4f7de0d 100644 --- a/R/config.R +++ b/R/config.R @@ -14,7 +14,7 @@ get_configurations <- function(pkgname = "dyn.log") { config_files <- list.files( system.file("", package = pkgname), pattern = ".yaml", - full.names = T + full.names = TRUE ) configs <- list() @@ -52,7 +52,7 @@ init_logger <- function(file_path = NULL) { config_file <- file_path } - config <- yaml::read_yaml(config_file, eval.expr = T) + config <- yaml::read_yaml(config_file, eval.expr = TRUE) config_name <- tools::file_path_sans_ext(basename(config_file)) ensure_logger(config$variable) @@ -98,7 +98,7 @@ ensure_logger <- function(variable) { } envir <- globalenv() - idx <- which(ls(envir) == variable, arr.ind = T) + idx <- which(ls(envir) == variable, arr.ind = TRUE) if (identical(idx, integer())) { logger <- LogDispatch$new() @@ -120,7 +120,7 @@ ensure_logger <- function(variable) { wipe_logger <- function() { envir <- globalenv(); objs <- ls(envir) - idx <- which(objs == active$log_var, arr.ind = T) + idx <- which(objs == active$log_var, arr.ind = TRUE) if (!identical(idx, integer(0))) { rm(list = objs[idx], envir = envir) @@ -144,7 +144,10 @@ load_log_layouts <- function(layouts) { invisible(sapply(layouts, function(layout) { if (identical(class(layout$format), "character")) { - parsed <- stringr::str_split(layout$formats, pattern = ",", simplify = T) + + parsed <- stringr::str_split(layout$formats, + pattern = ",", + simplify = TRUE) formats <- sapply(parsed, function(fmt) { eval(parse(text = stringr::str_trim(fmt))) diff --git a/R/context.R b/R/context.R index 2ebb489..aad65d6 100644 --- a/R/context.R +++ b/R/context.R @@ -79,7 +79,9 @@ extract_func_name <- function(func) { #' @returns string representation of a func call. format_fn_call <- function(expr, cutoff = 100L) { - deparse1(expr, collapse = " ", width.cutoff = cutoff, backtick = T) + deparse1(expr, collapse = " ", + width.cutoff = cutoff, + backtick = TRUE) } #' @title Formatted Call Stack @@ -95,9 +97,9 @@ format_fn_call <- function(expr, #' @family Context #' @returns formatted call stack #' @importFrom stringr str_detect fixed -get_call_stack <- function(keep_args = F, +get_call_stack <- function(keep_args = FALSE, call_subset = c(-1, -1), - filter_internal = T) { + filter_internal = TRUE) { trace_back <- rlang::trace_back() trace <- sapply(trace_back, list, simplify = "branch") @@ -154,7 +156,7 @@ clean_internal_calls <- function(call_stack) { internal_calls <- sapply(call_stack, function(call) { stringr::str_starts(call, pattern = stringr::fixed("dyn.log::")) - }, simplify = T) + }, simplify = TRUE) if (length(internal_calls) > 0) { call_stack <- call_stack[!internal_calls] @@ -177,17 +179,17 @@ clean_internal_calls <- function(call_stack) { #' @return system context for evaluating \code{fmt_metric} objects. #' @family Context #' @export -exec_context <- function(keep_args = F, +exec_context <- function(keep_args = FALSE, max_calls = 5, call_subset = c(-1, -1), - filter_internal = T) { + filter_internal = TRUE) { full_stack <- get_call_stack(keep_args = keep_args, call_subset = call_subset, filter_internal = filter_internal) - lcs <- sapply(full_stack, is_logger_call, simplify = T) - lc_idx <- as.integer(which(lcs, arr.ind = T)) + lcs <- sapply(full_stack, is_logger_call, simplify = TRUE) + lc_idx <- as.integer(which(lcs, arr.ind = TRUE)) if (!identical(lc_idx, integer(0))) { full_stack <- full_stack[1:(lc_idx - 1)] diff --git a/R/dispatch.R b/R/dispatch.R index c37910f..6e9c3a4 100644 --- a/R/dispatch.R +++ b/R/dispatch.R @@ -18,10 +18,10 @@ #' @export LogDispatch <- R6::R6Class( #nolint classname = "LogDispatch", - lock_objects = F, - lock_class = F, - cloneable = F, - portable = F, + lock_objects = FALSE, + lock_class = FALSE, + cloneable = FALSE, + portable = FALSE, public = list( @@ -95,7 +95,7 @@ LogDispatch <- R6::R6Class( #nolint caller_env <- rlang::caller_env() parent_env <- parent.env(caller_env) - has_calling_class <- ifelse(is.null(parent_env$self), F, T) + has_calling_class <- ifelse(is.null(parent_env$self), FALSE, TRUE) calling_class <- NA log_msg <- glue::glue(msg, .envir = parent) @@ -109,7 +109,7 @@ LogDispatch <- R6::R6Class( #nolint # association given its hierarchy. cls_name <- class(calling_class) registered <- names(log_layouts()) - layout_idx <- max(c(0L, match(cls_name, registered)), na.rm = T) + layout_idx <- max(c(0L, match(cls_name, registered)), na.rm = TRUE) if (layout_idx > 0) { log_layout <- log_layouts(registered[layout_idx]) @@ -143,7 +143,7 @@ LogDispatch <- R6::R6Class( #nolint evaluated <- evaluate_layout(detail, context) cat(glue::glue(evaluated), - fill = T, + fill = TRUE, file = stdout()) } diff --git a/R/layout.R b/R/layout.R index b64ed7d..cd7d807 100644 --- a/R/layout.R +++ b/R/layout.R @@ -129,7 +129,7 @@ evaluate_layout <- function(detail, context) { if (any(!is.na(match(detail$types, "fmt_newline")))) { is_break <- sapply(detail$formats, function(fmt) "fmt_newline" %in% class(fmt)) groups <- split(range, with(rle(is_break), rep(cumsum(!values), lengths))) # nolint (values is bound from RLE) - new_lines <- which(is_break, arr.ind = T) + new_lines <- which(is_break, arr.ind = TRUE) } output <- character(0) @@ -139,7 +139,7 @@ evaluate_layout <- function(detail, context) { rng <- unlist(unname(group)) has_break <- any(rng %in% new_lines) - if (has_break == T) { + if (has_break == TRUE) { rng <- rng[-length(rng)] } diff --git a/R/level.R b/R/level.R index d5a05e7..ccee27e 100644 --- a/R/level.R +++ b/R/level.R @@ -73,7 +73,7 @@ log_levels <- local({ if (length(level) > 0 && is.na(level)) { # remove an existing level - lvl_idx <- which(!is.na(match(lvl_names, name)), arr.ind = T) + lvl_idx <- which(!is.na(match(lvl_names, name)), arr.ind = TRUE) if (!identical(lvl_idx, integer())) { levels <<- levels[-lvl_idx] } diff --git a/README.Rmd b/README.Rmd index 3e30a69..9a53233 100644 --- a/README.Rmd +++ b/README.Rmd @@ -5,8 +5,6 @@ output: always_allow_html: yes --- - - ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, @@ -31,17 +29,27 @@ knitr::opts_chunk$set( [![R-CMD-check](https://github.com/bmoretz/dyn.log/workflows/R-CMD-check/badge.svg)](https://github.com/bmoretz/dyn.log/actions) [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://cran.r-project.org/web/licenses/MIT) [![Codecov test coverage](https://codecov.io/gh/bmoretz/dyn.log/branch/master/graph/badge.svg)](https://app.codecov.io/gh/bmoretz/dyn.log?branch=master) -[![](https://img.shields.io/badge/devel%20version-0.3.0-blue.svg)](https://bmoretz.github.io/dyn.log/) +[![](https://img.shields.io/badge/devel%20version-0.3.3-blue.svg)](https://bmoretz.github.io/dyn.log/) [![Lifecycle](https://img.shields.io/badge/lifecycle-stable-darkgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) -The goal of dyn.log is to be a comprehensive and dynamic configuration driven logging package -for R. While there are several excellent logging solutions already in the R ecosystem, I always -feel constrained in some way by each of them. Every project is designed differently to achieve its stated goal; -to solve some problem, and ultimately the utility of a logging solution is its ability to adapt -to the project’s design. This is the rai·​son d'être for dyn.log; to provide a modular design, -template mechanics and a configuration-based integration model. This enableds the logger to integrate -deeply into your design, even though it knows nothing about it. +The goal of `dyn.log` is to be a comprehensive, dynamic, configuration-based logging package for R. While there are several excellent logging solutions already in the R ecosystem, I found none of them were both robust functionality-wise, and completely generic i.e., they are designed exclusively for use within a specific environment (shiny/plumber/etc). + +This is the raison d'être for `dyn.log`: a flexible logging solution that: + +* Integrates seamlessly + + set an R option or call `init_logging` in your .Rprofile and your logger is attached (and will re-attach when you `rm(list = ls())`). +* Agnostics of project type, so it can be deployed across the entire application stack + + [shiny](https://github.com/rstudio/shiny) + + [plumber](https://github.com/rstudio/plumber) + + stand-alone prototype scripts + + etc. +* Reusable + + log layout, levels, etc. can be highly-customized for both shiny apps and plumber services, then reused across packages running in different environments (docker containers). + +### Demos + +In order to keep the package as light as possible dependency-wise, there are no demos that come integrated with the package. However, separate repositories are **coming soon** to demonstrate the above scenarios and will be linked here. ## Installation diff --git a/README.md b/README.md index 6a9c01e..a7938fd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,4 @@ - - # dyn.log # Overview @@ -12,20 +10,41 @@ MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://cran.r-project.org/web/licenses/MIT) [![Codecov test coverage](https://codecov.io/gh/bmoretz/dyn.log/branch/master/graph/badge.svg)](https://app.codecov.io/gh/bmoretz/dyn.log?branch=master) -[![](https://img.shields.io/badge/devel%20version-0.3.2-blue.svg)](https://bmoretz.github.io/dyn.log/) +[![](https://img.shields.io/badge/devel%20version-0.3.3-blue.svg)](https://bmoretz.github.io/dyn.log/) [![Lifecycle](https://img.shields.io/badge/lifecycle-stable-darkgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) -The goal of dyn.log is to be a comprehensive and dynamic configuration -driven logging package for R. While there are several excellent logging -solutions already in the R ecosystem, I always feel constrained in some -way by each of them. Every project is designed differently to achieve -its stated goal; to solve some problem, and ultimately the utility of a -logging solution is its ability to adapt to the project’s design. This -is the rai·​son d’être for dyn.log; to provide a modular design, -template mechanics and a configuration-based integration model. This -enableds the logger to integrate deeply into your design, even though it -knows nothing about it. +The goal of `dyn.log` is to be a comprehensive, dynamic, +configuration-based logging package for R. While there are several +excellent logging solutions already in the R ecosystem, I found none of +them were both robust functionality-wise, and completely generic i.e., +they are designed exclusively for use within a specific environment +(shiny/plumber/etc). + +This is the raison d’être for `dyn.log`: a flexible logging solution +that: + +- Integrates seamlessly + - set an R option or call `init_logging` in your .Rprofile and + your logger is attached (and will re-attach when you + `rm(list = ls())`). +- Agnostics of project type, so it can be deployed across the entire + application stack + - [shiny](https://github.com/rstudio/shiny) + - [plumber](https://github.com/rstudio/plumber) + - stand-alone prototype scripts + - etc. +- Reusable + - log layout, levels, etc. can be highly-customized for both shiny + apps and plumber services, then reused across packages running + in different environments (docker containers). + +### Demos + +In order to keep the package as light as possible dependency-wise, there +are no demos that come integrated with the package. However, separate +repositories are **coming soon** to demonstrate the above scenarios and +will be linked here. ## Installation diff --git a/cran-comments.md b/cran-comments.md index 37b532d..eaa7cff 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,5 +1,11 @@ -## R CMD check results -### dyn.log **0.3.2** +### dyn.log **0.3.3** + +Previous CRAN submission: **FAILED**. + +* Items resolved since previous submission: + + added lintr rule `T_and_F_symbol_linter` and converted all `T` and `F` to `TRUE` and `FALSE`, respectively. + + added api name +#### R CMD check results * 1 Note + checking CRAN incoming feasibility ... NOTE diff --git a/man/exec_context.Rd b/man/exec_context.Rd index 1c42982..2d23a7e 100644 --- a/man/exec_context.Rd +++ b/man/exec_context.Rd @@ -5,10 +5,10 @@ \title{Execution Context} \usage{ exec_context( - keep_args = F, + keep_args = FALSE, max_calls = 5, call_subset = c(-1, -1), - filter_internal = T + filter_internal = TRUE ) } \arguments{ diff --git a/man/get_call_stack.Rd b/man/get_call_stack.Rd index a92e86b..dc5207a 100644 --- a/man/get_call_stack.Rd +++ b/man/get_call_stack.Rd @@ -4,7 +4,11 @@ \alias{get_call_stack} \title{Formatted Call Stack} \usage{ -get_call_stack(keep_args = F, call_subset = c(-1, -1), filter_internal = T) +get_call_stack( + keep_args = FALSE, + call_subset = c(-1, -1), + filter_internal = TRUE +) } \arguments{ \item{keep_args}{T/F to indicate if you want to keep diff --git a/renv.lock b/renv.lock index 12908aa..878f784 100644 --- a/renv.lock +++ b/renv.lock @@ -9,14 +9,6 @@ ] }, "Packages": { - "BH": { - "Package": "BH", - "Version": "1.78.0-0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "4e348572ffcaa2fb1e610e7a941f6f3a", - "Requirements": [] - }, "DT": { "Package": "DT", "Version": "0.21", @@ -33,48 +25,6 @@ "promises" ] }, - "R.cache": { - "Package": "R.cache", - "Version": "0.15.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "e92a8ea8388c47c82ed8aa435ed3be50", - "Requirements": [ - "R.methodsS3", - "R.oo", - "R.utils", - "digest" - ] - }, - "R.methodsS3": { - "Package": "R.methodsS3", - "Version": "1.8.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "4bf6453323755202d5909697b6f7c109", - "Requirements": [] - }, - "R.oo": { - "Package": "R.oo", - "Version": "1.24.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "5709328352717e2f0a9c012be8a97554", - "Requirements": [ - "R.methodsS3" - ] - }, - "R.utils": { - "Package": "R.utils", - "Version": "2.11.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "a7ecb8e60815c7a18648e84cd121b23a", - "Requirements": [ - "R.methodsS3", - "R.oo" - ] - }, "R6": { "Package": "R6", "Version": "2.5.1", @@ -85,10 +35,10 @@ }, "Rcpp": { "Package": "Rcpp", - "Version": "1.0.8", + "Version": "1.0.8.2", "Source": "Repository", "Repository": "CRAN", - "Hash": "22b546dd7e337f6c0c58a39983a496bc", + "Hash": "6d93fbe4e93e43cbf59fd90d7932c5fb", "Requirements": [] }, "askpass": { @@ -101,14 +51,6 @@ "sys" ] }, - "backports": { - "Package": "backports", - "Version": "1.4.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "c39fbec8a30d23e721980b8afb31984c", - "Requirements": [] - }, "base64enc": { "Package": "base64enc", "Version": "0.1-3", @@ -195,20 +137,12 @@ "Hash": "019388fc48e48b3da0d3a76ff94608a8", "Requirements": [] }, - "collections": { - "Package": "collections", - "Version": "0.3.5", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "92537c684a3d2eaa6bd8f65c28ef97f0", - "Requirements": [] - }, "commonmark": { "Package": "commonmark", - "Version": "1.7", + "Version": "1.8.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "0f22be39ec1d141fd03683c06f3a6e67", + "Hash": "2ba81b120c1655ab696c935ef33ea716", "Requirements": [] }, "covr": { @@ -294,13 +228,13 @@ }, "desc": { "Package": "desc", - "Version": "1.4.0", + "Version": "1.4.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "28763d08fadd0b733e3cee9dab4e12fe", + "Hash": "eebd27ee58fcc58714eedb7aa07d8ad1", "Requirements": [ "R6", - "crayon", + "cli", "rprojroot" ] }, @@ -501,19 +435,6 @@ "yaml" ] }, - "httpgd": { - "Package": "httpgd", - "Version": "1.3.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "81bb9c5c74fbe3ded849845e9a31bfd3", - "Requirements": [ - "BH", - "cpp11", - "later", - "systemfonts" - ] - }, "httr": { "Package": "httr", "Version": "1.4.2", @@ -568,26 +489,6 @@ "yaml" ] }, - "languageserver": { - "Package": "languageserver", - "Version": "0.3.12", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "f62ed8b09fd56cd70291bd077bc52c4b", - "Requirements": [ - "R6", - "callr", - "collections", - "fs", - "jsonlite", - "lintr", - "roxygen2", - "stringi", - "styler", - "xml2", - "xmlparsedata" - ] - }, "later": { "Package": "later", "Version": "1.3.0", @@ -916,15 +817,15 @@ }, "renv": { "Package": "renv", - "Version": "0.15.4-4", + "Version": "0.15.0-10", "Source": "GitHub", "RemoteType": "github", "RemoteHost": "api.github.com", "RemoteUsername": "rstudio", "RemoteRepo": "renv", - "RemoteRef": "0.15.4-4", - "RemoteSha": "7243b4810f58d4fc11025a1eedf8e9ca8e21fe94", - "Hash": "4550413885e5598c957fe56913718df0", + "RemoteRef": "0.15.0-10", + "RemoteSha": "f03d9d6b828f4bae15b79816a69d44f374cafbd4", + "Hash": "a816ad243cb90671ad9367692f1f76c7", "Requirements": [] }, "rex": { @@ -947,10 +848,10 @@ }, "rmarkdown": { "Package": "rmarkdown", - "Version": "2.12", + "Version": "2.13", "Source": "Repository", "Repository": "CRAN", - "Hash": "354da5088ddfdffb73c11cc952885d88", + "Hash": "ac78f4d2e0289d4cba73b88af567b8b1", "Requirements": [ "bslib", "evaluate", @@ -1057,27 +958,6 @@ "stringi" ] }, - "styler": { - "Package": "styler", - "Version": "1.6.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "d9e85c794c5a723aabed32a49926186a", - "Requirements": [ - "R.cache", - "backports", - "cli", - "glue", - "magrittr", - "purrr", - "rematch2", - "rlang", - "rprojroot", - "tibble", - "withr", - "xfun" - ] - }, "sys": { "Package": "sys", "Version": "3.4", diff --git a/renv/activate.R b/renv/activate.R index e5d141a..30ead42 100644 --- a/renv/activate.R +++ b/renv/activate.R @@ -2,11 +2,16 @@ local({ # the requested version of renv - version <- "0.15.4-4" + version <- "0.15.0-10" # the project directory project <- getwd() + # figure out path to 'renv' folder from this script + call <- sys.call(1L) + if (is.call(call) && identical(call[[1L]], as.symbol("source"))) + Sys.setenv(RENV_PATHS_RENV = dirname(call[[2L]])) + # figure out whether the autoloader is enabled enabled <- local({ @@ -54,10 +59,20 @@ local({ # mask 'utils' packages, will come first on the search path library(utils, lib.loc = .Library) - # unload renv if it's already been laoded - if ("renv" %in% loadedNamespaces()) + # check to see if renv has already been loaded + if ("renv" %in% loadedNamespaces()) { + + # if renv has already been loaded, and it's the requested version of renv, + # nothing to do + spec <- .getNamespaceInfo(.getNamespace("renv"), "spec") + if (identical(spec[["version"]], version)) + return(invisible(TRUE)) + + # otherwise, unload and attempt to load the correct version of renv unloadNamespace("renv") + } + # load bootstrap tools `%||%` <- function(x, y) { if (is.environment(x) || length(x)) x else y @@ -148,20 +163,16 @@ local({ nv <- numeric_version(version) components <- unclass(nv)[[1]] - # if this appears to be a development version of 'renv', we'll - # try to restore from github - dev <- length(components) == 4L - - # begin collecting different methods for finding renv - methods <- c( - renv_bootstrap_download_tarball, - if (dev) + methods <- if (length(components) == 4L) { + list( renv_bootstrap_download_github - else c( + ) + } else { + list( renv_bootstrap_download_cran_latest, renv_bootstrap_download_cran_archive ) - ) + } for (method in methods) { path <- tryCatch(method(version), error = identity) @@ -298,33 +309,6 @@ local({ } - renv_bootstrap_download_tarball <- function(version) { - - # if the user has provided the path to a tarball via - # an environment variable, then use it - tarball <- Sys.getenv("RENV_BOOTSTRAP_TARBALL", unset = NA) - if (is.na(tarball)) - return() - - # allow directories - info <- file.info(tarball, extra_cols = FALSE) - if (identical(info$isdir, TRUE)) { - name <- sprintf("renv_%s.tar.gz", version) - tarball <- file.path(tarball, name) - } - - # bail if it doesn't exist - if (!file.exists(tarball)) - return() - - fmt <- "* Bootstrapping with tarball at path '%s'." - msg <- sprintf(fmt, tarball) - message(msg) - - tarball - - } - renv_bootstrap_download_github <- function(version) { enabled <- Sys.getenv("RENV_BOOTSTRAP_FROM_GITHUB", unset = "TRUE") @@ -378,13 +362,7 @@ local({ bin <- R.home("bin") exe <- if (Sys.info()[["sysname"]] == "Windows") "R.exe" else "R" r <- file.path(bin, exe) - - args <- c( - "--vanilla", "CMD", "INSTALL", "--no-multiarch", - "-l", shQuote(path.expand(library)), - shQuote(path.expand(tarball)) - ) - + args <- c("--vanilla", "CMD", "INSTALL", "--no-multiarch", "-l", shQuote(library), shQuote(tarball)) output <- system2(r, args, stdout = TRUE, stderr = TRUE) message("Done!") @@ -758,17 +736,12 @@ local({ } - renv_bootstrap_user_dir <- function() { - dir <- renv_bootstrap_user_dir_impl() - path.expand(chartr("\\", "/", dir)) + renv_bootstrap_user_dir <- function(path) { + dir <- renv_bootstrap_user_dir_impl(path) + chartr("\\", "/", dir) } - renv_bootstrap_user_dir_impl <- function() { - - # use local override if set - override <- getOption("renv.userdir.override") - if (!is.null(override)) - return(override) + renv_bootstrap_user_dir_impl <- function(path) { # use R_user_dir if available tools <- asNamespace("tools") @@ -779,8 +752,10 @@ local({ envvars <- c("R_USER_CACHE_DIR", "XDG_CACHE_HOME") for (envvar in envvars) { root <- Sys.getenv(envvar, unset = NA) - if (!is.na(root)) - return(file.path(root, "R/renv")) + if (!is.na(root)) { + path <- file.path(root, "R/renv") + return(path) + } } # use platform-specific default fallbacks @@ -793,14 +768,13 @@ local({ } - renv_json_read <- function(file = NULL, text = NULL) { text <- paste(text %||% read(file), collapse = "\n") # find strings in the JSON pattern <- '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' - locs <- gregexpr(pattern, text, perl = TRUE)[[1]] + locs <- gregexpr(pattern, text)[[1]] # if any are found, replace them with placeholders replaced <- text diff --git a/tests/testthat/helper-log-dispatch.R b/tests/testthat/helper-log-dispatch.R index c6b871f..8393c55 100644 --- a/tests/testthat/helper-log-dispatch.R +++ b/tests/testthat/helper-log-dispatch.R @@ -1,10 +1,10 @@ LogDispatchTester <- R6::R6Class( # nolint (class name) classname = "LogDispatchTester", inherit = LogDispatch, - lock_objects = F, - lock_class = F, - cloneable = F, - portable = F, + lock_objects = FALSE, + lock_class = FALSE, + cloneable = FALSE, + portable = FALSE, public = list( @@ -18,10 +18,10 @@ LogDispatchTester <- R6::R6Class( # nolint (class name) SingletonTester <- R6::R6Class( # nolint (class name) classname = "SingletonTester", inherit = LogDispatch, - lock_objects = F, - lock_class = F, - cloneable = F, - portable = F, + lock_objects = FALSE, + lock_class = FALSE, + cloneable = FALSE, + portable = FALSE, public = list( diff --git a/tests/testthat/test-config.R b/tests/testthat/test-config.R index a2d50b1..62ba7e2 100644 --- a/tests/testthat/test-config.R +++ b/tests/testthat/test-config.R @@ -141,7 +141,7 @@ testthat::test_that( "test-variable.yaml", package = "dyn.log") - config <- yaml::read_yaml(test_config_file, eval.expr = T) + config <- yaml::read_yaml(test_config_file, eval.expr = TRUE) ensure_logger(config$variable) @@ -159,7 +159,7 @@ testthat::test_that( "test-variable.yaml", package = "dyn.log") - config <- yaml::read_yaml(test_config_file, eval.expr = T) + config <- yaml::read_yaml(test_config_file, eval.expr = TRUE) ensure_logger(config$variable) diff --git a/tests/testthat/test-context.R b/tests/testthat/test-context.R index 14dbe15..8782cd7 100644 --- a/tests/testthat/test-context.R +++ b/tests/testthat/test-context.R @@ -57,8 +57,8 @@ testthat::test_that( wrapper <- function(x, y, z) { outer <- function(d, e, f) { inner <- function(g, h, i) { - get_call_stack(keep_args = F, - filter_internal = F) + get_call_stack(keep_args = FALSE, + filter_internal = FALSE) } inner(d, e, f) @@ -85,8 +85,8 @@ testthat::test_that( wrapper <- function(x, y, z) { outer <- function(d, e, f) { inner <- function(g, h, i) { - get_call_stack(keep_args = T, - filter_internal = F) + get_call_stack(keep_args = TRUE, + filter_internal = FALSE) } inner(d, e, f) @@ -113,7 +113,7 @@ testthat::test_that( wrapper <- function(x, y, z) { outer <- function(d, e, f) { inner <- function(g, h, i) { - exec_context(filter_internal = F) + exec_context(filter_internal = FALSE) } inner(d, e, f) diff --git a/tests/testthat/test-dispatch.R b/tests/testthat/test-dispatch.R index 383c3d1..ba9b971 100644 --- a/tests/testthat/test-dispatch.R +++ b/tests/testthat/test-dispatch.R @@ -41,7 +41,7 @@ test_that("test_can_set_log_settings", { "test-config.yaml", package = "dyn.log") - log_config <- yaml::read_yaml(test_config_file, eval.expr = T) + log_config <- yaml::read_yaml(test_config_file, eval.expr = TRUE) dispatch <- LogDispatchTester$new() dispatch$set_settings(log_config$settings) @@ -57,7 +57,7 @@ test_that("test_add_log_level_works", { "test-config.yaml", package = "dyn.log") - log_config <- yaml::read_yaml(test_config_file, eval.expr = T) + log_config <- yaml::read_yaml(test_config_file, eval.expr = TRUE) dispatch <- LogDispatchTester$new() dispatch$set_settings(log_config$settings) @@ -91,7 +91,7 @@ test_that("test_threshold_evaluation_works", { "test-config.yaml", package = "dyn.log") - log_config <- yaml::read_yaml(test_config_file, eval.expr = T) + log_config <- yaml::read_yaml(test_config_file, eval.expr = TRUE) dispatch <- LogDispatchTester$new() dispatch$set_settings(log_config$settings) diff --git a/vignettes/Formats.Rmd b/vignettes/Formats.Rmd index 6e204e9..861960c 100644 --- a/vignettes/Formats.Rmd +++ b/vignettes/Formats.Rmd @@ -25,9 +25,11 @@ init_logger(configs$knitr) ```{r, comment="", results="asis", echo=F} options(crayon.enabled = TRUE) + knitr::opts_chunk$set(collapse = TRUE, fig.path = "man/figures/FORMAT-", comment = "") + old.hooks <- fansi::set_knit_hooks(knitr::knit_hooks) ```