rversions icon indicating copy to clipboard operation
rversions copied to clipboard

Use https://api.r-hub.io/rversions

Open gaborcsardi opened this issue 3 years ago • 4 comments

It should be much faster, and probably more available than the R SVN server, plus that way we only need to implement things once.

gaborcsardi avatar Aug 31 '22 09:08 gaborcsardi

Did you have something like this in mind? If yes, I can make a PR.

#' Function factory to create variants of `r_oldrel()` functions
#' @keywords internal
#' @noRd
.r_oldrel_n <- function(n) {
  force(n)
  
  function() {
    api_url <- paste0("https://api.r-hub.io/rversions/r-oldrel/", n)
    response <- httr::GET(api_url)
    status <- response$status_code
    if (status != 200) {
      stop("API request failed with status code: ", status)
    }
    data <- as.data.frame(httr::content(response))
    subset(data, select = -URL)
  }
}

#'  @rdname r_oldrel
#'  @export
r_oldrel_2 <- .r_oldrel_n(2L)

#'  @rdname r_oldrel
#'  @export
r_oldrel_3 <- .r_oldrel_n(3L)

#'  @rdname r_oldrel
#'  @export
r_oldrel_4 <- .r_oldrel_n(4L)



r_oldrel_2()
#>   version                        date    nickname
#> 1   4.1.3 2022-03-10T08:05:38.083503Z One Push-Up

r_oldrel_3()
#>   version                        date        nickname
#> 1   4.0.5 2021-03-31T07:05:15.035437Z Shake and Throw

r_oldrel_4()
#>   version                        date             nickname
#> 1   3.6.3 2020-02-29T08:05:16.744223Z Holding the Windsock

Created on 2023-09-13 with reprex v2.0.2

IndrajeetPatil avatar Sep 13 '23 07:09 IndrajeetPatil

Kind of, but using this API: https://api.r-hub.io/rversions/#/paths/~1resolve~1:version~1:os~1:arch/get

gaborcsardi avatar Sep 13 '23 08:09 gaborcsardi

But the os and arch path parameters should be hardcoded to some value, or will the user be able to modify them?

That is, will the function signature be .r_oldrel_n(n) or .r_oldrel_n(n, os, arch)?

IndrajeetPatil avatar Sep 22 '23 14:09 IndrajeetPatil

The user should be able to modify them.

gaborcsardi avatar Sep 22 '23 14:09 gaborcsardi