Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix in manipulateConfig #89

Merged
merged 1 commit into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '4240422'
ValidationKey: '4259969'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
Expand Down
2 changes: 1 addition & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "lucode2: Code Manipulation and Analysis Tools",
"version": "0.22.2",
"version": "0.22.3",
"description": "<p>A collection of tools which allow to manipulate and analyze code.<\/p>",
"creators": [
{
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: lucode2
Type: Package
Title: Code Manipulation and Analysis Tools
Version: 0.22.2
Date: 2022-04-19
Version: 0.22.3
Date: 2022-04-21
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
3 changes: 2 additions & 1 deletion R/manipulateConfig.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ manipulateConfig <- function(configFile, ...) {
m[[paste(i, "_pattern1", sep = "")]][2] <- paste(
"\\1 ", rpl, "\\2", sep = "")
m[[paste(i, "_pattern2", sep = "")]][1] <- paste(
"((\\n|^)[\\t ]*(scalar|parameter|set|)s?[\\t ]*", i, "(|\\([^\\)]*\\))[\\t ][^/;]*/)[^/]*", sep = "")
"((\\n|^)[\\t ]*(scalar|parameter|set|)s?[\\t ]*", i, "(|\\([^\\)]*\\))[\\t ]*(\"[^\"]*\"|)[^\"/;]*/)[^/]*",
sep = "")
m[[paste(i, "_pattern2", sep = "")]][2] <- paste(
"\\1 ", rpl, " ", sep = "")
m[[paste(i, "_pattern3", sep = "")]][1] <- paste(
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Code Manipulation and Analysis Tools

R package **lucode2**, version **0.22.2**
R package **lucode2**, version **0.22.3**

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

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

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

Dietrich J, Klein D, Giannousakis A, Bonsch M, Bodirsky B, Baumstark L, Führlich P (2022). _lucode2: Code Manipulation and Analysis Tools_. doi: 10.5281/zenodo.4389418 (URL: https://doi.org/10.5281/zenodo.4389418), R package version 0.22.2, <URL: https://github.com/pik-piam/lucode2>.
Dietrich J, Klein D, Giannousakis A, Bonsch M, Bodirsky B, Baumstark L, Führlich P (2022). _lucode2: Code Manipulation and Analysis Tools_. doi: 10.5281/zenodo.4389418 (URL: https://doi.org/10.5281/zenodo.4389418), R package version 0.22.3, <URL: https://github.com/pik-piam/lucode2>.

A BibTeX entry for LaTeX users is

Expand All @@ -47,7 +47,7 @@ A BibTeX entry for LaTeX users is
title = {lucode2: Code Manipulation and Analysis Tools},
author = {Jan Philipp Dietrich and David Klein and Anastasis Giannousakis and Markus Bonsch and Benjamin Leon Bodirsky and Lavinia Baumstark and Pascal Führlich},
year = {2022},
note = {R package version 0.22.2},
note = {R package version 0.22.3},
doi = {10.5281/zenodo.4389418},
url = {https://github.com/pik-piam/lucode2},
}
Expand Down
29 changes: 29 additions & 0 deletions tests/testthat/test-manipulateConfig.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

test_that("manipulateConfig works", {
withr::with_tempdir({
configFile <- "test.gms"

cfg <- list(foo = 0,
bar = 0,
buzz = 0,
bazz = 0)

code <- function(cfg) {
x <- c("scalars",
paste0(" foo blah / ", cfg$foo, " /"),
' bar "either x/y or X/Y"',
' bazz "just x/y"',
paste0(' buzz "not x/y" / ', cfg$buzz, " /"),
";",
paste0("bar = ", cfg$bar, ";"),
paste0("bazz = ", cfg$bazz, ";"),
paste0("buzz = ", cfg$buzz, ";"))
return(x)
}

writeLines(code(cfg), configFile)
cfg[seq_along(cfg)] <- seq_along(cfg)
manipulateConfig(configFile, cfg)
expect_identical(readLines(configFile), code(cfg))
})
})