Skip to content

Commit

Permalink
downloadModule with missing args (fix #309)
Browse files Browse the repository at this point in the history
- improved use of `downloadModule` by checking for missing args internally using a single method instead of separate methods for all combinations of missing args

- bump dev vers to 9034
  • Loading branch information
achubaty committed Oct 4, 2016
1 parent 1182c86 commit a648cc3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 53 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Expand Up @@ -11,7 +11,7 @@ Description: Implement a variety of event-based models, with a focus on
installed with `install.packages("fastshp", repos = "http://rforge.net",
type = "source")`.
URL: http://spades.predictiveecology.org, https://github.com/PredictiveEcology/SpaDES
Version: 1.2.0.9033
Version: 1.2.0.9034
Date: 2016-10-04
Authors@R: c(
person(c("Alex", "M"), "Chubaty", email="alexander.chubaty@canada.ca",
Expand Down
53 changes: 16 additions & 37 deletions R/module-repository.R
Expand Up @@ -151,8 +151,7 @@ setMethod("checkModule",
#'
#' @author Alex Chubaty
#'
setGeneric("downloadModule", function(name, path, version, repo, data = FALSE,
quiet = FALSE) {
setGeneric("downloadModule", function(name, path, version, repo, data, quiet) {
standardGeneric("downloadModule")
})

Expand Down Expand Up @@ -205,52 +204,32 @@ setMethod(
#' @rdname downloadModule
setMethod(
"downloadModule",
signature = c(name = "character", path = "missing", version = "ANY",
repo = "ANY", data = "ANY", quiet = "ANY"),
definition = function(name, version, data, quiet) {
signature = c(name = "character", path = "missing", version = "missing",
repo = "missing", data = "missing", quiet = "missing"),
definition = function(name) {
files <- downloadModule(name, path = getOption("spades.modulesPath"),
version, repo = getOption("spades.modulesRepo"),
data = data, quiet = quiet)
return(invisible(files))
})

#' @rdname downloadModule
setMethod(
"downloadModule",
signature = c(name = "character", path = "character", version = "missing",
repo = "missing", data = "ANY", quiet = "ANY"),
definition = function(name, path, data, quiet) {
files <- downloadModule(name, path, version = NA_character_,
repo = getOption("spades.modulesRepo"),
data = data,
quiet = quiet)
version = NA_character_,
repo = getOption('spades.modulesRepo'),
data = FALSE, quiet = FALSE)
return(invisible(files))
})

#' @rdname downloadModule
setMethod(
"downloadModule",
signature = c(name = "character", path = "character", version = "character",
repo = "missing", data = "ANY", quiet = "ANY"),
definition = function(name, path, version, data, quiet) {
files <- downloadModule(name, path, version,
repo = getOption("spades.modulesRepo"),
data = data, quiet = quiet)
return(invisible(files))
})
signature = c(name = "character", path = "ANY", version = "ANY",
repo = "ANY", data = "ANY", quiet = "ANY"),
definition = function(name, path, version, repo, data, quiet) {
if (missing(path)) path <- getOption("spades.modulesPath")
if (missing(version)) version <- NA_character_
if (missing(repo)) repo <- getOption("spades.modulesRepo")
if (missing(data)) data <- FALSE
if (missing(quiet)) quiet <- FALSE

#' @rdname downloadModule
setMethod(
"downloadModule",
signature = c(name = "character", path = "character", version = "missing",
repo = "character", data = "ANY", quiet = "ANY"),
definition = function(name, path, repo, data, quiet) {
files <- downloadModule(name, path, version = NA_character_, repo = repo,
data = data, quiet)
files <- downloadModule(name, path, version, repo, data, quiet)
return(invisible(files))
})


################################################################################
#' Download module data
#'
Expand Down
22 changes: 7 additions & 15 deletions man/downloadModule.Rd

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

0 comments on commit a648cc3

Please sign in to comment.