-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ added functions to get R and Rstudio versions
- Loading branch information
1 parent
6f36fde
commit a76b91a
Showing
4 changed files
with
86 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#' Get a list of the allowed R versions for the rostools courses. | ||
#' | ||
#' The allowed versions are those that are at maximum a year old from today, | ||
#' sorted by the oldest first. | ||
#' | ||
#' @return A character vector of allowed R versions. | ||
#' @export | ||
#' | ||
#' @examples | ||
#' get_allowed_r_versions() | ||
get_allowed_r_versions <- function() { | ||
rversions::r_versions() |> | ||
dplyr::filter( | ||
date >= one_year_ago() | ||
) |> | ||
dplyr::pull(version) | ||
} | ||
|
||
#' Get a list of the allowed RStudio versions for the rostools courses. | ||
#' | ||
#' The versions are those that are at a maximum one year old from today, | ||
#' sorted by the oldest first. | ||
#' | ||
#' @return A character vector of allowed RStudio versions. | ||
#' @export | ||
#' | ||
#' @examples | ||
#' get_allowed_rstudio_versions() | ||
get_allowed_rstudio_versions <- function() { | ||
versions <- gh::gh("/repos/:owner/:repo/tags", owner = "rstudio", repo = "rstudio") |> | ||
purrr::map_chr("name") |> | ||
stringr::str_subset("\\d{4}\\.\\d{2}") | ||
|
||
tibble::tibble( | ||
version = versions, | ||
date = versions |> | ||
stringr::str_extract("\\d{4}\\.\\d{2}") |> | ||
stringr::str_c(".01") |> | ||
lubridate::as_date() | ||
) |> | ||
dplyr::filter( | ||
date >= one_year_ago() | ||
) |> | ||
dplyr::arrange(date) |> | ||
dplyr::pull(version) | ||
} | ||
|
||
one_year_ago <- function() { | ||
lubridate::today() - lubridate::years(1) | ||
} |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.