From 92134cd3173f20e05c1fa6948a32375f646ef190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Sun, 27 Mar 2016 21:00:31 +0200 Subject: [PATCH 1/6] AppVeyor badge --- README.md | 2 +- readme/README.Rmd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c31ff7d..ea00876 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[rprojroot](https://krlmlr.github.io/rprojroot) [![wercker status](https://app.wercker.com/status/c4dfa136cd78514514e259cc388e880c/s/master "wercker status")](https://app.wercker.com/project/bykey/c4dfa136cd78514514e259cc388e880c) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/krlmlr/rprojroot?branch=master&type=svg)](https://ci.appveyor.com/project/krlmlr/rprojroot) [![codecov.io](https://codecov.io/github/krlmlr/rprojroot/coverage.svg?branch=master)](https://codecov.io/github/krlmlr/rprojroot?branch=master) [![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/rprojroot)](https://cran.r-project.org/package=rprojroot) +[rprojroot](https://krlmlr.github.io/rprojroot) [![wercker status](https://app.wercker.com/status/c4dfa136cd78514514e259cc388e880c/s/master "wercker status")](https://app.wercker.com/project/bykey/c4dfa136cd78514514e259cc388e880c) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/krlmlr/rprojroot?branch=master&svg=true)](https://ci.appveyor.com/project/krlmlr/rprojroot) [![codecov.io](https://codecov.io/github/krlmlr/rprojroot/coverage.svg?branch=master)](https://codecov.io/github/krlmlr/rprojroot?branch=master) [![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/rprojroot)](https://cran.r-project.org/package=rprojroot) ====================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================== This package helps accessing files relative to a *project root* to [stop the working directory insanity](https://gist.github.com/jennybc/362f52446fe1ebc4c49f). diff --git a/readme/README.Rmd b/readme/README.Rmd index 75401fa..a20d063 100644 --- a/readme/README.Rmd +++ b/readme/README.Rmd @@ -18,7 +18,7 @@ knitr::opts_chunk$set( ) ``` -[rprojroot](https://krlmlr.github.io/rprojroot) [![wercker status](https://app.wercker.com/status/c4dfa136cd78514514e259cc388e880c/s/master "wercker status")](https://app.wercker.com/project/bykey/c4dfa136cd78514514e259cc388e880c) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/krlmlr/rprojroot?branch=master&type=svg)](https://ci.appveyor.com/project/krlmlr/rprojroot) [![codecov.io](https://codecov.io/github/krlmlr/rprojroot/coverage.svg?branch=master)](https://codecov.io/github/krlmlr/rprojroot?branch=master) [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/rprojroot)](https://cran.r-project.org/package=rprojroot) +[rprojroot](https://krlmlr.github.io/rprojroot) [![wercker status](https://app.wercker.com/status/c4dfa136cd78514514e259cc388e880c/s/master "wercker status")](https://app.wercker.com/project/bykey/c4dfa136cd78514514e259cc388e880c) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/krlmlr/rprojroot?branch=master&svg=true)](https://ci.appveyor.com/project/krlmlr/rprojroot) [![codecov.io](https://codecov.io/github/krlmlr/rprojroot/coverage.svg?branch=master)](https://codecov.io/github/krlmlr/rprojroot?branch=master) [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/rprojroot)](https://cran.r-project.org/package=rprojroot) ================================================================================================================================================================================================================================================================================================================================================= This package helps accessing files relative to a *project root* to [stop the working directory insanity](https://gist.github.com/jennybc/362f52446fe1ebc4c49f). From 96204672a5114548a8fe192cbcd5be376c3bdd89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Mon, 28 Mar 2016 12:33:04 +0200 Subject: [PATCH 2/6] use normalizePath() in test for Windows compatibility --- tests/testthat/test-make.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-make.R b/tests/testthat/test-make.R index db05f8e..f990838 100644 --- a/tests/testthat/test-make.R +++ b/tests/testthat/test-make.R @@ -8,5 +8,6 @@ test_that("Shortcuts", { oldwd <- setwd("~") on.exit(setwd(oldwd)) - expect_equal(R("testthat"), oldwd) + expect_equal(normalizePath(R("testthat"), mustWork = TRUE), + normalizePath(oldwd, mustWork = TRUE)) }) From a70fea2f07daf170c7e2c861f5e2e099f8614885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Mon, 28 Mar 2016 15:09:10 +0200 Subject: [PATCH 3/6] rox_on: documentation is version-controlled --- .gitignore | 1 - DESCRIPTION | 1 - R/zzz-autoroxy.R | 21 -------------- man/criteria.Rd | 26 +++++++++++++++++ man/find_root.Rd | 41 +++++++++++++++++++++++++++ man/find_root_file.Rd | 54 +++++++++++++++++++++++++++++++++++ man/root_criterion.Rd | 65 +++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 186 insertions(+), 23 deletions(-) delete mode 100644 R/zzz-autoroxy.R create mode 100644 man/criteria.Rd create mode 100644 man/find_root.Rd create mode 100644 man/find_root_file.Rd create mode 100644 man/root_criterion.Rd diff --git a/.gitignore b/.gitignore index 5e25001..7c7994a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,3 @@ inst/doc /inst/web /vignettes/*.html -/man diff --git a/DESCRIPTION b/DESCRIPTION index b1b7a97..c56ad90 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,4 +29,3 @@ Collate: 'has-file.R' 'root.R' 'shortcut.R' - 'zzz-autoroxy.R' diff --git a/R/zzz-autoroxy.R b/R/zzz-autoroxy.R deleted file mode 100644 index d680e2e..0000000 --- a/R/zzz-autoroxy.R +++ /dev/null @@ -1,21 +0,0 @@ -# nolint start -{ - if (!"DESCRIPTION" %in% dir()) { - return(invisible(NULL)) - } - if (file.exists("man")) { - return(invisible(NULL)) - } - if (grepl("/.*[.]Rcheck/00_pkg_src/.*$", normalizePath(getwd(), - winslash = "/"))) { - stop("Cannot run this function in R CMD check.") - } - message("*** autoroxy: creating documentation") - if (!requireNamespace("roxygen2")) { - warning("Cannot load roxygen2. Package documentation will be unavailable.", - call. = FALSE) - return(invisible(NULL)) - } - roxygen2::roxygenize(roclets = c("rd")) -} -# nolint end diff --git a/man/criteria.Rd b/man/criteria.Rd new file mode 100644 index 0000000..c1a9042 --- /dev/null +++ b/man/criteria.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/has-file.R +\docType{data} +\name{criteria} +\alias{criteria} +\alias{is_r_package} +\alias{is_rstudio_project} +\title{Prespecified criteria} +\format{An object of class \code{root_criteria} of length 2.} +\usage{ +criteria + +is_rstudio_project + +is_r_package +} +\description{ +This is a collection of commonly used root criteria. +} +\details{ +\code{is_rstudio_project} looks for a file with extension \code{.Rproj}. + +\code{is_r_package} looks for a \code{DESCRIPTION} file. +} +\keyword{datasets} + diff --git a/man/find_root.Rd b/man/find_root.Rd new file mode 100644 index 0000000..6b7d3ee --- /dev/null +++ b/man/find_root.Rd @@ -0,0 +1,41 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/root.R +\name{find_root} +\alias{find_root} +\title{Find the root of a directory hierarchy} +\usage{ +find_root(criterion, path = ".") +} +\arguments{ +\item{criterion}{A criterion, will be coerced using +\code{\link{as.root_criterion}}} + +\item{path}{The start directory} +} +\value{ +The normalized path of the root as specified by the search criterion. + Throws an error if no root is found +} +\description{ +A \emph{root} is defined as a directory that contains a regular file +whose name matches a given pattern and which optionally contains a given text. +The search for a root starts at a given directory (the working directory +by default), and proceeds up the directory hierarchy. +} +\details{ +Starting from the working directory, the \code{find_root} function searches +for the root. +If a root is found, the \code{...} arguments are used to construct a path; +thus, if no extra arguments are given, the root is returned. +If no root is found, an error is thrown. +} +\examples{ +\dontrun{ +find_root(glob2rx("DESCRIPTION"), "^Package: ") +} + +} +\seealso{ +\code{\link[utils]{glob2rx}} \code{\link{file.path}} +} + diff --git a/man/find_root_file.Rd b/man/find_root_file.Rd new file mode 100644 index 0000000..ca9bf02 --- /dev/null +++ b/man/find_root_file.Rd @@ -0,0 +1,54 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/file.R, R/shortcut.R +\name{find_root_file} +\alias{find_package_root_file} +\alias{find_root_file} +\alias{find_rstudio_root_file} +\title{File paths relative to the root of a directory hierarchy} +\usage{ +find_root_file(..., criterion, path = ".") + +find_rstudio_root_file(..., path = ".") + +find_package_root_file(..., path = ".") +} +\arguments{ +\item{...}{Additional arguments passed to \code{\link{file.path}}} + +\item{criterion}{A criterion, will be coerced using +\code{\link{as.root_criterion}}} + +\item{path}{The start directory} +} +\value{ +The normalized path of the root as specified by the search criteria. + Throws an error if no root is found +} +\description{ +Append an arbitrary number of path components to the root using +\code{\link[base]{file.path}}. +} +\details{ +The \code{find_root_file} function is a simple wrapper around +\code{\link{find_root}} that +appends an arbitrary number of path components to the root using +\code{\link[base]{file.path}}. +The function \code{make_find_root_file} can be used to create shorthand functions +such as \code{find_rstudio_root_file} and \code{find_package_root_file}. +In many cases, the function \code{make_fix_root_file} is even more useful: +It creates a shorthand function that is tied to a fixed root (as opposed to +\code{make_find_root_file} which creates a function that will look for the +root every time it is called). +} +\examples{ +\dontrun{ +find_package_root_file("tests", "testthat.R") +make_find_root_file(glob2rx("DESCRIPTION"), "^Package: ") +make_fix_root_file(glob2rx("DESCRIPTION"), "^Package: ") +} + +} +\seealso{ +\code{\link{find_root}} \code{\link[utils]{glob2rx}} \code{\link[base]{file.path}} +} + diff --git a/man/root_criterion.Rd b/man/root_criterion.Rd new file mode 100644 index 0000000..123eb4f --- /dev/null +++ b/man/root_criterion.Rd @@ -0,0 +1,65 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/criterion.R, R/has-file.R +\name{root_criterion} +\alias{as.root_criterion} +\alias{as.root_criterion.character} +\alias{as.root_criterion.root_criterion} +\alias{has_file} +\alias{has_file_pattern} +\alias{is.root_criterion} +\alias{root_criterion} +\title{Is a directory the project root?} +\usage{ +root_criterion(testfun, desc) + +is.root_criterion(x) + +as.root_criterion(x) + +\method{as.root_criterion}{character}(x) + +\method{as.root_criterion}{root_criterion}(x) + +has_file(filepath, contents = NULL, n = -1L) + +has_file_pattern(pattern, contents = NULL, n = -1L) +} +\arguments{ +\item{testfun}{A function with one parameter that returns \code{TRUE} +if the directory specified by this parameter is the project root, +and \code{FALSE} otherwise} + +\item{desc}{A textual description of the test criterion} + +\item{x}{An object} + +\item{filepath}{File path (can contain directories)} + +\item{contents}{Regular expression to match the file contents} + +\item{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.} + +\item{pattern}{Regular expression to match the file name} +} +\description{ +Objects of the \code{root_criterion} class decide if a +given directory is a project root. +} +\details{ +Construct criteria using \code{root_criterion} in a very general fashion +by specifying a function with a \code{path} argument, and a description. + +The \code{as.root_criterion} function accepts objects of class +\code{root_criterion}, and character values; the latter will be +converted to criteria using \code{has_file}. + +The \code{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 \code{has_file_pattern} function constructs a criterion that checks for the +existence of a file that matches a pattern, with specific contents. +} + From 83a4cdd6de857a03fe31dd265d84956c88eca927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Mon, 28 Mar 2016 15:09:10 +0200 Subject: [PATCH 4/6] bump version to 1.0-2 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index c56ad90..08da084 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: rprojroot Title: Finding Files in Project Subdirectories -Version: 1.0-1 +Version: 1.0-2 Authors@R: person(given = "Kirill", family = "Müller", role = c("aut", "cre"), email = "krlmlr+r@mailbox.org") Description: Robust, reliable and flexible paths to files below a From d2146e619a714baed77ac73ab1c6d6bd950af5a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Mon, 28 Mar 2016 15:11:58 +0200 Subject: [PATCH 5/6] NEWS --- NEWS.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/NEWS.md b/NEWS.md index fe2b64f..2d0e675 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,15 @@ +# rprojroot 1.0-2 (2016-03-28) + +- Fix test that fails on Windows only on CRAN. + + # rprojroot 1.0-1 (2016-03-26) +- Updated NEWS. + + +# rprojroot 1.0 (2016-03-26) + Initial CRAN release. - S3 class `root_criterion`: From 5d323265017acef49099f84075ffcff9faa6ad2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Mon, 28 Mar 2016 15:13:08 +0200 Subject: [PATCH 6/6] comments --- cran-comments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cran-comments.md b/cran-comments.md index d4daef5..80967de 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -7,7 +7,7 @@ 0 errors | 0 warnings | 1 note -* 1 day since last update: Fixup release to repair NEWS file. +* 1 day since last update: Fix checks that fail on Windows. ## Reverse dependencies