Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix modification tracking on virtual resources #40

Merged
merged 1 commit into from
Jan 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.3.0.5.9000

* Started development version and fixed issue with modification
tracking on virtual resources.

## 0.3.0.5

* Fix an issue where sourcing a virtual resource with a preprocessor
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Description: Director is responsible for managing and loading resources in
consecutive loads of resources (so that we can tell if a script was modified
since we last ran it) and defining parsers that allow us to generalize from
the pernicious simple linear execution that is common to R.
Version: 0.3.0.5
Version: 0.3.0.5.9000
Authors@R: c(person("Robert", "Krzyzanowski",
email = "technoguyrob@gmail.com", role = c("aut", "cre")))
Depends:
Expand Down
12 changes: 9 additions & 3 deletions R/resource-modification_tracker.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,16 @@ modification_tracker <- function(object, ..., modification_tracker.return = "obj
## We injected `virtual` in the previous layer, `virtual_checker`, using
## `object$injects %<<% list(virtual = virtual)`
if (isTRUE(object$injects$virtual)) {
## Virtual resources are always considered to be modified, since we have
## Virtual resources are never considered to be modified, since we have
## have no corresponding file and we have no way to tell.
object$injects %<<% list(modified = TRUE)
yield()
if (identical(modification_tracker.return, "modified")) {
FALSE
} else if (identical(modification_tracker.return, "mtime")) {
NULL
} else {
object$injects %<<% list(modified = FALSE)
yield()
}
} else {
## In order to keep track of whether the resource has been modified,
## we will need to store the previous and current modification time
Expand Down
3 changes: 2 additions & 1 deletion R/resource-parser.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ apply_parser <- function(active_resource, route, args) {
environment(parser_function)

environment(parser_function) <-
new.env(parent = sourcing_env) %<<% list(
new.env(parent = sourcing_env) %<<%
active_resource$injects %<<% list(
# TODO: (RK) Intersect with parser formals.
# TODO: (RK) Use alist so these aren't evaluated right away.
resource = active_resource$resource$name,
Expand Down