Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to retrieve taxonomy version and tests to verify version #132

Merged
merged 33 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1a2027f
Initial action
jrdnbradford Jul 11, 2024
c6f005e
Add `tax` with sorted `NameCodes`
jrdnbradford Jul 11, 2024
876675f
Add badge to `README`
jrdnbradford Jul 11, 2024
e02f688
Finalize GHA `on`
jrdnbradford Jul 11, 2024
84dd1a6
Merge pull request #10 from jrdnbradford/tax-update-action
jrdnbradford Jul 11, 2024
cdb6bb4
Update from feedback
jrdnbradford Jul 13, 2024
45ebea3
Test version check
jrdnbradford Jul 13, 2024
d6c3a4a
Remove `output`
jrdnbradford Jul 13, 2024
b63e9ee
Fix `if`
jrdnbradford Jul 13, 2024
0c80666
Add `continue-on-error`
jrdnbradford Jul 13, 2024
2e9b74d
Load package from source
jrdnbradford Jul 13, 2024
8c35415
Fix `needs`
jrdnbradford Jul 13, 2024
eb2987e
Test failure
jrdnbradford Jul 13, 2024
d8c61b2
Fix `check-and-create-issue-job` `if`
jrdnbradford Jul 13, 2024
3b49dc5
Debugging `if`
jrdnbradford Jul 13, 2024
8e2afdc
Re-add
jrdnbradford Jul 13, 2024
38df744
Test passed test
jrdnbradford Jul 13, 2024
1ab9b5c
Update docs
jrdnbradford Jul 13, 2024
be13030
Update test vars
jrdnbradford Jul 13, 2024
5e0b663
Update cron comment
jrdnbradford Jul 13, 2024
b940ba8
Merge pull request #12 from jrdnbradford/tax-update-action
jrdnbradford Jul 13, 2024
8b12cfe
Fix documentation typo
jrdnbradford Jul 13, 2024
c5d9609
Update `README`
jrdnbradford Jul 13, 2024
e482fa8
Update `README`
jrdnbradford Jul 13, 2024
ddb62ec
Update tax
jrdnbradford Jul 28, 2024
029645b
Test `workflow_run`
jrdnbradford Jul 28, 2024
21e6b31
Merge branch 'master' into tax-update-action
jrdnbradford Jul 28, 2024
56236ef
Merge pull request #14 from jrdnbradford/tax-update-action
jrdnbradford Jul 28, 2024
14cfeb3
Add failed test
jrdnbradford Jul 28, 2024
ff8a43c
Test reusable workflow
jrdnbradford Jul 28, 2024
a6cf1ef
Use scheduled R-CMD-check
jrdnbradford Aug 12, 2024
dfc9212
Bump version and update changelog
jrdnbradford Aug 12, 2024
4ca3ca5
Merge pull request #15 from jrdnbradford/tax-update-action
jrdnbradford Aug 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [main, master]
pull_request:
branches: [main, master]
schedule:
- cron:
'0 8 1,15 * *' # At 08:00AM on 1st and 15th of month

name: R-CMD-check

Expand All @@ -29,7 +32,7 @@ jobs:
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: rebird
Version: 1.3.9005
Version: 1.3.9006
Title: R Client for the eBird Database of Bird Observations
Description: A programmatic client for the eBird database
(<https://ebird.org/home>), including functions for searching for bird
Expand Down Expand Up @@ -36,7 +36,7 @@ Suggests:
covr,
vcr (>= 0.6.0),
withr
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
X-schema.org-applicationCategory: Data Access
X-schema.org-keywords: birds, birding, ebird, database, data, biology, observations, sightings, ornithology
X-schema.org-isPartOf: https://ropensci.org
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export(ebirdregioninfo)
export(ebirdregionspecies)
export(ebirdsubregionlist)
export(ebirdtaxonomy)
export(ebirdtaxonomyversion)
export(getlatlng)
export(nearestobs)
export(species_code)
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# rebird 1.3.9005
# rebird 1.3.9006

- Added `ebirdtaxonomyversion()` which retrieves data on available taxonomy versions.
The version is added as an attribute to `rebird::tax` (#131).
- Added `ebirdchecklist()`, which lets you view individual checklists (thanks @RichardLitt and @Rafnuss, #108).
- Made `ebirdregioncheck()`, `ebirdhotspot()`, `ebirdloc()` defunct.
- API tests now use `vcr`, which saves "cassettes" of the tests which can be played
Expand Down
10 changes: 6 additions & 4 deletions R/ebirdtaxonomy.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ ebirdtaxonomy <- function(cat=NULL, locale=NULL, species = NULL, key = NULL, ...
species <- if(!is.null(species)) species <- paste0(species, collapse = ",")
args <- list(fmt='json', cat=cat, locale=locale, species=species)

# Allow not using a key for just this function, it's the only endpoint
# that allows it
# Allow not using a key for this function
if (is.null(key) && !nzchar(Sys.getenv("EBIRD_KEY"))) {
key <- ""
}

ebird_GET(paste0(ebase(), 'ref/taxonomy/ebird'), args, key = key, ...)

tax <- ebird_GET(paste0(ebase(), 'ref/taxonomy/ebird'), args, key = key, ...)
latest <- subset(ebirdtaxonomyversion(), latest == TRUE)$authorityVer
attr(tax, "version") <- latest
tax
}
31 changes: 31 additions & 0 deletions R/ebirdtaxonomyversion.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#' eBird Taxonomy Version
#'
#' Returns a data.frame of available version numbers of the eBird taxonomy
#'
#' @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
#' supply the key, and to avoid accidentally sharing it publicly.
#' @param ... Curl options passed on to \code{\link[httr]{GET}}
#'
#' @return data.frame containing the collected information:
#' @return "authorityVer": Character of version.
#' @return "latest": Boolean indicating whether `authorityVer` is the latest taxonomy version
#'
#' @export
#'
#' @examples \dontrun{
#' ebirdtaxonomyversion()
#' }
#' @author Jordan Bradford \email{[email protected]}
#' @references \url{http://ebird.org/}
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 <- ""
}

ebird_GET(paste0(ebase(), 'ref/taxonomy/versions'), args, key = key, ...)
}
1 change: 0 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,3 @@ ebird_GET <- function(url, args, key = NULL, ...){
}
}
}

4 changes: 2 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,12 @@ The 2.0 APIs have considerably been expanded from the previous version, and `reb
### ref/taxonomy
- [x] eBird Taxonomy: `ebirdtaxonomy()`
- [ ] Taxonomic Forms
- [ ] Taxonomy Versions
- [x] Taxonomy Versions: `ebirdtaxonomyversion()`
- [ ] Taxonomic Groups

### ref/region
- [x] Region Info: `ebirdregioninfo()`
- [x] Sub Region List `ebirdsubregionlist()`
- [x] Sub Region List: `ebirdsubregionlist()`


## Meta
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -558,13 +558,13 @@ covered by this package, feel free to submit a pull request!

- [x] eBird Taxonomy: `ebirdtaxonomy()`
- [ ] Taxonomic Forms
- [ ] Taxonomy Versions
- [x] Taxonomy Versions: `ebirdtaxonomyversion()`
- [ ] Taxonomic Groups

### ref/region

- [x] Region Info: `ebirdregioninfo()`
- [x] Sub Region List `ebirdsubregionlist()`
- [x] Sub Region List: `ebirdsubregionlist()`

## Meta

Expand Down
4 changes: 2 additions & 2 deletions data-raw/tax.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# eBird taxonomy to look up species codes
#
# This creates the internal taxonomy data frame used by rebird, which
# is stored ind 'R/sysdata.rda'. We update the package in CRAN when
# This creates the taxonomy data frame used by rebird, which
# is stored in 'data/tax.rda'. We update the package in CRAN when
# the eBird taxonomy update is completed, but in the event you need
# to update the taxonomy yourself you can do so by running the code below.

Expand Down
Binary file modified data/tax.rda
Binary file not shown.
37 changes: 37 additions & 0 deletions man/ebirdtaxonomyversion.Rd

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

Loading
Loading