Skip to content

Commit

Permalink
Merge pull request #304 from metrumresearchgroup/release/0.5.2
Browse files Browse the repository at this point in the history
Prepare 0.5.2 release
  • Loading branch information
kyleam authored Dec 14, 2022
2 parents 7c1c692 + bb58350 commit 4f21317
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: pmtables
Type: Package
Title: Tables for Pharmacometrics
Version: 0.5.1
Version: 0.5.2
Authors@R:
c(
person(given = "Kyle",
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# pmtables 0.5.2

- pmtables has been updated to be compatible with stringr 1.5.0, which
changed the classes of pattern modifiers (#302).

# pmtables 0.5.1

- New function `st_filter()` to filter data item in a pipeline (#298).
Expand Down
5 changes: 4 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ is_regex <- function(x) {

is_str_regex <- function(x) {
if(!is.character(x)) return(FALSE)
is_regex(x) || (inherits(x, "fixed") && inherits(x, "pattern"))
is_regex(x) ||
(inherits(x, "stringr_fixed") && inherits(x, "stringr_pattern")) ||
# stringr < v1.5.0
(inherits(x, "fixed") && inherits(x, "pattern"))
}

as_str_regex <- function(x) {
Expand Down
9 changes: 7 additions & 2 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ test_that("check if regular expression is valid [PMT-TEST-0243]", {
expect_false(pmtables:::is_regex("\\textbf{foo}"))
expect_true(pmtables:::is_str_regex(fixed("\\textbf{foo}")))
x <- pmtables:::as_str_regex("\\textbf{foo}")
expect_is(x, "fixed")
expected <- if (utils::packageVersion("stringr") >= "1.5.0") {
"stringr_fixed"
} else {
"fixed"
}
expect_is(x, expected)
x <- pmtables:::as_str_regex(NULL)
expect_is(x, "fixed")
expect_is(x, expected)
expect_match(x, "invalid-regex-")
})

Expand Down

0 comments on commit 4f21317

Please sign in to comment.