diff --git a/.travis.yml b/.travis.yml index a4c91ba..aee4c81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/DESCRIPTION b/DESCRIPTION index 67fdc2e..1cddca5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 diff --git a/R/attributes.R b/R/attributes.R index 8042a40..fed08e6 100644 --- a/R/attributes.R +++ b/R/attributes.R @@ -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) diff --git a/R/environment.R b/R/environment.R index 8ff1c12..66c32aa 100644 --- a/R/environment.R +++ b/R/environment.R @@ -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() diff --git a/R/util.R b/R/util.R index eaa5001..2ef7984 100644 --- a/R/util.R +++ b/R/util.R @@ -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)