From dc28b2d507a15977b880d7926629027823e31620 Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Tue, 26 May 2020 15:23:22 -0400 Subject: [PATCH 1/4] init dev branch --- DESCRIPTION | 2 +- NEWS.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7c454381..7d05c1f2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: pepr Type: Package Title: Reading Portable Encapsulated Projects -Version: 0.3.0 +Version: 0.3.1 Date: 2020-05-26 Authors@R: c(person("Nathan", "Sheffield", email = "nathan@code.databio.org", role = c("aut", "cph")),person("Michal","Stolarczyk",email="michal@virginia.edu",role=c("aut","cre"))) diff --git a/NEWS.md b/NEWS.md index 9fd6dd34..c30eef0c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# pepr 0.3.1 - 2020-05-26 + +## Fixed + # pepr 0.3.0 - 2020-05-26 **This version introduced backwards-incompatible changes.** From aba6bef83e47b0c66ca4926076b62e4191caaab4 Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Tue, 26 May 2020 15:24:24 -0400 Subject: [PATCH 2/4] potential Windows fixes --- .gitignore | 2 ++ R/config.R | 2 +- R/utils.R | 3 +-- tests/testthat/test_config.R | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index e9f0c131..cdceb4fd 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ pepr.Rproj docs doc Meta +pepr.Rcheck/ +pepr_*.tar.gz \ No newline at end of file diff --git a/R/config.R b/R/config.R index e05872f5..641458ae 100644 --- a/R/config.R +++ b/R/config.R @@ -186,7 +186,7 @@ setMethod( signature = "Config", definition = function(object) { if (CFG_VERSION_KEY %in% names(object)){ - split = str_split(object[[CFG_VERSION_KEY]],"\\.")[[1]] + split = strsplit(object[[CFG_VERSION_KEY]],"[.]")[[1]] if (length(split) < 3) stop("PEP version string is not tripartite") majorVer = as.numeric(split[1]) if (majorVer < 2){ diff --git a/R/utils.R b/R/utils.R index 254cebf4..d52db68b 100644 --- a/R/utils.R +++ b/R/utils.R @@ -151,8 +151,7 @@ #' @return Flag indicating whether the \code{path} appears to be absolute. .isAbsolute = function(path) { if (!is.character(path)) stop("The path must be character") - firstChar = substr(path, 1, 1) - return(identical("/", firstChar) | identical("~", firstChar)) + return(grepl("^(/|[A-Za-z]:|\\\\|~)", path)) } .safeFileExists = function(path) { diff --git a/tests/testthat/test_config.R b/tests/testthat/test_config.R index ded13323..5121e859 100644 --- a/tests/testthat/test_config.R +++ b/tests/testthat/test_config.R @@ -83,7 +83,7 @@ test_that("loadConfig returns correct object type", { test_that("loadConfig throws errors", { expect_error(Config("a")) - expect_error(Config(filename = Project(cfg)@config$sample_table)) + expect_error(Config(Project(cfg)@config$sample_table)) }) test_that("paths are automatically expanded", { From f067440b6f810d7cfdbe116048de4819aa84f793 Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Tue, 26 May 2020 15:36:24 -0400 Subject: [PATCH 3/4] normalize parent path before object creation --- R/project.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/project.R b/R/project.R index 5f889725..2624c7d4 100644 --- a/R/project.R +++ b/R/project.R @@ -23,7 +23,7 @@ setMethod("initialize", "Project", function(.Object, ...) { ellipsis <- list(...) if (!is.null(ellipsis$file)) { # check if file path provided - .Object@file = .makeAbsPath(ellipsis$file, parent = getwd()) + .Object@file = .makeAbsPath(ellipsis$file, parent = normalizePath(getwd())) # instantiate config object and stick it in the config slot .Object@config = Config(ellipsis$file, ellipsis$amendments) .Object = .loadSampleAnnotation(.Object) From 45c9f7fcadf64a5484bf62db83e36919e75a8c08 Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Wed, 27 May 2020 10:57:50 -0400 Subject: [PATCH 4/4] further Windows fixes --- R/config.R | 2 +- R/project.R | 2 +- R/utils.R | 8 ++++---- tests/testthat/test_config.R | 3 +-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/R/config.R b/R/config.R index 641458ae..aacd6f38 100644 --- a/R/config.R +++ b/R/config.R @@ -352,5 +352,5 @@ setMethod( #' @return string project name .inferProjectName = function(cfg, filename){ if (!is.null(cfg$name)) return(cfg$name) - return(basename(dirname(normalizePath(filename)))) + return(basename(dirname(path.expand(filename)))) } \ No newline at end of file diff --git a/R/project.R b/R/project.R index 2624c7d4..9e613e0e 100644 --- a/R/project.R +++ b/R/project.R @@ -23,7 +23,7 @@ setMethod("initialize", "Project", function(.Object, ...) { ellipsis <- list(...) if (!is.null(ellipsis$file)) { # check if file path provided - .Object@file = .makeAbsPath(ellipsis$file, parent = normalizePath(getwd())) + .Object@file = .makeAbsPath(ellipsis$file, parent = path.expand(getwd())) # instantiate config object and stick it in the config slot .Object@config = Config(ellipsis$file, ellipsis$amendments) .Object = .loadSampleAnnotation(.Object) diff --git a/R/utils.R b/R/utils.R index d52db68b..e40ba894 100644 --- a/R/utils.R +++ b/R/utils.R @@ -47,9 +47,9 @@ if (!startsWith(path, "/") && length(undefinedID) == 0) { path = paste0("/", path) } - # prevent double slashes - path = gsub("//", "/", path) } + # prevent double slashes + path = gsub("//", "/", path) } # handle null/empty input. @@ -58,7 +58,7 @@ } # if it's a path, make it absolute - path = normalizePath(path.expand(path),mustWork = FALSE) + path = path.expand(path) # search for env vars, both bracketed and not matchesBracket = gregexpr("\\$\\{\\w+\\}", path, perl=T) matches = gregexpr("\\$\\w+", path, perl=T) @@ -131,7 +131,7 @@ if (.isAbsolute(perhapsRelative)) { abspath = perhapsRelative } else { - abspath = file.path(normalizePath(parent), perhapsRelative) + abspath = file.path(path.expand(parent), perhapsRelative) } if (!.isAbsolute(abspath)) stop("Relative path ", perhapsRelative, " and parent ", parent , diff --git a/tests/testthat/test_config.R b/tests/testthat/test_config.R index 5121e859..e3fc816d 100644 --- a/tests/testthat/test_config.R +++ b/tests/testthat/test_config.R @@ -53,8 +53,7 @@ configConst = system.file( .isAbsolute = function(path) { if (!is.character(path)) stop("The path must be character") - firstChar = substr(path, 1, 1) - return(identical("/", firstChar) | identical("~", firstChar)) + return(grepl("^(/|[A-Za-z]:|\\\\|~)", path)) } # tests -------------------------------------------------------------------