-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
prepares #329
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#' Store individual results in a spreadsheet | ||
#' @details `r metacheck::mc_long_docs_string("spreadsheet.md")` | ||
#' @family communicate | ||
#' @name spreadsheet | ||
NULL | ||
|
||
#' @describeIn spreadsheet Create individual results | ||
#' @return A list of tibbles | ||
#' @inheritParams report | ||
#' @export | ||
create_ss <- function(dois = doi_examples$good[1:10]) { | ||
df <- cr_compliance_overview(get_cr_md(dois[is_metacheckable(dois)])) | ||
df[["pretest"]] <- tibble::tibble( | ||
# writexl does not know vctrs records | ||
doi = as.character(biblids::as_doi(dois)), | ||
tabulate_metacheckable(dois) | ||
) | ||
df | ||
} | ||
|
||
#' @describeIn spreadsheet Write out file | ||
#' @inheritParams writexl::write_xlsx | ||
#' @inheritDotParams writexl::write_xlsx | ||
#' @export | ||
write_xlsx_mc <- function(x, path = fs::file_temp(ext = "xlsx"), ...) { | ||
writexl::write_xlsx( | ||
x = x, | ||
path = path, | ||
... | ||
) | ||
} | ||
|
||
#' @describeIn spreadsheet Attach file to email | ||
#' @inheritParams blastula::add_attachment | ||
#' @export | ||
add_attachment_mc <- function(email = blastula::prepare_test_message(), | ||
file, | ||
translator = mc_translator()) { | ||
blastula::add_attachment( | ||
email = email, | ||
file = file, | ||
filename = translator$translate("mc_individual_results.xlsx") | ||
) | ||
} | ||
|
||
#' @describeIn spreadsheet Create and attach individual results to email | ||
#' @export | ||
create_and_attach_ss <- function(dois = doi_examples$good[1:10], ...) { | ||
ellipsis::check_dots_used() | ||
df <- create_ss(dois = dois) | ||
add_attachment_mc(file = write_xlsx_mc(df), ...) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# individual results are assembled | ||
|
||
Code | ||
names(create_ss()) | ||
Output | ||
[1] "cr_overview" "cc_license_check" "tdm" "funder_info" | ||
[5] "pretest" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
test_that("individual results are assembled", { | ||
expect_snapshot(names(create_ss())) | ||
}) | ||
|
||
test_that("spreadsheet is written to file", { | ||
checkmate::expect_file_exists(write_xlsx_mc(create_ss())) | ||
}) | ||
|
||
test_that("individual results can be created and attached", { | ||
expect_true(length(create_and_attach_ss()$attachments) == 1L) | ||
}) |