Skip to content

Commit

Permalink
Merge pull request #79 from 0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q/dev/down…
Browse files Browse the repository at this point in the history
…load_distribute_gitignore

have getfiledestinations() ignore directories from .gitignore
  • Loading branch information
0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q authored Dec 4, 2023
2 parents e86294b + e528b75 commit 9a604ba
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '5511520'
ValidationKey: '5711550'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'gms: ''GAMS'' Modularization Support Package'
version: 0.28.0
date-released: '2023-11-23'
version: 0.29.0
date-released: '2023-12-04'
abstract: A collection of tools to create, use and maintain modularized model code
written in the modeling language 'GAMS' (<https://www.gams.com/>). Out-of-the-box
'GAMS' does not come with support for modularized model code. This package provides
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: gms
Type: Package
Title: 'GAMS' Modularization Support Package
Version: 0.28.0
Date: 2023-11-23
Version: 0.29.0
Date: 2023-12-04
Authors@R: c(person("Jan Philipp", "Dietrich", email = "[email protected]", role = c("aut","cre")),
person("David", "Klein", role = "aut"),
person("Anastasis", "Giannousakis", role = "aut"),
Expand Down
28 changes: 25 additions & 3 deletions R/getfiledestinations.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
#' getfiledestinations
#'
#' Create file2destination mapping based on information from the model
#' Create file2destination mapping based on information from the model, ignoring
#' top-level directories listed in `.gitignore`.
#'
#' @md
#'
#' @author Jan Philipp Dietrich, David Klein


getfiledestinations <- function() {
folders <- base::list.dirs(recursive = FALSE, full.names = FALSE)
folders <- grep("^(\\.|225|output|calib_run|figure)", folders, invert = TRUE, value = TRUE)

if (0 == file.access(".gitignore", mode = 4)) {
ignores <- grep("/[:space:]*$", # directories end on "/"
sub("(^|[^\\\\])#.*$", "\\1", # strip comments
readLines(".gitignore")),
value = TRUE)
ignores <- basename(ignores)[dirname(ignores) %in% c(".", "/")]

# turn globs into regex patterns
globs <- grep("\\*", ignores, value = TRUE)
globs <- gsub("([.|()\\^{}+$*?]|\\[|\\])", "\\\\\\1", globs)
globs <- gsub("\\\\\\*", ".*", globs)

ignores <- c(gsub("([.|()\\^{}+$*?]|\\[|\\])", "\\\\\\1",
grep("\\*", ignores, value = TRUE, invert = TRUE)),
globs)
} else {
ignores <- character()
}

folders <- grep(paste0("^(\\.|(", paste(ignores, collapse = "|"), ")$)"),
folders, value = TRUE, invert = TRUE)
files <- NULL
for (f in folders) files <- c(files, dir(path = f, pattern = "^files$", recursive = TRUE, full.names = TRUE))
out <- NULL
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 'GAMS' Modularization Support Package

R package **gms**, version **0.28.0**
R package **gms**, version **0.29.0**

[![CRAN status](https://www.r-pkg.org/badges/version/gms)](https://cran.r-project.org/package=gms) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4390032.svg)](https://doi.org/10.5281/zenodo.4390032) [![R build status](https://github.com/pik-piam/gms/workflows/check/badge.svg)](https://github.com/pik-piam/gms/actions) [![codecov](https://codecov.io/gh/pik-piam/gms/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/gms) [![r-universe](https://pik-piam.r-universe.dev/badges/gms)](https://pik-piam.r-universe.dev/builds)

Expand Down Expand Up @@ -43,7 +43,7 @@ In case of questions / problems please contact Jan Philipp Dietrich <dietrich@pi

To cite package **gms** in publications use:

Dietrich J, Klein D, Giannousakis A, Beier F, Koch J, Baumstark L, Pflüger M, Richters O (2023). _gms: 'GAMS' Modularization Support Package_. doi: 10.5281/zenodo.4390032 (URL: https://doi.org/10.5281/zenodo.4390032), R package version 0.28.0, <URL: https://github.com/pik-piam/gms>.
Dietrich J, Klein D, Giannousakis A, Beier F, Koch J, Baumstark L, Pflüger M, Richters O (2023). _gms: 'GAMS' Modularization Support Package_. doi:10.5281/zenodo.4390032 <https://doi.org/10.5281/zenodo.4390032>, R package version 0.29.0, <https://github.com/pik-piam/gms>.

A BibTeX entry for LaTeX users is

Expand All @@ -52,7 +52,7 @@ A BibTeX entry for LaTeX users is
title = {gms: 'GAMS' Modularization Support Package},
author = {Jan Philipp Dietrich and David Klein and Anastasis Giannousakis and Felicitas Beier and Johannes Koch and Lavinia Baumstark and Mika Pflüger and Oliver Richters},
year = {2023},
note = {R package version 0.28.0},
note = {R package version 0.29.0},
doi = {10.5281/zenodo.4390032},
url = {https://github.com/pik-piam/gms},
}
Expand Down

0 comments on commit 9a604ba

Please sign in to comment.