Skip to content

Commit

Permalink
Merge 45c9f7f into b69fec8
Browse files Browse the repository at this point in the history
  • Loading branch information
stolarczyk committed May 27, 2020
2 parents b69fec8 + 45c9f7f commit b8a9512
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ pepr.Rproj
docs
doc
Meta
pepr.Rcheck/
pepr_*.tar.gz
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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")))
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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.**
Expand Down
4 changes: 2 additions & 2 deletions R/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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))))
}
2 changes: 1 addition & 1 deletion R/project.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 = path.expand(getwd()))
# instantiate config object and stick it in the config slot
.Object@config = Config(ellipsis$file, ellipsis$amendments)
.Object = .loadSampleAnnotation(.Object)
Expand Down
11 changes: 5 additions & 6 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down Expand Up @@ -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 ,
Expand All @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions tests/testthat/test_config.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 -------------------------------------------------------------------
Expand Down Expand Up @@ -83,7 +82,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", {
Expand Down

0 comments on commit b8a9512

Please sign in to comment.