Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ r:
- oldrel
- release
- devel
r_packages: ncdf4
sudo: false
cache: packages
addons:
apt:
update: true
packages:
- librdf0-dev
- libnetcdf-dev
- r-cran-ncdf4
- netcdf-bin
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ Depends:
R (>= 3.2.3)
Imports:
digest,
dplyr,
dataone,
datapack,
EML,
httr,
methods,
ncdf4,
stringr,
stringi,
tools,
uuid,
yaml,
xml2,
XML
License: MIT + file LICENSE
LazyData: true
Suggests:
dplyr,
testthat,
humaniformat,
knitr,
ncdf4,
rmarkdown,
yaml,
xslt
RoxygenNote: 6.0.1
VignetteBuilder: knitr
6 changes: 6 additions & 0 deletions R/attributes.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
get_ncdf4_attributes <- function(nc) {
stopifnot(is(nc, "ncdf4") || file.exists(nc))

if (!requireNamespace("ncdf4")) {
stop(call. = FALSE,
"The package 'ncdf4' must be installed to run this function. ",
"Please install it and try again.")
}

# Read the file in if `nc` is a character vector
if (is.character(nc)) {
nc <- ncdf4::nc_open(nc)
Expand Down
11 changes: 10 additions & 1 deletion R/editing.R
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ update_object <- function(mn, pid, path, format_id=NULL, new_pid=NULL, sid=NULL)
#' @param parent_data_pids (character) Optional. Identifier for the data objects of the parent package. Not optional if the parent package contains data objects.
#' @param parent_child_pids (character) Optional. Resource map identifier(s) of child packages in the parent package. \code{resource_map_pid} should not be included. Not optional if the parent package contains other child packages.
#' @param child_pids (character) Optional. Child packages resource map PIDs.
#' @param metadata_path (character) Optional. Path to a metadata file to update with. If this is not set, the existing metadata document will be used.
#' @param metadata_path (character or eml) Optional. An eml class object or a path to a metadata file to update with. If this is not set, the existing metadata document will be used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can/should this arg name get changed now that it's not just a path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to change the name so that it could remain backwards-compatible. But if our preference is to make it friendlier for new users, then a name change makes sense

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's probably more important.

#' @param public (logical) Optional. Make the update public. If FALSE, will set the metadata and resource map to private (but not the data objects).
#' This applies to the new metadata PID and its resource map and data object.
#' access policies are not affected.
Expand Down Expand Up @@ -367,6 +367,15 @@ publish_update <- function(mn,
# Get the metadata doc
message("Getting metadata from the MN.")
eml <- EML::read_eml(rawToChar(dataone::getObject(mn, metadata_pid)), asText = TRUE)
Copy link
Contributor

@maier-m maier-m May 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to close this if statement correct? or better use else if

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking into it.


} else if(class(metadata_path) == "eml") {
# If an eml object is provided, use it directly after validating
if(!eml_validate(metadata_path)){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isteves Maybe move this out of the call here so that eml always gets validated wether or not is an R object or from disk. Also maybe add a message so users know that eml is being validated in case it takes a non-trivial amount of time.

stop("The EML object is not valid.")
}

eml <- metadata_path

} else {
# Alternatively, read an edited metadata file from disk if provided
if (!file.exists(metadata_path)) {
Expand Down
6 changes: 6 additions & 0 deletions R/environment.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ env_get <- function() {
#'
#'
env_load <- function(name=NULL, path=NULL, skip_mn=FALSE) {
if (!requireNamespace("yaml")) {
stop(call. = FALSE,
"The package 'yaml' must be installed to run this function. ",
"Please install it and try again.")
}

# Determine the environment to load
if (is.null(name)) {
name <- env_get()
Expand Down
6 changes: 6 additions & 0 deletions R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ get_netcdf_format_id <- function(path) {
nchar(path) > 0,
file.exists(path))

if (!requireNamespace("ncdf4")) {
stop(call. = FALSE,
"The package 'ncdf4' must be installed to run this function. ",
"Please install it and try again.")
}

# Try to open the file, capturing errors
cdf_file <- try({
ncdf4::nc_open(path)
Expand Down
2 changes: 1 addition & 1 deletion man/publish_update.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.