From f2be005ee1a542c70b7bda18c38d0810a369ad98 Mon Sep 17 00:00:00 2001 From: Toby Hodges Date: Tue, 7 May 2024 10:17:33 +0200 Subject: [PATCH 1/3] add template CITATION.cff --- R/create_lesson.R | 1 + R/template.R | 4 ++++ inst/templates/citation-template.txt | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 inst/templates/citation-template.txt diff --git a/R/create_lesson.R b/R/create_lesson.R index db87fc7d4..b62d7e776 100644 --- a/R/create_lesson.R +++ b/R/create_lesson.R @@ -41,6 +41,7 @@ create_lesson <- function(path, name = fs::path_file(path), rmd = TRUE, rstudio copy_template("conduct", path, "CODE_OF_CONDUCT.md") copy_template("license", path, "LICENSE.md") copy_template("contributing", path, "CONTRIBUTING.md") + copy_template("citation", path, "CITATION.cff") copy_template("setup", fs::path(path, "learners"), "setup.md") copy_template("index", path, "index.md") copy_template("links", path, "links.md") diff --git a/R/template.R b/R/template.R index 8c5377d86..39dab309d 100644 --- a/R/template.R +++ b/R/template.R @@ -56,6 +56,10 @@ template_episode <- generate_template_function("episode") #' @export template_links <- generate_template_function("links") +#' @rdname template +#' @export +template_citation <- generate_template_function("citation") + #' @rdname template #' @export template_config <- generate_template_function("config") diff --git a/inst/templates/citation-template.txt b/inst/templates/citation-template.txt new file mode 100644 index 000000000..8664c63bb --- /dev/null +++ b/inst/templates/citation-template.txt @@ -0,0 +1,22 @@ +# This template CITATION.cff file was generated with cffinit. +# Visit https://bit.ly/cffinit to replace its contents +# with information about your lesson. +# Remember to update this file periodically, +# ensuring that the author list and other fields remain accurate. + +cff-version: 1.2.0 +title: FIXME +message: >- + Please cite this lesson using the information in this file + when you refer to it in publications, and/or if you + re-use, adapt, or expand on the content in your own + training material. +type: dataset +authors: + - given-names: FIXME + family-names: FIXME +abstract: >- + FIXME Replace this with a short abstract describing the + lesson, e.g. its target audience and main intended + learning objectives. +license: CC-BY-4.0 \ No newline at end of file From 9daba16063df3b8f082814f1ff0d18fa20dbe49c Mon Sep 17 00:00:00 2001 From: Toby Hodges Date: Tue, 7 May 2024 10:17:51 +0200 Subject: [PATCH 2/3] test for templated citation file --- tests/testthat/test-create_lesson.R | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/testthat/test-create_lesson.R b/tests/testthat/test-create_lesson.R index 549c9c14f..d81d649d1 100644 --- a/tests/testthat/test-create_lesson.R +++ b/tests/testthat/test-create_lesson.R @@ -61,6 +61,7 @@ test_that("All template files exist", { expect_true(fs::file_exists(fs::path(tmp, "episodes", "introduction.Rmd"))) expect_true(fs::file_exists(fs::path(tmp, ".gitignore"))) expect_true(fs::file_exists(fs::path(tmp, paste0(basename(tmp), ".Rproj")))) + expect_true(fs::file_exists(fs::path(tmp, "CITATION.cff"))) }) test_that("Templated files are correct", { @@ -74,6 +75,10 @@ test_that("Templated files are correct", { readLines(fs::path(tmp, "episodes", "introduction.Rmd")), strsplit(expected, "\n")[[1]] ) + expect_setequal( + readLines(fs::path(tmp, "CITATION.cff")), + readLines(template_citation()) + ) }) From b3d18daccd29dfbe0dc93cdd27bc57cc7181552e Mon Sep 17 00:00:00 2001 From: Robert Davey Date: Tue, 7 May 2024 18:18:54 +0100 Subject: [PATCH 3/3] Tidy spacing in test-create_lesson.R --- tests/testthat/test-create_lesson.R | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/testthat/test-create_lesson.R b/tests/testthat/test-create_lesson.R index d81d649d1..bb929b809 100644 --- a/tests/testthat/test-create_lesson.R +++ b/tests/testthat/test-create_lesson.R @@ -8,7 +8,6 @@ } test_that("lessons can be created in empty directories", { - expect_false(fs::dir_exists(tmp)) suppressMessages({capture.output({ res <- create_lesson(tmp, name = "BRAND NEW LESSON", rstudio = TRUE, open = TRUE) @@ -26,7 +25,6 @@ test_that("lessons are NOT initialized with a 'master' branch", { expect_false(gert::git_branch_exists("master", repo = tmp)) # enforce that our new branch matches the user's default branch (or main) expect_true(gert::git_branch(tmp) == sandpaper:::get_default_branch()) - }) test_that("check_lesson() passes muster on new lessons", { @@ -79,7 +77,6 @@ test_that("Templated files are correct", { readLines(fs::path(tmp, "CITATION.cff")), readLines(template_citation()) ) - }) test_that("Lesson configuration is correctly provisioned", { @@ -127,7 +124,6 @@ test_that("We have a git repo that's correctly configured", { }) cli::test_that_cli("Destruction of the .gitignore file renders the lesson incorrect", { - if (fs::file_exists(gi <- fs::path(tmp, ".gitignore"))) fs::file_delete(gi) expect_snapshot({ expect_error( @@ -138,7 +134,6 @@ cli::test_that_cli("Destruction of the .gitignore file renders the lesson incorr }) test_that("lessons cannot be created in directories that are occupied", { - skip("needs evaluation, but not critical infrastructure tool") tmpdir <- fs::file_temp() fs::dir_create(tmpdir) @@ -153,5 +148,4 @@ test_that("lessons cannot be created in directories that are occupied", { # This should fail expect_error(create_lesson(tmp, open = FALSE), "lesson-example is not an empty directory.") - })