Skip to content

Commit 8736b7c

Browse files
authored
fix: add acceptedUsageKey and acceptedScientificName to name_backbone output #824 (#826)
1 parent 7fdf1b0 commit 8736b7c

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Description: A programmatic interface to the Web Service methods
88
retrieving information on data providers, getting species occurrence
99
records, getting counts of occurrence records, and using the GBIF
1010
tile map service to make rasters summarizing huge amounts of data.
11-
Version: 3.8.4.1
11+
Version: 3.8.4.2
1212
License: MIT + file LICENSE
1313
Authors@R: c(
1414
person("Scott", "Chamberlain", role = "aut", comment = c("0000-0003-1444-9135")),

R/name_backbone.r

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,14 @@ process_name_backbone_output <- function(tt, args) {
262262
} else {
263263
NULL
264264
}
265+
acceptedUsage <- if (!is.null(tt$acceptedUsage)) {
266+
a <- tibble::as_tibble(tt$acceptedUsage)[c("key","name")]
267+
colnames(a)[colnames(a) == "key"] <- "acceptedUsageKey"
268+
colnames(a)[colnames(a) == "name"] <- "acceptedScientificName"
269+
a
270+
} else {
271+
NULL
272+
}
265273
verbatim <- if (!is.null(args)) {
266274
input_args_clean <- args[!names(args) %in%
267275
c("strict","verbose","start","limit","curlopts")]
@@ -273,7 +281,8 @@ process_name_backbone_output <- function(tt, args) {
273281
} else {
274282
NULL
275283
}
276-
out <- do.call("cbind", rgbif_compact(list(usage,
284+
out <- do.call("cbind", rgbif_compact(list(usage,
285+
acceptedUsage,
277286
diagnostics,
278287
classification,
279288
synonym,

tests/fixtures/name_backbone_acceptedUsageKey.yml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-name_backbone.r

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,14 @@ test_that("name_backbone verbose=TRUE", {
127127
expect_true(all(vv$verbatim_name == "Calopteryx"))
128128
expect_true(nrow(vv) > nrow(tt))
129129
})
130+
131+
test_that("name_backbone returns acceptedUsageKey", {
132+
vcr::use_cassette("name_backbone_acceptedUsageKey", {
133+
aa <- name_backbone(name = 'Anastrophyllum minutum')
134+
})
135+
expect_is(aa, "tbl")
136+
expect_is(aa, "tbl_df")
137+
expect_is(aa, "data.frame")
138+
expect_true("acceptedUsageKey" %in% colnames(aa))
139+
expect_true("acceptedScientificName" %in% colnames(aa))
140+
})

0 commit comments

Comments
 (0)