-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- switch to `source` and `destination` argument syntax - use `corella::darwin_core_terms` to add links to schema
- Loading branch information
1 parent
b96d00e
commit 61737d7
Showing
9 changed files
with
96 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,35 @@ | ||
#' Create a metadata statement for a Darwin Core Archive | ||
#' | ||
#' A metadata statement lists the owner of the dataset, how it was collected, | ||
#' and how it may used (i.e. its' licence). This function simply converts | ||
#' metadata stored in a markdown file to xml, and stores it in the folder | ||
#' specified using the `directory` argument. | ||
#' and how it can be used (i.e. its' licence). This function simply reads | ||
#' converts metadata stored in a markdown file, converts it to xml, and saves it | ||
#' in the `destination` file. | ||
#' | ||
#' This function is a fairly shallow wrapper on top of functionality build | ||
#' in the `paperbark` package, particularly `read_md()` and `write_eml()`. You can | ||
#' use that package to gain greater control, or to debug problems, should you | ||
#' wish. | ||
#' @param path Path to a metadata statement stored in markdown format (.md). | ||
#' @param file A file where the result should be saved. Defaults to | ||
#' @param source A metadata file stored in markdown format (`.md`). Defaults | ||
#' to `metadata.md`, which is the same as is created by [use_metdata()] | ||
#' @param destination A file where the result should be saved. Defaults to | ||
#' `data/eml.xml`. | ||
#' @returns Does not return an object to the workspace; called for the side | ||
#' effect of building a file named `meta.xml` in the `data` directory. | ||
#' @importFrom paperbark read_md | ||
#' @importFrom paperbark write_eml | ||
#' @export | ||
build_metadata <- function(x = "data", | ||
file = "./data/eml.xml"){ | ||
if(!file.exists(x)){ | ||
cli::cli_abort("{.file {x}} doesn't exist in specified location.") | ||
build_metadata <- function(source = "metadata.md", | ||
destination = "./data/eml.xml"){ | ||
if(!file.exists(source)){ | ||
cli::cli_abort("`{source}` doesn't exist in specified location.") | ||
} | ||
# import file, ensure EML metadata is added, convert to XML | ||
progress_update("Reading file...") | ||
metadata_file <- read_md(x) | ||
metadata_tbl <- read_md(source) | ||
|
||
progress_update("Writing file...") | ||
write_eml(built_file, file = file) | ||
write_eml(metadata_tbl, file = destination) | ||
|
||
cli::cli_alert_success("Metadata successfully built. Saved as {.file /data/eml.xml}.") | ||
cli::cli_alert_success("Metadata successfully built. Saved as `{destination}`.") | ||
cli::cli_progress_done() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters