Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
maelle committed Oct 8, 2024
0 parents commit 740e088
Show file tree
Hide file tree
Showing 12 changed files with 147 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
^starchart\.Rproj$
^\.Rproj\.user$
^LICENSE\.md$
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.Rproj.user
.Rhistory
.Rdata
.httr-oauth
.DS_Store
.quarto
16 changes: 16 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Package: starchart
Title: 'R-Universe' 'API'
Version: 0.0.0.9000
Authors@R:
person("Maëlle", "Salmon", , "[email protected]", role = c("cre", "aut"),
comment = c(ORCID = "0000-0002-2815-0399"))
Description: Client to access the 'R-Universe' 'API'.
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Depends:
R (>= 4.2.0)
Imports:
cli,
httr2
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2024
COPYRIGHT HOLDER: starchart authors
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2024 starchart authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Generated by roxygen2: do not edit by hand

export(universe_ls)
6 changes: 6 additions & 0 deletions R/starchart-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#' @keywords internal
"_PACKAGE"

## usethis namespace: start
## usethis namespace: end
NULL
22 changes: 22 additions & 0 deletions R/universe.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#' All packages in an universe
#'
#' @param universe Name of the universe (character of length 1)
#'
#' @return A character vector of all packages in the universe.
#' @export
#'
#' @examplesIf interactive()
#' universe_ls("jeroen")
#' universe_ls("ropensci")
universe_ls <- function(universe) {
if (!is.character(universe) || length(universe) != 1) {
cli::cli_abort("{.arg universe} must be a character of length 1.")
}
# TODO assert that universe is an universe

universe_query(
universe_url = sprintf("https://%s.r-universe.dev", universe),
path = "ls"
) |>
unlist()
}
8 changes: 8 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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()
}
15 changes: 15 additions & 0 deletions man/starchart-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions man/universe_ls.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions starchart.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Version: 1.0

RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
LineEndingConversion: Posix

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace

0 comments on commit 740e088

Please sign in to comment.