Skip to content

Commit 808fef3

Browse files
authored
Merge pull request DOI-NPS#193 from RobLBaker/main
add function to support removal of arcticdatautils dependency across NPSdataverse
2 parents 4f6a503 + 01858f9 commit 808fef3

9 files changed

Lines changed: 74 additions & 7 deletions

File tree

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export(get_doi)
1414
export(get_drr_doi)
1515
export(get_drr_title)
1616
export(get_ds_id)
17+
export(get_eml_simple)
1718
export(get_end_date)
1819
export(get_file_info)
1920
export(get_lit)

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# EMLeditor v1.0.1 (under development)
2+
## 2025-04-11
3+
* add `get_eml_simple` function and associated unit test.
4+
25
## 2025-04-09
36
* update `set_data_urls` to set dataset urls in addition to dataTable urls. `set_data_urls` now adds a function = "information" tag to urls because they do not lead to direct file download links. It will overwrite all function = "download" tags added by ezEML.
47
* update `set_data_urls` unit tests; add test for function = "information".

R/getEMLfunctions.R

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
#' Returns a simple list of eml elements
2+
#'
3+
#' This function wraps EML::get_eml and returns the requested object in a much simpler format. It works best with eml elements that do not have child elements.
4+
#'
5+
#' @param eml_object is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml").
6+
#' @param eml_element is a string indicating the element within the eml_object that should be accessed and returned.
7+
#'
8+
#' @returns a list of values
9+
#' @export
10+
#' @examples
11+
#' \dontrun{
12+
#' get_eml_simple(eml_object, "geographicDescription")
13+
#' }
14+
get_eml_simple <- function(eml_object, eml_element){
15+
out <- EML::eml_get(eml_object, eml_element, from = "list")
16+
out$`@context` <- NULL
17+
attributes(out) <- NULL
18+
out <- unlist(out)
19+
return(out)
20+
}
21+
122
#' returns the first date
223
#'
324
#' @description get_begin_date returns the date of the earliest data point in the data package

docs/news/index.html

Lines changed: 10 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/pkgdown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ articles:
77
a03_Template_edits: a03_Template_edits.html
88
a04_Editing_fixing_eml: a04_Editing_fixing_eml.html
99
a05_advanced_functionality: a05_advanced_functionality.html
10-
last_built: 2025-04-09T17:13Z
10+
last_built: 2025-04-11T22:09Z
1111
urls:
1212
reference: https://nationalparkservice.github.io/EMLeditor/reference
1313
article: https://nationalparkservice.github.io/EMLeditor/articles

docs/reference/index.html

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/sitemap.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<url><loc>https://nationalparkservice.github.io/EMLeditor/reference/get_drr_doi.html</loc></url>
2727
<url><loc>https://nationalparkservice.github.io/EMLeditor/reference/get_drr_title.html</loc></url>
2828
<url><loc>https://nationalparkservice.github.io/EMLeditor/reference/get_ds_id.html</loc></url>
29+
<url><loc>https://nationalparkservice.github.io/EMLeditor/reference/get_eml_simple.html</loc></url>
2930
<url><loc>https://nationalparkservice.github.io/EMLeditor/reference/get_end_date.html</loc></url>
3031
<url><loc>https://nationalparkservice.github.io/EMLeditor/reference/get_file_info.html</loc></url>
3132
<url><loc>https://nationalparkservice.github.io/EMLeditor/reference/get_lit.html</loc></url>

man/get_eml_simple.Rd

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-getEMLfunctions.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ BICY_EMLed_meta <- EML::read_eml(testthat::test_path("good",
88
return_val_2 <- function() {2}
99
return_val_1 <- function() {1}
1010

11+
# ---- get_eml_simple ----
12+
13+
test_that("get_eml_simple returns a simple vector of values", {
14+
simple_list <- get_eml_simple(BICY_EMLed_meta, "geographicDescription")
15+
expect_equal(simple_list, c("NPS Unit Connections: BICY", "BICY"))
16+
})
17+
1118
# ---- get_begin_date ----
1219

1320
test_that("get_begin_date gets the beginning date of EML document", {

0 commit comments

Comments
 (0)