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
4 changed files
with
184 additions
and
0 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,20 @@ | ||
#' Search among all universes | ||
#' | ||
#' @inheritParams universe_search | ||
#' | ||
#' @return A list with query results. The `total` field indicates the | ||
#' total number of results and can be used as `limit` value in a second call. | ||
#' @export | ||
#' | ||
#' @examplesIf interactive() | ||
#' global_search(query = '"weather data"', limit = 1) | ||
#' global_search(query = 'needs:httr2', limit = 1) | ||
global_search <- function(query, limit = 100) { | ||
httr2::request("https://r-universe.dev") |> | ||
httr2::req_url_path("api") |> | ||
httr2::req_url_path_append("search") |> | ||
httr2::req_user_agent("starchart R package") |> | ||
httr2::req_url_query(limit = limit, q = query) |> | ||
httr2::req_perform() |> | ||
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.
131 changes: 131 additions & 0 deletions
131
tests/testthat/global-search/r-universe.dev/api/search-420206.json
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,131 @@ | ||
{ | ||
"results": [ | ||
{ | ||
"_id": "66efb9c1363ce6fc66389768", | ||
"Package": "devtools", | ||
"Title": "Tools to Make Developing R Packages Easier", | ||
"Description": "Collection of package development tools.", | ||
"_user": "r-lib", | ||
"_owner": "r-lib", | ||
"_usedby": 141, | ||
"_score": 19.742559633132295, | ||
"_uuid": 22618716, | ||
"maintainer": { | ||
"name": "Jennifer Bryan", | ||
"email": "[email protected]", | ||
"login": "jennybc", | ||
"mastodon": "https://fosstodon.org/@jennybryan", | ||
"uuid": 599454, | ||
"orcid": "0000-0002-6983-2759" | ||
}, | ||
"updated": 1726848647, | ||
"stars": 2392, | ||
"topics": [ | ||
"package-creation" | ||
], | ||
"rundeps": [ | ||
"askpass", | ||
"base64enc", | ||
"brew", | ||
"brio", | ||
"bslib", | ||
"cachem", | ||
"callr", | ||
"cli", | ||
"clipr", | ||
"commonmark", | ||
"cpp11", | ||
"crayon", | ||
"credentials", | ||
"curl", | ||
"desc", | ||
"diffobj", | ||
"digest", | ||
"downlit", | ||
"ellipsis", | ||
"evaluate", | ||
"fansi", | ||
"fastmap", | ||
"fontawesome", | ||
"fs", | ||
"gert", | ||
"gh", | ||
"gitcreds", | ||
"glue", | ||
"highr", | ||
"htmltools", | ||
"htmlwidgets", | ||
"httpuv", | ||
"httr2", | ||
"ini", | ||
"jquerylib", | ||
"jsonlite", | ||
"knitr", | ||
"later", | ||
"lifecycle", | ||
"magrittr", | ||
"memoise", | ||
"mime", | ||
"miniUI", | ||
"openssl", | ||
"pillar", | ||
"pkgbuild", | ||
"pkgconfig", | ||
"pkgdown", | ||
"pkgload", | ||
"praise", | ||
"prettyunits", | ||
"processx", | ||
"profvis", | ||
"promises", | ||
"ps", | ||
"purrr", | ||
"R6", | ||
"ragg", | ||
"rappdirs", | ||
"rcmdcheck", | ||
"Rcpp", | ||
"rematch2", | ||
"remotes", | ||
"rlang", | ||
"rmarkdown", | ||
"roxygen2", | ||
"rprojroot", | ||
"rstudioapi", | ||
"rversions", | ||
"sass", | ||
"sessioninfo", | ||
"shiny", | ||
"sourcetools", | ||
"stringi", | ||
"stringr", | ||
"sys", | ||
"systemfonts", | ||
"testthat", | ||
"textshaping", | ||
"tibble", | ||
"tinytex", | ||
"urlchecker", | ||
"usethis", | ||
"utf8", | ||
"vctrs", | ||
"waldo", | ||
"whisker", | ||
"withr", | ||
"xfun", | ||
"xml2", | ||
"xopen", | ||
"xtable", | ||
"yaml", | ||
"zip" | ||
], | ||
"rank": 19.742559633132295 | ||
} | ||
], | ||
"query": { | ||
"_rundeps": "gert" | ||
}, | ||
"skip": 0, | ||
"limit": 1, | ||
"total": 359 | ||
} |
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,7 @@ | ||
test_that("universe_search() works", { | ||
httptest2::with_mock_dir("global-search", { | ||
packages <- global_search(query = 'needs:gert', limit = 1) | ||
}) | ||
expect_type(packages, "list") | ||
expect_gt(length(packages), 0) | ||
}) |