From 88f7514b2e420201d39088263c2391924f322377 Mon Sep 17 00:00:00 2001 From: Christopher Kenny Date: Tue, 11 Jun 2024 19:41:52 -0400 Subject: [PATCH] prep for cran --- DESCRIPTION | 20 +++++++++++----- R/attach.R | 2 +- R/cache.R | 48 ++++++++++++++++++++++++++++++++++++++ R/redistverse-package.R | 1 + README.Rmd | 4 ++++ README.md | 1 + inst/WORDLIST | 11 +++++++++ man/redistverse-package.Rd | 6 ++--- tests/spelling.R | 3 +++ 9 files changed, 86 insertions(+), 10 deletions(-) create mode 100644 R/cache.R create mode 100644 inst/WORDLIST create mode 100644 tests/spelling.R diff --git a/DESCRIPTION b/DESCRIPTION index 6feb6fe..20be257 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,9 +1,14 @@ Package: redistverse Title: Easily Install and Load Redistricting Software -Version: 0.1.0.9000 +Version: 0.1.0 Authors@R: c( - person("Christopher T.", "Kenny", email = "christopherkenny@fas.harvard.edu", role = c("aut", "cre")), - person("Cory", "McCartan", email = "cmccartan@g.harvard.edu", role = "aut"), + person(given = "Christopher T.", + family = "Kenny", + role = c("aut", "cre"), + email = "christopherkenny@fas.harvard.edu", + comment = c(ORCID = "0000-0002-9386-6860")), + person(given = "Cory", family = "McCartan", email = "mccartan@psu.edu", + role = "aut", comment = c(ORCID = "0000-0002-6251-669X")), person("tidyverse contributors", role = "ctb", comment = "attach code adapted from tidyverse.")) Description: The 'redistverse' is a set of packages for redistricting data downloading, spatial preprocessing, simulation, analysis, and @@ -22,14 +27,17 @@ Imports: easycensus, PL94171, alarmdata, - cli + cli, + birdie Suggests: wacolors, - testthat (>= 3.0.0) + testthat (>= 3.0.0), + spelling License: MIT + file LICENSE Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 URL: https://github.com/alarm-redist/redistverse, https://alarm-redist.org/redistverse/ BugReports: https://github.com/alarm-redist/redistverse/issues Config/testthat/edition: 3 +Language: en-US diff --git a/R/attach.R b/R/attach.R index ffa0752..62546c2 100644 --- a/R/attach.R +++ b/R/attach.R @@ -1,7 +1,7 @@ # adopted from `tidyverse` core_pkgs <- c("redist", "redistmetrics", "ggredist", "geomander", "sf") -xtra_pkgs <- c("PL94171", "tinytiger", "alarmdata", "censable", "easycensus") +xtra_pkgs <- c("PL94171", "tinytiger", "alarmdata", "censable", "easycensus", "birdie") # geocoder? birdie? core_unloaded <- function() { diff --git a/R/cache.R b/R/cache.R new file mode 100644 index 0000000..a9f8d37 --- /dev/null +++ b/R/cache.R @@ -0,0 +1,48 @@ +#" Summarize caches for `redistverse` packages +#" +#" @param packages character vector of package names. Default is `c("alarmdata", "tinytiger")`. +#" +#" @return a vector of paths to the cache directories for the specified packages +#" @export +#" +#" @examples +#" redistverse_cache_status() +redistverse_cache_status <- function(packages = c("alarmdata", "tinytiger")) { + if ("alarmdata" %in% packages) { + packages[packages == "alarmdata"] <- "alarm" + } + + check_fns <- c( + tinytiger = tinytiger::tt_cache_path, + alarm = alarmdata::alarm_cache_path + ) + + use_cache <- logical(length(packages)) + paths <- character(length(packages)) + for (i in seq_along(packages)) { + use_cache[i] <- getOption(x = paste0(packages[i], ".use_cache"), default = FALSE) + if (use_cache[i] && !is.null(check_fns[[packages[i]]])) { + paths[i] <- check_fns[[packages[i]]]() + } else { + paths[i] <- getOption(paste0(packages[i], ".cache_dir"), default = NA_character_) + } + } + + ul <- cli::cli_ul() + for (i in seq_along(packages)) { + if (is.na(paths[i])) { + if (isFALSE(use_cache[i])) { + cli::cli_li("{.pkg {packages[i]}}: cache is not enabled.") + } else { + cli::cli_li("{.pkg {packages[i]}}: cache enabled but not found.") + } + } else { + cli::cli_li("{.pkg {packages[i]}}: cache is {.path {paths[i]}}.") + } + } + cli::cli_end(ul) + + names(paths) <- packages + + invisible(paths) +} diff --git a/R/redistverse-package.R b/R/redistverse-package.R index f45dbde..23c1bbb 100644 --- a/R/redistverse-package.R +++ b/R/redistverse-package.R @@ -15,4 +15,5 @@ ignore_unused_imports <- function() { redistmetrics::by_plan sf::st_crs tinytiger::tt_voting_districts + birdie::birdie } diff --git a/README.Rmd b/README.Rmd index be243a8..e1faeee 100644 --- a/README.Rmd +++ b/README.Rmd @@ -16,6 +16,9 @@ knitr::opts_chunk$set( # redistverse +[![redistverse status +badge](https://alarm-redist.r-universe.dev/badges/redistverse)](https://alarm-redist.r-universe.dev/redistverse) +[![R-CMD-check](https://github.com/alarm-redist/redistverse/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/alarm-redist/redistverse/actions/workflows/R-CMD-check.yaml) The `redistverse` is a set of packages for redistricting data downloading, spatial @@ -53,3 +56,4 @@ Related packages are installed: - [alarmdata](https://alarm-redist.org/alarmdata/) - [easycensus](https://corymccartan.com/easycensus/) - [censable](https://christophertkenny.com/censable/) +- [birdie](https://corymccartan.com/birdie/) diff --git a/README.md b/README.md index bc27e44..25800a5 100644 --- a/README.md +++ b/README.md @@ -42,3 +42,4 @@ Related packages are installed: - [alarmdata](https://alarm-redist.org/alarmdata/) - [easycensus](https://corymccartan.com/easycensus/) - [censable](https://christophertkenny.com/censable/) +- [birdie](https://corymccartan.com/birdie/) diff --git a/inst/WORDLIST b/inst/WORDLIST new file mode 100644 index 0000000..a21934b --- /dev/null +++ b/inst/WORDLIST @@ -0,0 +1,11 @@ +CMD +ORCID +alarmdata +censable +easycensus +geomander +ggredist +redist +redistmetrics +tidyverse +tinytiger diff --git a/man/redistverse-package.Rd b/man/redistverse-package.Rd index cfee732..ce60211 100644 --- a/man/redistverse-package.Rd +++ b/man/redistverse-package.Rd @@ -14,17 +14,17 @@ The 'redistverse' is a set of packages for redistricting data downloading, spati Useful links: \itemize{ \item \url{https://github.com/alarm-redist/redistverse} - \item \url{http://alarm-redist.org/redistverse/} + \item \url{https://alarm-redist.org/redistverse/} \item Report bugs at \url{https://github.com/alarm-redist/redistverse/issues} } } \author{ -\strong{Maintainer}: Christopher T. Kenny \email{christopherkenny@fas.harvard.edu} +\strong{Maintainer}: Christopher T. Kenny \email{christopherkenny@fas.harvard.edu} (\href{https://orcid.org/0000-0002-9386-6860}{ORCID}) Authors: \itemize{ - \item Cory McCartan \email{cmccartan@g.harvard.edu} + \item Cory McCartan \email{mccartan@psu.edu} (\href{https://orcid.org/0000-0002-6251-669X}{ORCID}) } Other contributors: diff --git a/tests/spelling.R b/tests/spelling.R new file mode 100644 index 0000000..6713838 --- /dev/null +++ b/tests/spelling.R @@ -0,0 +1,3 @@ +if(requireNamespace('spelling', quietly = TRUE)) + spelling::spell_check_test(vignettes = TRUE, error = FALSE, + skip_on_cran = TRUE)