Skip to content

Commit b96d00e

Browse files
committed
add suggest_workflow() and use_metadata()
Former re-exported from `corella`; latter moved from `paperbark`. Also add `corella` as a Depends to ensure it always loads with galaxias
1 parent 11e4833 commit b96d00e

11 files changed

+94
-13
lines changed

DESCRIPTION

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ Description: galaxias helps users describe, package and share biodiversity
2121
partner nodes. It is functionally similar to `devtools`, but with a focus on
2222
building Darwin Core Archives (DwCA's) rather than R packages.
2323
Depends:
24-
R (>= 4.3.0)
24+
R (>= 4.3.0),
25+
corella
2526
Imports:
2627
cli,
27-
corella,
2828
curl,
2929
dplyr,
3030
glue,

NAMESPACE

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export(galaxias_config)
1111
export(galaxias_package)
1212
export(galaxias_project)
1313
export(get_validator_report)
14+
export(suggest_workflow)
15+
export(use_metadata)
1416
export(validate_archive)
1517
importFrom(cli,cat_line)
1618
importFrom(cli,cli_abort)
@@ -20,6 +22,7 @@ importFrom(cli,cli_inform)
2022
importFrom(cli,cli_progress_step)
2123
importFrom(cli,cli_progress_update)
2224
importFrom(corella,check_dataset)
25+
importFrom(corella,suggest_workflow)
2326
importFrom(curl,form_data)
2427
importFrom(curl,form_file)
2528
importFrom(dplyr,bind_rows)
@@ -40,8 +43,8 @@ importFrom(jsonlite,toJSON)
4043
importFrom(jsonlite,unbox)
4144
importFrom(paperbark,check_eml)
4245
importFrom(paperbark,read_md)
43-
importFrom(paperbark,use_metadata)
4446
importFrom(paperbark,write_eml)
47+
importFrom(paperbark,write_md)
4548
importFrom(potions,brew)
4649
importFrom(potions,pour)
4750
importFrom(purrr,map)

R/check_archive.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#' the console.
1313
#' @importFrom utils unzip
1414
#' @export
15-
check_archive <- function(x = "data"){
15+
check_archive <- function(x = "data"){ # add `file` arg for consistency with `check_eml()`
1616
if(!file.exists(x)){
1717
abort(glue("file or directory '{x}' not found"))
1818
}else{
@@ -38,8 +38,8 @@ check_files <- function(filenames){
3838
switch(a,
3939
"occurrences.csv" = {read_csv(a) |>
4040
check_dataset()},
41-
"meta.xml" = {check_eml(a)},
42-
"eml.xml" = {check_eml(a)}
41+
"meta.xml" = {check_eml(file = a)},
42+
"eml.xml" = {check_eml(file = a)}
4343
)
4444
}) |>
4545
invisible()

R/galaxias-package.R

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#' @description
44
#' `galaxias` helps users describe, package and share biodiversity
55
#' information using the 'Darwin Core' data standard, which is the format used
6-
#' and accepted by the Global Biodiversity Information Facility (GBIF) and it's
6+
#' and accepted by the Global Biodiversity Information Facility (GBIF) and its'
77
#' partner nodes. It is functionally similar to `devtools`, but with a focus on
88
#' building Darwin Core Archives rather than R packages.
99
#'
@@ -16,10 +16,12 @@
1616
#'
1717
#' **Set up a project**
1818
#' * [galaxias_project()] Set up a project with the necessary folder structure
19+
#' * [use_metadata()] Add a blank metadata statement to the working directory
20+
#' * [suggest_workflow()] Advise on configuring a tibble for the Darwin Core standard
1921
#'
2022
#' **Construct an archive**
2123
#' * [build_schema()] Build a schema file (`meta.xml`) for a given directory
22-
#' * [build_metadata()] Supply a metadata file in .md format, and convert to a metadata file (`eml.xml`)
24+
#' * [build_metadata()] Convert a metadata file from markdown to EML (`eml.xml`)
2325
#' * [build_archive()] Convert a directory to a Darwin Core Archive
2426
#'
2527
#' **Validate an archive**

R/galaxias_project.R

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#' side-effect of building a new project or package.
1313
#' @name galaxias_project
1414
#' @order 1
15-
#' @importFrom paperbark use_metadata
1615
#' @importFrom usethis create_project
1716
#' @importFrom usethis use_directory
1817
#' @export
@@ -21,7 +20,6 @@ galaxias_project <- function(path, ...){
2120
use_metadata()
2221
use_directory("data_raw")
2322
use_directory("data")
24-
2523
}
2624

2725
#' @rdname galaxias_project

R/suggest_workflow.R

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#' @importFrom corella suggest_workflow
2+
#' @export
3+
corella::suggest_workflow

R/use_metadata.R

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#' Write an example metadata statement
2+
#'
3+
#' This function takes `metadata_example` and exports it to the specified file.
4+
#' This is useful for creating a boilerplate metadata statement that you
5+
#' can edit yourself.
6+
#' @param file (string) A filename to save the statement to. Defaults to
7+
#' `"metadata.md"`.
8+
#' @param overwrite (logical) Should any existing file with this name be
9+
#' overwritten? Defaults to `FALSE`.
10+
#' @returns Does not return an object to the workspace; called for the
11+
#' side-effect of saving a markdown file to the specified location.
12+
#' @importFrom glue glue
13+
#' @importFrom paperbark write_md
14+
#' @importFrom rlang abort
15+
#' @export
16+
use_metadata <- function(file, overwrite = FALSE){
17+
if(missing(file)){
18+
file <- "metadata.md"
19+
}
20+
if(overwrite){
21+
write_md(paperbark::metadata_example, file = file)
22+
}else{
23+
if(file.exists(file)){
24+
abort(c(glue("file `{file}` already exists."),
25+
i = "give a different `file` or set `overwrite = TRUE`"))
26+
}else{
27+
write_md(paperbark::metadata_example, file = file)
28+
}
29+
}
30+
}

_pkgdown.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ navbar:
3232
href: news/index.html
3333
reference:
3434
- title: Set up a project
35-
contents: galaxias_project
35+
contents:
36+
- galaxias_project
37+
- use_metadata
38+
- suggest_workflow
3639
- title: Construct an archive
3740
contents:
3841
- build_metadata

man/galaxias-package.Rd

+4-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/reexports.Rd

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/use_metadata.Rd

+24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)