From 9be9ae20fae6d28f06533d4547819466b63b1e70 Mon Sep 17 00:00:00 2001 From: mpadge Date: Tue, 16 Jul 2024 15:15:30 +0200 Subject: [PATCH] check input param to dashboard fn --- DESCRIPTION | 3 +- R/quarto-dashboard.R | 23 ++++++++++++ codemeta.json | 87 +++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 106 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b5e3621..06f78da 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: githist Title: Code analyses traced along the 'git' history of a package -Version: 0.0.1.027 +Version: 0.1.0 Authors@R: person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-2172-5265")) @@ -11,6 +11,7 @@ URL: https://docs.ropensci.org/githist/, BugReports: https://github.com/ropensci-review-tools/githist/issues Imports: checkmate, + cli, dplyr, fs, gert, diff --git a/R/quarto-dashboard.R b/R/quarto-dashboard.R index dbada2e..4e4a758 100644 --- a/R/quarto-dashboard.R +++ b/R/quarto-dashboard.R @@ -6,6 +6,8 @@ #' @export gh_dashboard <- function (results) { + check_dashboard_arg (results) + requireNamespace ("brio") requireNamespace ("quarto") requireNamespace ("withr") @@ -37,3 +39,24 @@ quarto_insert_pkg_name <- function (dir, pkg_name) { y [i] <- gsub ("Package", pkg_name, y [i]) brio::write_lines (y, f_yaml) } + +check_dashboard_arg <- function (results) { + + checkmate::assert_list (results, len = 3L, names = "named") + checkmate::assert_names (names (results), identical.to = c ("desc_data", "loc", "stats")) + + ncols <- vapply (results, ncol, integer (1L)) + ncols_expected <- c (9, 15, 8) + if (!identical (ncols, ncols_expected)) { + cli::cli_abort (paste0 ( + "'results' has wrong number of columns; ", + "should be [{ncols_expected}] but is ", + "[{ncols}]" + )) + } + + nrows <- vapply (results, nrow, integer (1L)) + if (!all (nrows > 0L)) { + cli::cli_abort ("'results' contains empty tables.") + } +} diff --git a/codemeta.json b/codemeta.json index dd2ec0d..32c3ff9 100644 --- a/codemeta.json +++ b/codemeta.json @@ -8,7 +8,7 @@ "codeRepository": "https://github.com/ropensci-review-tools/githist", "issueTracker": "https://github.com/ropensci-review-tools/githist/issues", "license": "https://spdx.org/licenses/GPL-3.0", - "version": "0.0.1.027", + "version": "0.1.0", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", @@ -33,6 +33,57 @@ "@id": "https://orcid.org/0000-0003-2172-5265" } ], + "softwareSuggestions": [ + { + "@type": "SoftwareApplication", + "identifier": "brio", + "name": "brio", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=brio" + }, + { + "@type": "SoftwareApplication", + "identifier": "quarto", + "name": "quarto", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=quarto" + }, + { + "@type": "SoftwareApplication", + "identifier": "testthat", + "name": "testthat", + "version": ">= 3.0.0", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=testthat" + }, + { + "@type": "SoftwareApplication", + "identifier": "withr", + "name": "withr", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=withr" + } + ], "softwareRequirements": { "1": { "@type": "SoftwareApplication", @@ -47,6 +98,18 @@ "sameAs": "https://CRAN.R-project.org/package=checkmate" }, "2": { + "@type": "SoftwareApplication", + "identifier": "cli", + "name": "cli", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=cli" + }, + "3": { "@type": "SoftwareApplication", "identifier": "dplyr", "name": "dplyr", @@ -58,7 +121,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=dplyr" }, - "3": { + "4": { "@type": "SoftwareApplication", "identifier": "fs", "name": "fs", @@ -70,7 +133,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=fs" }, - "4": { + "5": { "@type": "SoftwareApplication", "identifier": "gert", "name": "gert", @@ -82,13 +145,25 @@ }, "sameAs": "https://CRAN.R-project.org/package=gert" }, - "5": { + "6": { + "@type": "SoftwareApplication", + "identifier": "pbapply", + "name": "pbapply", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=pbapply" + }, + "7": { "@type": "SoftwareApplication", "identifier": "pkgstats", "name": "pkgstats", "sameAs": "https://github.com/ropensci-review-tools/pkgstats" }, - "SystemRequirements": {} + "SystemRequirements": null }, - "fileSize": "3.768KB" + "fileSize": "55.256KB" }