Skip to content

Commit

Permalink
File per export (ropensci#81)
Browse files Browse the repository at this point in the history
* Document `gutenberg_add_metadata`

* Restructure exports/test (ropensci#67)
  • Loading branch information
jrdnbradford authored Oct 14, 2024
1 parent cd9ad51 commit c946d59
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 14 deletions.
8 changes: 7 additions & 1 deletion R/gutenberg_download.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,13 @@ read_next <- function(possible_urls) {
}
}


#' Join metadata fields to Gutenberg works
#'
#' @param gutenberg_tbl A two column `tbl_df` from `gutenberg_download`.
#' @inheritParams gutenberg_download
#'
#' @return A `tbl_df` of the Gutenberg works with joined metadata.
#' @keywords internal
gutenberg_add_metadata <- function(gutenberg_tbl, meta_fields) {
meta_fields <- union("gutenberg_id", meta_fields)
dplyr::left_join(
Expand Down
21 changes: 21 additions & 0 deletions man/gutenberg_add_metadata.Rd

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

11 changes: 11 additions & 0 deletions tests/testthat/test-data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
test_that("All four datasets have a date-updated", {
d1 <- attr(gutenberg_metadata, "date_updated")
d2 <- attr(gutenberg_subjects, "date_updated")
d3 <- attr(gutenberg_authors, "date_updated")
d4 <- attr(gutenberg_languages, "date_updated")

expect_s3_class(d1, "Date")
expect_s3_class(d2, "Date")
expect_s3_class(d3, "Date")
expect_s3_class(d4, "Date")
})
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,3 @@ test_that("gutenberg_works gives error messages with named arguments", {
"named arguments"
)
})


test_that("All four datasets have a date-updated", {
d1 <- attr(gutenberg_metadata, "date_updated")
d2 <- attr(gutenberg_subjects, "date_updated")
d3 <- attr(gutenberg_authors, "date_updated")
d4 <- attr(gutenberg_languages, "date_updated")

expect_s3_class(d1, "Date")
expect_s3_class(d2, "Date")
expect_s3_class(d3, "Date")
expect_s3_class(d4, "Date")
})

0 comments on commit c946d59

Please sign in to comment.