Parse and extract a module's version

moduleVersion(module, path, sim, envir = NULL)

# S4 method for class 'character,character,missing'
moduleVersion(module, path, envir)

# S4 method for class 'character,missing,missing'
moduleVersion(module, envir)

# S4 method for class 'character,missing,simList'
moduleVersion(module, sim, envir)

Arguments

module

Character string. Your module's name.

path

Character string specifying the file path to modules directory. Default is to use the spades.modulePath option.

sim

A simList simulation object, generally produced by simInit.

envir

Optional environment in which to store parsed code. This may be useful if the same file is being parsed multiple times. This function will check in that environment for the parsed file before parsing again. If the envir is transient, then this will have no effect.

Value

numeric_version indicating the module's version.

See also

Author

Alex Chubaty

Examples

# using filepath
path <- getSampleModules(tempdir())
moduleVersion("caribouMovement", path)
#> [1] ‘1.6.1’

# using simList
options("spades.useRequire" = FALSE)
if (require("SpaDES.tools", quietly = TRUE)) {
   mySim <- simInit(
      times = list(start = 2000.0, end = 2002.0, timeunit = "year"),
      params = list(
        .globals = list(stackName = "landscape", burnStats = "nPixelsBurned")
      ),
      modules = list("caribouMovement"),
      paths = list(modulePath = path)
   )
   moduleVersion("caribouMovement", sim = mySim)
}
#> Setting:
#>   options(
#>     spades.modulePath = '/tmp/Rtmp45trFG/sampleModules'
#>   )
#> Paths set to:
#>   options(
#>     rasterTmpDir = '/tmp/Rtmp45trFG/SpaDES/scratch/raster'
#>     reproducible.cachePath = '/tmp/Rtmp45trFG/reproducible/cache'
#>     spades.inputPath = '/tmp/Rtmp45trFG/SpaDES/inputs'
#>     spades.outputPath = '/tmp/Rtmp45trFG/SpaDES/outputs'
#>     spades.modulePath = '/tmp/Rtmp45trFG/sampleModules'
#>     spades.scratchPath = '/tmp/Rtmp45trFG/SpaDES/scratch'
#>   )
#>   terra::terraOptions(tempdir = '/tmp/Rtmp45trFG/SpaDES/scratch/terra'
#> Nov21 04:22:38 simInit Using setDTthreads(1). To change: 'options(spades.DTthreads = X)'.
#> Nov21 04:22:38 simInit caribouMovement: module code: landscape, caribou are declared in metadata inputObjects, but no default(s) are provided in .inputObjects
#> Nov21 04:22:38 simInit caribouMovement: module code: landscape is declared in metadata inputObjects, but is not used in the module
#> Nov21 04:22:38 simInit caribouMovement: inputObjects: Par$stackName is used from sim inside Init, but is not declared in metadata inputObjects
#> Nov21 04:22:38 simInit caribouMovement: inputObjects: Par$stackName is used from sim inside Move, but is not declared in metadata inputObjects
#> Nov21 04:22:38 simInit The following .globals were used:
#> Nov21 04:22:38 simInit Key: <global, module>
#> Nov21 04:22:38 simInit module    global
#> Nov21 04:22:38 simInit <char>    <char>
#> Nov21 04:22:38 simInit 1: caribouMovement stackName
#> Nov21 04:22:38 simInit Global parameter(s) not used in any module: burnStats.
#> Elpsed time for simInit: 0.1269269 secs
#> [1] ‘1.6.1’