Skip to content

Commit

Permalink
Clearer function name
Browse files Browse the repository at this point in the history
Seemed too easy to read "install_if_version(foo, >= 1.2.3)"
as "if the version of foo is >= 1.2.3, then install [some other version?]"
  • Loading branch information
infotroph committed Dec 17, 2023
1 parent ce91430 commit 67d6266
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
38 changes: 19 additions & 19 deletions docker/depends/pecan.depends.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ options(repos = c(
getOption('repos'),
sub(r'(\d{4}-\d{2}-\d{2})', 'latest', getOption('repos'))
))
install_if_version <- function(pkg, version) {
ensure_version <- function(pkg, version) {
vers <- gsub('[^[:digit:].-]+', '', version)
cmp <- get(gsub('[^<>=]+', '', version))
ok <- requireNamespace(pkg, quietly = TRUE) &&
Expand All @@ -152,21 +152,21 @@ install_if_version <- function(pkg, version) {
remotes::install_version(pkg, version, dependencies = TRUE, upgrade = FALSE)
}
}
install_if_version('abind', '>= 1.4.5')
install_if_version('coda', '>= 0.18')
install_if_version('geonames', '> 0.998')
install_if_version('lubridate', '>= 1.7.0')
install_if_version('magic', '>= 1.5.0')
install_if_version('mockery', '>= 0.4.3')
install_if_version('MODISTools', '>= 1.1.0')
install_if_version('ncdf4', '>= 1.15')
install_if_version('plyr', '>= 1.8.4')
install_if_version('purrr', '>= 0.2.3')
install_if_version('reshape2', '>= 1.4.2')
install_if_version('rlang', '>= 0.2.0')
install_if_version('rmarkdown', '>= 2.19')
install_if_version('stringr', '>= 1.1.0')
install_if_version('testthat', '>= 3.0.4')
install_if_version('TruncatedNormal', '>= 2.2')
install_if_version('vdiffr', '>= 1.0.2')
install_if_version('XML', '>= 3.98-1.4')
ensure_version('abind', '>= 1.4.5')
ensure_version('coda', '>= 0.18')
ensure_version('geonames', '> 0.998')
ensure_version('lubridate', '>= 1.7.0')
ensure_version('magic', '>= 1.5.0')
ensure_version('mockery', '>= 0.4.3')
ensure_version('MODISTools', '>= 1.1.0')
ensure_version('ncdf4', '>= 1.15')
ensure_version('plyr', '>= 1.8.4')
ensure_version('purrr', '>= 0.2.3')
ensure_version('reshape2', '>= 1.4.2')
ensure_version('rlang', '>= 0.2.0')
ensure_version('rmarkdown', '>= 2.19')
ensure_version('stringr', '>= 1.1.0')
ensure_version('testthat', '>= 3.0.4')
ensure_version('TruncatedNormal', '>= 2.2')
ensure_version('vdiffr', '>= 1.0.2')
ensure_version('XML', '>= 3.98-1.4')
4 changes: 2 additions & 2 deletions scripts/generate_dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ unversioned_deps <- uniq_deps[uniq_deps$version == "*",]$package
versioned_dep_install_calls <- uniq_deps[uniq_deps$version != "*",] |>
dplyr::mutate(
inst_call = paste0(
"install_if_version(", shQuote(package), ", ", shQuote(version), ")")) |>
"ensure_version(", shQuote(package), ", ", shQuote(version), ")")) |>
dplyr::pull(inst_call) |>
sort()

Expand Down Expand Up @@ -191,7 +191,7 @@ cat("#!/usr/bin/env Rscript",
" getOption('repos'),",
" sub(r'(\\d{4}-\\d{2}-\\d{2})', 'latest', getOption('repos'))",
"))",
"install_if_version <- function(pkg, version) {",
"ensure_version <- function(pkg, version) {",
" vers <- gsub('[^[:digit:].-]+', '', version)",
" cmp <- get(gsub('[^<>=]+', '', version))",
" ok <- requireNamespace(pkg, quietly = TRUE) &&",
Expand Down

0 comments on commit 67d6266

Please sign in to comment.