-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from jrdnbradford/tax-update-action
Tax update action
- Loading branch information
Showing
10 changed files
with
35 additions
and
140 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
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,42 +1,31 @@ | ||
#' eBird Taxonomy Version | ||
#' | ||
#' Returns a data.frame of available version numbers of | ||
#' the eBird taxonomy or the latest version number of the | ||
#' taxonomy. | ||
#' Returns a data.frame of available version numbers of the eBird taxonomy | ||
#' | ||
#' @param key eBird API key. You can obtain one from https://ebird.org/api/keygen. | ||
#' @param key optional eBird API key. You can obtain one from https://ebird.org/api/keygen. | ||
#' We strongly recommend storing it in your \code{.Renviron} file as an | ||
#' environment variable called \code{EBIRD_KEY} to avoid having to constantly | ||
#' environment variable called \code{EBIRD_KEY} to avoid having to constantly | ||
#' supply the key, and to avoid accidentally sharing it publicly. | ||
#' @param latest_only Whether to return only the latest version number | ||
#' @param ... Curl options passed on to \code{\link[httr]{GET}} | ||
#' | ||
#' @return If `latest_only = FALSE`, a data.frame containing the collected information: | ||
#' | ||
#' @return data.frame containing the collected information: | ||
#' @return "authorityVer": Character of version. | ||
#' @return "latest": Boolean indicating whether `authorityVer` is the latest taxonomy version | ||
#' @return If `latest_only = TRUE`, a character of the latest `authorityVer` | ||
#' | ||
#' | ||
#' @export | ||
#' | ||
#' | ||
#' @examples \dontrun{ | ||
#' ebirdtaxonomyversion() | ||
#' ebirdtaxonomyversion(latest_only = TRUE) | ||
#' } | ||
#' @author Jordan Bradford \email{[email protected]} | ||
#' @references \url{http://ebird.org/} | ||
ebirdtaxonomyversion <- function(key = NULL, latest_only = FALSE, ...) { | ||
ebirdtaxonomyversion <- function(key = NULL, ...) { | ||
args <- list(fmt = 'json') | ||
|
||
# Allow not using a key for this function | ||
if (is.null(key) && !nzchar(Sys.getenv("EBIRD_KEY"))) { | ||
key <- "" | ||
} | ||
|
||
versions <- ebird_GET(paste0(ebase(), 'ref/taxonomy/versions'), args, key = key, ...) | ||
versions$authorityVer <- sub("0+$", "", as.character(versions$authorityVer)) | ||
|
||
if (latest_only) { | ||
return(subset(versions, latest == TRUE)$authorityVer) | ||
} | ||
versions | ||
ebird_GET(paste0(ebase(), 'ref/taxonomy/versions'), args, key = key, ...) | ||
} |
Binary file not shown.
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
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,6 @@ | ||
test_that("tax dataset version is latest version", { | ||
latest_version <- ebirdtaxonomyversion(latest_only = TRUE) | ||
temp_env <- new.env() | ||
data("tax", envir = temp_env) | ||
dataset_tax <- temp_env$tax | ||
dataset_tax_version <- attr(dataset_tax, "version") | ||
latest_version <- subset(ebirdtaxonomyversion(), latest == TRUE)$authorityVer | ||
tax <- rebird::tax | ||
dataset_tax_version <- attr(tax, "version") | ||
expect_equal(latest_version, dataset_tax_version) | ||
}) |
This file was deleted.
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
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