import_module: Import a Module.

Description Usage Arguments Details Value Syntactic Sugars Warning See Also Examples

View source: R/import.R

Description

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.

Usage

1

Arguments

name

A string (character vector of lenght one).

A module name can contain letters, figures and some special characters, namely _, -, and /. The latter is a namespace separator.

Names containing /mock/, /mocks/, /test/, /tests/, /example/, or /examples/ have a special meaning related to code testing and examples.

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 httr::GET.

digest

A string (character vector of length one). See get_digest.

force

A flag. Should an already defined module be re-imported?

Details

R Markdown and R Sweave files are accordingly tangled into R code, which is in turn evaluated.

The imported module is rejected if

In such a case, the internal state of modulr is rolled back.

Value

The result of the evaluation of the imported script.

Syntactic Sugars

1
name %imports% url
1
name %digests% digest %imports% url

Warning

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.

See Also

httr::GET, get_digest, list_modules, make, and make_tests.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## 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()
## End(Not run)

## Not run: 
reset()
# https://gist.github.com/aclemen1/3fcc508cb40ddac6c1e3
"modulr/vault_with_a_typo" %imports% "3fcc508cb40ddac6c1e3"
list_modules()
## End(Not run)

## Not run: 
reset()
# https://gist.github.com/aclemen1/3fcc508cb40ddac6c1e3
"modulr/vault" %digests%
  "with a wrong digest" %imports%
  "3fcc508cb40ddac6c1e3"
list_modules()
## End(Not run)

openscienceunil/modulr documentation built on May 3, 2019, 5:49 p.m.