-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
proofr v0.3.0 Updates
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
Package: proofr | ||
Title: Client for the PROOF API | ||
Version: 0.2.0.94 | ||
Version: 0.2.1.91 | ||
Authors@R: | ||
person("Scott", "Chamberlain", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0003-1444-9135")) | ||
Description: Client for the PROOF API. | ||
URL: http://getwilds.org/proofr/ (website) | ||
https://github.com/getwilds/proofr (devel) | ||
URL: http://getwilds.org/proofr/, https://github.com/getwilds/proofr | ||
License: MIT + file LICENSE | ||
Encoding: UTF-8 | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.2.3 | ||
RoxygenNote: 7.3.2 | ||
Depends: R (>= 4.1.0) | ||
Imports: | ||
cli, | ||
glue, | ||
httr | ||
httr2 | ||
Suggests: | ||
jsonlite, | ||
knitr, | ||
rmarkdown, | ||
testthat (>= 3.0.0), | ||
webmockr, | ||
webmockr (>= 1.0.0), | ||
withr | ||
Config/testthat/edition: 3 | ||
VignetteBuilder: knitr |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,6 @@ | ||
stop_for_message <- function(response) { | ||
if (http_error(response)) { | ||
parsed <- tryCatch(content(response), error = function(e) e) | ||
if (inherits(parsed, "error")) stop_for_status(response) | ||
if (!is.list(parsed)) stop_for_status(response) | ||
msg <- glue::glue( | ||
"{http_status(response)$reason}", | ||
" (HTTP {status_code(response)})", | ||
" {parsed$message}" | ||
) | ||
stop(msg, call. = FALSE) | ||
} | ||
error_body <- function(response) { | ||
parsed <- resp_body_json(response) | ||
glue::glue( | ||
"Additional context: {parsed$message}" | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#' Get information about PROOF server | ||
#' | ||
#' @export | ||
#' @return A list with fields: | ||
#' - `branch` (character): git branch of API | ||
#' - `commit_sha` (character): SHA of the git commit of the API | ||
#' - `short_commit_sha` (character): the first eight characters of `commit_sha` | ||
#' - `commit_message` (character): commit message of API's most recent commit | ||
#' - `tag` (character): tag of most recent commit/release version | ||
proof_info <- function() { | ||
request(make_url("info")) |> | ||
req_timeout(proofr_env$timeout_sec) |> | ||
req_error(body = error_body) |> | ||
req_perform() |> | ||
resp_body_json() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
#' @keywords internal | ||
#' @section Base URL for PROOF API: | ||
#' The base URL for the PROOF API can be changed by setting the environment | ||
#' variable `PROOF_API_BASE_URL`. It can be set for an R session or for | ||
#' function by function use as we check that env var in each function call | ||
#' to the API | ||
"_PACKAGE" | ||
|
||
## usethis namespace: start | ||
#' @importFrom httr GET POST DELETE add_headers content | ||
#' stop_for_status timeout http_status status_code | ||
#' http_error | ||
#' @importFrom httr2 request req_perform req_headers | ||
#' req_timeout req_body_json req_method req_error | ||
#' resp_status resp_body_json | ||
## usethis namespace: end | ||
NULL |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.