README.md

Build Status Coverage status CRAN_Status_Badge CRAN License Twitter

Modulr: A Dependency Injection Framework for R

Modulr is a Dependency Injection (DI) framework for R which allows to break down sequential programs into discrete, modular units that are loosely coupled, simple to develop, test, debug, maintain, reuse, and share.

Please read the documentation and vignettes (browseVignettes(package = "modulr")) to see extended examples in action.

"Hello, world!"

library(modulr)

"foo" %provides% "Hello"
#> [2017-06-21T21:58:16 UTC] Defining 'foo' ... OK

"bar" %provides% "World"
#> [2017-06-21T21:58:16 UTC] Defining 'bar' ... OK

"foobar" %requires% list(
  f = "foo", 
  b = "bar"
) %provides% {
  paste0(f, ", ", tolower(b), "!")
}
#> [2017-06-21T21:58:16 UTC] Defining 'foobar' ... OK

make("foobar")
#> [2017-06-21T21:58:16 UTC] Making 'foobar' ...
#> [2017-06-21T21:58:16 UTC] * Visiting and defining dependencies ...
#> [2017-06-21T21:58:16 UTC] * Constructing dependency graph ... OK
#> [2017-06-21T21:58:16 UTC] * Sorting 2 dependencies with 2 relations ... on 1 layer, OK
#> [2017-06-21T21:58:16 UTC] * Evaluating new and outdated dependencies ...
#> [2017-06-21T21:58:16 UTC] ** Evaluating #1/2 (layer #1/1): 'bar' ...
#> [2017-06-21T21:58:16 UTC] ** Evaluating #2/2 (layer #1/1): 'foo' ...
#> [2017-06-21T21:58:16 UTC] DONE ('foobar' in 0.044 secs)
#> [1] "Hello, world!"

Further readings

Installation

install.packages("devtools")
devtools::install_github("hadley/devtools")
devtools::install_github("aclemen1/modulr")

If you encounter a clear bug, please file a minimal reproducible example. For questions and other discussion, please use the modulr mailing list.

Real-world applications

  This is the dependency graph of a module (on the rightmost side) which exposes tidy, exhaustive, statistics-ready, and daily HR data for the University of Lausanne, Switzerland. Although not visible here, many of these modules are reused in other projects. The University of Lausanne has been running modulr in mission critical applications since March 2015.

Related approaches

In alphabetical order.

Code of conduct

In order to have a more open and welcoming community, modulr adheres to a Contributor Code of Conduct. Please adhere to this code of conduct in any interactions you have in the modulr community. It is strictly enforced on all official modulr repositories, websites, and resources. If you encounter someone violating these terms, please let the maintainer know and he will address it as soon as possible.



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