Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ tests/testthat/.remake
^remake_.*\.tar\.gz$
^.*\.Rproj$
^\.Rproj\.user$
.DS_Store
.Rapp.history

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ docker/
TODO.md
Rplots.pdf
.Rproj.user
.DS_Store
.Rapp.history

13 changes: 7 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
Package: remake
Title: Make-like build management
Title: Make-Like Build Management
Version: 0.3.0
Authors@R: "Rich FitzJohn <rich.fitzjohn@gmail.com> [aut, cre]"
Authors@R: person(family = "FitzJohn", given = "Rich",
email = "rich.fitzjohn@gmail.com", role = c("aut", "cre"))
Description: Make-like build management in R. The idea is to have
some sort of declarative programming to build analysis pipelines,
without having to use/install make.
Depends:
Depends:
R (>= 3.0.0)
License: BSD_2_clause + file LICENSE
LazyData: true
Imports:
Imports:
R6 (>= 2.0.0),
crayon,
digest,
optparse,
storr (>= 0.5.0),
yaml
Suggests:
Suggests:
DiagrammeR,
devtools,
knitr,
testthat
RoxygenNote: 5.0.1.9000
RoxygenNote: 5.0.1
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export(delete)
export(delete_bindings)
export(diagram)
export(dump_environment)
export(example_remake)
export(fetch)
export(fetch_archive)
export(file_extensions)
Expand All @@ -18,6 +19,7 @@ export(is_archive)
export(is_current)
export(list_archive)
export(list_dependencies)
export(list_examples_remake)
export(list_targets)
export(make)
export(make_environment)
Expand Down
24 changes: 24 additions & 0 deletions R/examples.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#' @title Function \code{example_remake}
#' @description Copy a remake example to the current working directory.
#' To see the names of all the examples, run \code{\link{list_examples_remake}}.
#' @seealso \code{\link{list_examples_remake}}, \code{\link{make}}
#' @export
#' @param example name of the example. To see all the available example names,
#' run \code{\link{list_examples_remake}}.
example_remake = function(example = list_examples_remake()){
example <- match.arg(example)
dir <- system.file(file.path("examples", example), package = "remake", mustWork = TRUE)
if(file.exists(example))
stop("There is already a file or folder named ", example, ".", sep = "")
file.copy(from = dir, to = getwd(), recursive = TRUE)
invisible()
}

#' @title Function \code{list_examples_remake}
#' @description Return the names of all the remake examples.
#' @seealso \code{\link{example_remake}}, \code{\link{make}}
#' @export
#' @return a names of all the remake examples.
list_examples_remake = function(){
list.dirs(system.file("examples", package = "remake"), full.names = FALSE, recursive = FALSE)
}
1 change: 1 addition & 0 deletions inst/examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
These are the `remake` examples managed by functions `example_remake()` and `list_examples_remake()`. To add your own example, simply make a new folder in `inst/examples` and put your files inside. If you create (and hopefully populate) `inst/examples/my_example`, then, `"my_example"` will be automatically included in the output of `list_examples_remake()`, and `example_remake(example = "my_example")` will copy `inst/examples/my_example` to the current working directory of your R session.
11 changes: 11 additions & 0 deletions inst/examples/quickstart/code.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
get_data = function(){
random_numbers()
}

random_numbers = function(){
rnorm(1000) # Change 1000 to 2000 and rerun remake::make() to see what remake does.
}

produce_plot = function(data, title){
hist(data, main = title, col = "black")
}
16 changes: 16 additions & 0 deletions inst/examples/quickstart/remake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
sources: code.R
# packages: MASS

targets:
all:
depends:
plot.pdf

plot.pdf: # Change the title and rerun remake::make() to see what remake does.
command:
produce_plot(data = my_data, title = I("Plot title")) # Use I() for character arguments.
plot: TRUE

my_data:
command:
get_data()
20 changes: 20 additions & 0 deletions man/example_remake.Rd

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

18 changes: 18 additions & 0 deletions man/list_examples_remake.Rd

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

19 changes: 19 additions & 0 deletions tests/testthat/test-examples.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# library(remake); library(testthat);
context("examples")

test_that("Basic checks on functions for examples are met.", {
expect_silent(list_examples_remake())
expect_gt(length(list_examples_remake()), 0)
nonsense = "alskdjfoijpaskjdfhasdhflkajhsdfkahdfkdsjf"
expect_error(example_remake(nonsense))
})

test_that("Quickstart example runs properly.", {
example = "quickstart"
expect_silent(example_remake(example))
expect_error(example_remake(example))
setwd(example)
make(verbose = F)
setwd("..")
unlink(example, recursive = TRUE)
})