rprojroot (version 0.1)

root_criterion: Is a directory the project root?

Description

Objects of the root_criterion class decide if a given directory is a project root.

Usage

root_criterion(testfun, desc)
is.root_criterion(x)
as.root_criterion(x)
"as.root_criterion"(x)
"as.root_criterion"(x)
has_file(filepath, contents = NULL, n = -1L)
has_file_pattern(pattern, contents = NULL, n = -1L)

Arguments

testfun
A function with one parameter that returns TRUE if the directory specified by this parameter is the project root, and FALSE otherwise
desc
A textual description of the test criterion
x
An object
filepath
File path (can contain directories)
contents
Regular expression to match the file contents
n
integer. The (maximal) number of lines to read. Negative values indicate that one should read up to the end of input on the connection.
pattern
Regular expression to match the file name

Details

Construct criteria using root_criterion in a very general fashion by specifying a function with a path argument, and a description.

The as.root_criterion function accepts objects of class root_criterion, and character values; the latter will be converted to criteria using has_file.

The has_file function constructs a criterion that checks for the existence of a specific file (which itself can be in a subdirectory of the root) with specific contents.

The has_file_pattern function constructs a criterion that checks for the existence of a file that matches a pattern, with specific contents.