This repository has been archived by the owner on Oct 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
555 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
^starchart\.Rproj$ | ||
^\.Rproj\.user$ | ||
^LICENSE\.md$ | ||
^man/universe_query\.Rd$ |
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(universe_ls) | ||
export(universe_packages) |
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
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 |
---|---|---|
@@ -1,8 +1,22 @@ | ||
universe_query <- function(universe_url, path) { | ||
httr2::request(universe_url) |> | ||
httr2::req_url_path("api") |> | ||
httr2::req_url_path_append(path) |> | ||
httr2::req_user_agent("starchart R package") |> | ||
httr2::req_perform() |> | ||
httr2::resp_body_json() | ||
#' Query the API of a single universe | ||
#' | ||
#' @param universe_url URL to the universe like ""https://jeroen.r-universe.dev" | ||
#' @param path Path to append after api like "ls" | ||
#' @param query_params Named list of query parameters | ||
#' | ||
#' @return The JSON from the API as a list | ||
#' @dev | ||
#' | ||
universe_query <- function(universe_url, path, query_params = NULL) { | ||
request <- httr2::request(universe_url) |> | ||
httr2::req_url_path("api") |> | ||
httr2::req_url_path_append(path) |> | ||
httr2::req_user_agent("starchart R package") | ||
|
||
if (!is.null(query_params)) { | ||
request <- httr2::req_url_query(request, !!!query_params) | ||
} | ||
|
||
httr2::req_perform(request) |> | ||
httr2::resp_body_json() | ||
} |
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.
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.
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,12 @@ | ||
# This file is part of the standard setup for testthat. | ||
# It is recommended that you do not modify it. | ||
# | ||
# Where should you do additional test configuration? | ||
# Learn more about the roles of various files in: | ||
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview | ||
# * https://testthat.r-lib.org/articles/special-files.html | ||
|
||
library(testthat) | ||
library(starchart) | ||
|
||
test_check("starchart") |
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 @@ | ||
library(httptest2) |
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,15 @@ | ||
test_that("universe_ls() works", { | ||
httptest2::with_mock_dir("univ-ls", { | ||
packages <- universe_ls("maelle") | ||
}) | ||
expect_type(packages, "character") | ||
expect_gt(length(packages), 0) | ||
}) | ||
|
||
test_that("universe_packages() works", { | ||
httptest2::with_mock_dir("univ-packages", { | ||
packages <- universe_packages("maelle", limit = 1) | ||
}) | ||
expect_type(packages, "list") | ||
expect_gt(length(packages), 0) | ||
}) |
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,6 @@ | ||
[ | ||
"cransays", | ||
"glitter", | ||
"roblog", | ||
"testthat" | ||
] |
Oops, something went wrong.