Skip to content

Commit

Permalink
Remove lazyeval dependency. (#74)
Browse files Browse the repository at this point in the history
Closes #60.
  • Loading branch information
jonthegeek authored Sep 5, 2024
1 parent 63301e3 commit 9d71290
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Authors@R: c(
person("Jon", "Harmon", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-4781-4346")),
person("Myfanwy", "Johnston", , "[email protected]", role = "aut"),
person("Jordan", "Bradford", , "[email protected]", role = "aut"),
person("David", "Robinson", , "[email protected]", role = c("aut", "cph"))
)
Description: Download and process public domain works in the Project
Expand All @@ -21,7 +22,6 @@ Imports:
cli,
dplyr,
glue,
lazyeval,
magrittr,
purrr,
readr,
Expand Down
6 changes: 4 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# gutenbergr (development version)

* `gutenberg_get_all_mirrors()` has been added to retrieve mirror data (@jrdnbradford, #58)
* `gutenberg_download()` tries the `.txt` version of files when the `.zip` is unavailable (@jrdnbradford, #55).
* New function `gutenberg_get_all_mirrors()` retrieves all mirror data (@jrdnbradford, #58).
* The package infrastructure has been updated to make the package more robust and maintainable.

# gutenbergr 0.2.4

Expand All @@ -14,7 +16,7 @@

* Updated metadata (#32, #29)
* minor bug fixes and improvements, including removing broken url and updating documentation to comply with CRAN roxygen2 requirements (#30, #31, #35, #28).
* Changed maintainer (#30)
* Changed maintainer (#30).

# gutenbergr 0.2.0

Expand Down
3 changes: 2 additions & 1 deletion R/gutenberg_download.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ try_gutenberg_download <- function(url) {
"i" = "The book may have been archived.",
"i" = "Alternatively, You may need to select a different mirror.",
">" = "See https://www.gutenberg.org/MIRRORS.ALL for options."
)
),
class = "gutenbergr-warning-download_failure"
)
}
return(ret)
Expand Down
22 changes: 12 additions & 10 deletions R/gutenberg_works.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,19 @@ gutenberg_works <- function(..., languages = "en",
distinct = TRUE,
all_languages = FALSE,
only_languages = TRUE) {
dots <- lazyeval::lazy_dots(...)
if (length(dots) > 0 && any(names(dots) != "")) {
cli::cli_abort(
c(
x = "We detected a named input.",
i = "Use == expressions, not named arguments.",
i = "For example, use gutenberg_works(author == 'Dickens, Charles'),",
i = "not gutenberg_works(author = 'Dickens, Charles')."
rlang::check_dots_unnamed(
error = function(e) {
cli::cli_abort(
c(
x = "We detected a named input.",
i = "Use == expressions, not named arguments.",
i = "For example, use gutenberg_works(author == 'Dickens, Charles'),",
i = "not gutenberg_works(author = 'Dickens, Charles')."
),
call = rlang::env_parent()
)
)
}
}
)
ret <- filter(gutenberg_metadata, ...)

if (!is.null(languages)) {
Expand Down
1 change: 1 addition & 0 deletions man/gutenbergr-package.Rd

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

12 changes: 12 additions & 0 deletions tests/testthat/test-gutenberg_download.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,15 @@ test_that("gutenberg_download works", {
)
expect_identical(test_result, gutenbergr::sample_books)
})

test_that("try_gutenberg_download errors informatively with no return", {
local_mocked_bindings(
read_next = function(url) {
return(NULL)
}
)
expect_warning(
try_gutenberg_download("https://example.com"),
class = "gutenbergr-warning-download_failure"
)
})

0 comments on commit 9d71290

Please sign in to comment.