-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
add a print function for data packages
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ Authors@R: c( | |
role = "aut", comment = c(ORCID = "0000-0003-3445-7562")), | ||
person("Pieter", "Huybrechts", email = "[email protected]", | ||
role = "aut", comment = c(ORCID = "0000-0002-6658-6062")), | ||
person("Kyle", "Husmann", email = "[email protected]", | ||
role = "ctb", comment = c(ORCID = "0000-0001-9875-8976")), | ||
person("Research Institute for Nature and Forest (INBO)", | ||
role = "cph", comment = "https://www.vlaanderen.be/inbo/en-gb/"), | ||
person("LifeWatch Belgium", | ||
|
@@ -51,4 +53,4 @@ Encoding: UTF-8 | |
Language: en-GB | ||
LazyData: true | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.3.0 | ||
RoxygenNote: 7.3.1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,5 +62,6 @@ check_path <- function(path, directory = NULL, safe = FALSE) { | |
) | ||
} | ||
} | ||
|
||
return(path) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,5 +124,5 @@ create_schema <- function(data) { | |
recursive = TRUE | ||
) | ||
|
||
schema | ||
return(schema) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,5 +65,5 @@ get_resource <- function(package, resource_name) { | |
resource$read_from <- "data" | ||
} | ||
|
||
resource | ||
return(resource) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,5 +43,5 @@ get_schema <- function(package, resource_name) { | |
# Check schema | ||
check_schema(schema) | ||
|
||
schema | ||
return(schema) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#' Print a Data Package | ||
#' | ||
#' Prints a human-readable summary of a Data Package, including its resources | ||
#' and a link to more information (if provided in `package$id`). | ||
#' | ||
#' @param x Data Package object, created with [read_package()] or | ||
#' [create_package()]. | ||
#' @param ... Further arguments, they are ignored by this function. | ||
#' @return [print()] with a summary of the Data Package object. | ||
#' @family datapackage functions | ||
#' @export | ||
#' @examples | ||
#' # Load the example Data Package | ||
#' package <- example_package | ||
#' | ||
#' # Print a summary of the Data Package | ||
#' package # Or print(package) | ||
print.datapackage <- function(x, ...) { | ||
# All prints should use cat (= cli::cat() helpers) | ||
|
||
# List resources | ||
resources <- resources(x) | ||
cli::cat_line( | ||
cli::format_inline( | ||
"A Data Package with {length(resources)} resource{?s}{?./:/:}" | ||
) | ||
) | ||
if (length(resources) > 0) { | ||
cli::cat_bullet(resources, bullet = "bullet") | ||
} | ||
|
||
# Include link (DOI) if available in package$id | ||
if (startsWith(replace_null(x$id, ""), "http")) { | ||
cli::cat_line( | ||
cli::format_inline("For more information, see {.url {x$id}}.") | ||
) | ||
} | ||
|
||
# Provide help | ||
cli::cat_line( | ||
cli::format_inline( | ||
"Use {.fun unclass} to print the Data Package as a list." | ||
), | ||
col = "silver" | ||
) | ||
|
||
invisible(x) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,5 +28,5 @@ remove_resource <- function(package, resource_name) { | |
(x$name == resource_name) | ||
}) | ||
|
||
package | ||
return(package) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.