You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: NEWS.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,10 @@
3
3
* Remove `test_public_points()` function. DataStore previously made GPS coordinates public, even when data files were restricted-access, so this function was written to alert users of that fact. DataStore now applies the same access rules to GPS coordinates and data files, so this check is no longer needed.
4
4
5
5
# DPchecker 1.0.1
6
+
## 2025-04-24
7
+
* add function `test_datatable_url_attributes` to test for the appropriate attribute in the xml designation in metadata for urls.
8
+
* Added unit tests for `test_datatable_url_attributes`, `test_datatable_urls_doi`, and `test_datatable_urls`
9
+
6
10
## 2025-04-16
7
11
* remove arcticdatautils as a dependency and replace functionality with equivalent functions from EMLeditor to reduce the total number of package dependencies.
cli::cli_warn(c("!"="Metadata URL for the data table {.var {tbl_name}} is incorrectly formatted. Use {.fn EMLeditor::set_data_urls} to update the URLs."))
#' Test for the appropriate attribute for data table URLs in metadata
484
+
#'
485
+
#' @description `test_datatable_url_attributes` tests whether the 'function =' attribute for the <url> element for each data table in metadata is properly specified. If there is no attribute, the function is assumed to be a direct download (as per the EML schema). The user is warned to check that this is the case (as data packages on DataStore will typically have a direct download link to the data file). If the specified attribute is not either "information" or "download", the function will throw an error as these are the only allowable attributes. If the attribute is "download" the function will warn the user and ask them to double check this. If the attribute is "information" and does not correspond to a DataStore reference profile, the function will warn the user and ask them to check this. If the attribute is "information" and a DataStore reference profile page is supplied, the test will pass.
cli::cli_abort(c("x"="One or more data files lack URLs. Could not test whether URL attributes are properly formatted or correctly correspond to the URL. Use {.fn EMLeditor::set_data_urls} to add URLs and attributes."))
514
+
return(invisible(metadata))
515
+
}
516
+
517
+
#check for url attributes:
518
+
if (length(seq_along(url)) ==1) {
519
+
520
+
#if no attributes, warn and exit:
521
+
cli::cli_warn(c("!"="One or more of data file URLs elements in metadata lack attributes. Either use {.fn EMLeditor::set_data_urls} to add the appropriate attribute for DataStore or make sure the URL provided is a direct download link."))
522
+
return(invisible(metadata))
523
+
}
524
+
525
+
# if URL element has an attribute:
526
+
if (length(seq_along(url)) >1) {
527
+
tag<-url[[2]]
528
+
url<-url[[1]]
529
+
530
+
# error if tag is not either "information" or "download"
531
+
if (tag!="information"&tag!="download") {
532
+
cli::cli_abort(c("x"="The \"function = \" attribute in data table URLs must be either \"information\" or \"download\". Use {.fn EMLeditor::set_data_urls} to update the URL attribute."))
533
+
return(invisible(metadata))
534
+
}
535
+
536
+
# warn if attribute is download, warn
537
+
if (tag=="download") {
538
+
cli::cli_warn(c("!"="One or more data file URL attributes in metadata are set to \"download\". Please make sure this is actually a direct download link to the data file. Use {.fn EMLeditor::set_data_urls} to update this attribute."))
539
+
return(invisible(metadata))
540
+
}
541
+
542
+
# if attribute is "information" check that it is a data store profile reference; warn if it is not:
cli::cli_warn(c("!"="One or more data table URL attributes in metadata is set to \"information\" but the URL supplied is not a DataStore reference profile. Please check that the URL goes to the appropriate page and it is not a direct download link for the data file."))
550
+
return(invisible(metadata))
551
+
}
552
+
}
553
+
}
554
+
}
555
+
556
+
# if you've gotten this far with no errors, it's probably OK:
557
+
cli::cli_inform(c("v"="Metadata datatable URLs and URL attributes are properly specified."))
0 commit comments