Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
fix #16 move to using crul instead of httr in suggests for validate fxn
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Jan 25, 2018
1 parent 0230196 commit fa560bf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Imports:
digest
Suggests:
testthat,
httr,
crul,
jsonlite
RoxygenNote: 6.0.1
X-schema.org-applicationCategory: Biology
Expand Down
16 changes: 10 additions & 6 deletions R/dwca_validate.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,28 @@
#' to generate the archive on the fly this might not be recognised. Optional.
#' @param browse (logical) Browse to generated report or not.
#' Default: `FALSE`
#' @param ... Curl options passed to [httr::GET()]
#' @param ... Curl options passed to [crul::HttpClient]
#' @details Uses the GBIF DCA validator (http://tools.gbif.org/dwca-validator/)
#'
#' @examples \dontrun{
#' x <- "http://rs.gbif.org/datasets/german_sl.zip"
#' dwca_validate(x)
#' }
dwca_validate <- function(x, ifModifiedSince = NULL, browse = FALSE, ...) {
checkforpkg("httr")
checkforpkg("crul")
checkforpkg("jsonlite")
if (!is.character(x)) stop(x, " must be character class", call. = FALSE)
if (!is.url(x)) stop(x, " does not appear to be a URL", call. = FALSE)
args <- fcmp(list(archiveUrl = x, ifModifiedSince = ifModifiedSince))
res <- httr::GET(gbif_val(), query = args)
httr::stop_for_status(res)
tmp <- httr::content(res, "text")
cli <- crul::HttpClient$new(url = gbif_val(), opts = list(...))
res <- cli$get(query = args)
res$raise_for_status()
tmp <- res$parse("UTF-8")
# res <- httr::GET(gbif_val(), query = args)
# httr::stop_for_status(res)
# tmp <- httr::content(res, "text")
dat <- jsonlite::fromJSON(tmp)
if (browse) utils::browseURL(dat$report) else dat
}

gbif_val <- function() "http://tools.gbif.org/dwca-validator/validatews.do"
gbif_val <- function() "https://tools.gbif.org/dwca-validator/validatews.do"
2 changes: 1 addition & 1 deletion man/dwca_validate.Rd

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

0 comments on commit fa560bf

Please sign in to comment.