Skip to content

Commit 86ccdfc

Browse files
authored
Merge pull request #55 from allenbaron/fix_ftxt
Update empc_ftxt() to indicate 1 input limit
2 parents b3d4794 + 99fb4ba commit 86ccdfc

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

‎R/epmc_ftxt.r‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#' Fetch Europe PMC full texts
1+
#' Fetch Europe PMC full text
22
#'
3-
#' This function loads full texts into R. Full texts are in XML format and are
3+
#' This function loads one full text into R. Full text is in XML format and is
44
#' only provided for the Open Access subset of Europe PMC.
55
#'
66
#' @param ext_id character, PMCID.
@@ -15,8 +15,8 @@
1515
#' epmc_ftxt("PMC3639880")
1616
#' }
1717
epmc_ftxt <- function(ext_id = NULL) {
18-
if (!grepl("^PMC", ext_id))
19-
stop("Please provide a PMCID, i.e. ids starting with 'PMC'")
18+
if (!grepl("^PMC", ext_id) || length(ext_id) != 1)
19+
stop("Please provide one PMCID, i.e. id starting with 'PMC'")
2020
# call api
2121
req <-
2222
httr::RETRY("GET",

‎tests/testthat/test_epmc_ftxt.r‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ test_that("epmc_ftxt returns", {
55
a <- epmc_ftxt("PMC3257301")
66
b <- epmc_ftxt("PMC3639880")
77

8-
#correct class metadata
8+
# correct class metadata
99
expect_is(a, "xml_document")
1010
expect_is(b, "xml_document")
1111

1212
# fails correctly
1313
expect_error(epmc_ftxt("2PMC3448176"))
1414
expect_error(epmc_ftxt("PMC3476"))
1515
expect_error(epmc_ftxt("3476"),
16-
"Please provide a PMCID, i.e. ids starting with 'PMC'"
17-
)
16+
"Please provide one PMCID, i.e. id starting with 'PMC'"
17+
)
1818
})

0 commit comments

Comments
 (0)