Skip to content

Commit bdcf072

Browse files
committed
Remove stringr dependencies, use base R function equivalents
1 parent c92c520 commit bdcf072

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

R/rocrate_report.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ rocrate_report.rocrate <- function(
196196
# split `ds.table` into `project` and `table`
197197
safe_output_tbl_v2 <- safe_output_tbl |>
198198
dplyr::mutate(
199-
project = stringr::str_extract(ds_table, "^.*(?=\\.)"),
200-
table = stringr::str_extract(ds_table, "(?<=\\.).*$")
199+
project = gsub("(?=\\.).*$", "", ds_table, perl = TRUE),
200+
table = gsub("^.*(?<=\\.)", "", ds_table, perl = TRUE)
201201
) |>
202202
dplyr::distinct(project, table, username, ds_function)
203203

R/safe-outputs.R

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ safe_output.opal <- function(
155155
if (nrow(userlogs_tbl) > 0) {
156156
userlogs <- userlogs_tbl |>
157157
glue::glue_data(
158-
"[{level}][{format(`@timestamp`, '%Y-%m-%dT%H:%M:%S')}]{stringr::str_pad(paste0('[', ds_action, ']'), 12, 'right', ' ')}{message}"
158+
"[{level}][{format(`@timestamp`, '%Y-%m-%dT%H:%M:%S')}]{sprintf('%-12s', paste0('[', ds_action, ']'))}{message}"
159159
)
160160
}
161161

@@ -207,12 +207,13 @@ safe_output.opal <- function(
207207
dplyr::mutate(
208208
# extract function name from ds_eval
209209
ds_function = ds_eval |>
210-
stringr::str_extract("^.*(?=\\()"),
210+
gsub(pattern = "(?=\\().*$", replacement = "", perl = TRUE),
211211
# extract symbol/object from ds_eval
212212
ds_symbol = ds_eval |>
213-
stringr::str_extract("(?<=\\()(.*?)(?=\\))") |>
214-
stringr::str_remove_all('"|\'') |>
215-
stringr::str_extract("[^\\$]*"),
213+
gsub(pattern = "^.*(?<=\\()", replacement = "", perl = TRUE) |>
214+
gsub(pattern = "(?=\\)).*$", replacement = "", perl = TRUE) |>
215+
gsub(pattern = '"|\'', replacement = "", perl = TRUE) |>
216+
gsub(pattern = "(?=\\$).*", replacement = "", perl = TRUE),
216217
.before = 1
217218
) |>
218219
## verify that `ds_symbol` is a mapped object (`userlogs_tbl_mappings`)

0 commit comments

Comments
 (0)