Skip to content

Commit

Permalink
fetchSOLUS: handle rvest namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
brownag committed Oct 23, 2024
1 parent 98bf43e commit d2a5578
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions R/fetchSOLUS.R
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ fetchSOLUS <- function(x = NULL,
.get_SOLUS_index <- function() {

# TODO: parse XML directly instead of HTML?
if (!requireNamespace("rvest")) {
stop("package 'rvest' is required", call. = FALSE)
}

# read index as HTML table
res <- rvest::html_table(rvest::read_html("https://storage.googleapis.com/solus100pub/index.html"), header = FALSE)[[1]]
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-fetchSOLUS.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ test_that("fetchSOLUS works", {

skip_if_not_installed("terra")

skip_if_not_installed("rvest")

b <- c(-119.747629, -119.67935, 36.912019, 36.944987)

bbox.sp <- sf::st_as_sf(wk::rct(
Expand Down Expand Up @@ -55,6 +57,8 @@ test_that("virtual and out-of-bounds requests", {

skip_if_not_installed("terra")

skip_if_not_installed("rvest")

# virtual raster for one variable*depth
tmp <- fetchSOLUS(variables = "claytotal",
output_type = "prediction",
Expand Down

0 comments on commit d2a5578

Please sign in to comment.