Import or re-import a module which is defined in an R, R Markdown or R Sweave script at a given URL using the HTTP(S) protocol.
import_module(name, url, ..., digest = NULL, force = FALSE)
name | A string (character vector of lenght one). A module name can contain letters, figures and some special characters,
namely Names containing The name "modulr" corresponds to a special module and is therefore reserved. |
---|---|
url | A string (character vector of length one). The URL must use the HTTP(S) protocol. |
... | Further arguments passed to |
digest | A string (character vector of length one). See
|
force | A flag. Should an already defined module be re-imported? |
The result of the evaluation of the imported script.
R Markdown and R Sweave files are accordingly tangled into R code, which is in turn evaluated.
The imported module is rejected if
its name differs from the name
argument,
its digest differs from the digest
argument.
In such a case, the internal state of modulr is rolled back.
name %imports% url
name %digests% digest %imports% url
It is considered a very bad practice to define, touch, undefine, load, make, reset, or perform any other operation from within a module definition that may alterate the internal state of modulr.
httr::GET
, get_digest
,
list_modules
, make
, and
make_tests
.
not_run({ reset() # https://gist.github.com/aclemen1/3fcc508cb40ddac6c1e3 "modulr/vault" %imports% "https://gist.github.com/aclemen1/3fcc508cb40ddac6c1e3" list_modules() reset() # equivalently "modulr/vault" %imports% "3fcc508cb40ddac6c1e3" make("modulr/vault/example") make_tests() }) not_run({ reset() # https://gist.github.com/aclemen1/3fcc508cb40ddac6c1e3 "modulr/vault_with_a_typo" %imports% "3fcc508cb40ddac6c1e3" list_modules() }) not_run({ reset() # https://gist.github.com/aclemen1/3fcc508cb40ddac6c1e3 "modulr/vault" %digests% "with a wrong digest" %imports% "3fcc508cb40ddac6c1e3" list_modules() })