Skip to content

Commit d22c421

Browse files
committed
paste-> glue
1 parent f16260d commit d22c421

14 files changed

Lines changed: 37 additions & 45 deletions

R/config_to_tibble.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ config_to_tibble <- function(
8686
"tag_set_map.include_min_duration" = as.numeric,
8787
"tag_set_map.extent" = \(x) list(x),
8888
"tag_set_map.known" = \(x) {
89-
paste0("data.frame(", paste(names(x), collapse = ","), ")")
89+
glue::glue("data.frame({glue::glue_collapse(names(x), sep = ',')})")
9090
},
9191
"geopressure_map.compute_known" = as.logical,
9292
"geopressure_map.max_sample" = as.numeric,
@@ -180,7 +180,7 @@ config_to_tibble <- function(
180180

181181
if (any(idx)) {
182182
cli_warn(
183-
"The following fields had length > 1 and were truncated: {paste(names(c)[idx], collapse = ', ')}"
183+
"The following fields had length > 1 and were truncated: {glue::glue_collapse(names(c)[idx], sep = ', ')}"
184184
)
185185

186186
# correction: keep only first element

R/create_geopressuretemplate.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ create_geopressuretemplate_config <- function(pkg) {
641641
if (!is.numeric(x)) {
642642
x <- glue::glue('"{x}"')
643643
}
644-
tmp <- paste0("[", paste(x, collapse = ", "), "]")
644+
tmp <- glue::glue("[{glue::glue_collapse(x, sep = ', ')}]")
645645

646646
# class(tmp) <- "verbatim" # does not work
647647
glue::glue("{tmp}{add_text}")

R/deprecations.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ zenodo_to_gldp <- function(id, ...) {
164164
when = "1.0.0",
165165
what = "zenodo_to_gldp()",
166166
with = "read_zenodo()",
167-
details = paste(
168-
"`read_zenodo()` has different behavior/arguments.",
167+
details = glue::glue(
168+
"`read_zenodo()` has different behavior/arguments. ",
169169
"Migrate your call explicitly (notably `endpoint`, `token`, and `sandbox`)."
170170
)
171171
)

R/gldp_to_eml.R

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,8 @@ gldp_to_eml <- function(pkg, directory) {
185185
}
186186
intellectual_rights <- if (length(license_names) > 0) {
187187
list(
188-
para = to_plain_text(paste(
189-
"This work is licensed under a",
190-
paste(license_names, collapse = ", "),
191-
"license."
188+
para = to_plain_text(glue::glue(
189+
"This work is licensed under a {glue::glue_collapse(license_names, sep = ', ')} license."
192190
))[1]
193191
)
194192
} else {

R/merge_gldp.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ merge_gldp <- function(x, y) {
5555
common_tags <- intersect(tags(x)$tag_id, tags(y)$tag_id)
5656
if (length(common_tags) > 0) {
5757
cli_abort(c(
58-
"Duplicate {.field tag_id} detected: {col_red(paste(common_tags, collapse = ', '))}.",
58+
"Duplicate {.field tag_id} detected: {col_red(glue::glue_collapse(common_tags, sep = ', '))}.",
5959
"x" = "Merging may fail due to duplicate tag IDs.",
6060
"i" = "Consider renaming or deleting one of the conflicting tag IDs."
6161
))
@@ -149,7 +149,7 @@ merge_gldp <- function(x, y) {
149149

150150
if (length(common_ids) > 0) {
151151
cli_abort(c(
152-
"Duplicate {.field datapackage_id} detected: {col_red(paste(common_ids, collapse = ', '))}.",
152+
"Duplicate {.field datapackage_id} detected: {col_red(glue::glue_collapse(common_ids, sep = ', '))}.",
153153
"x" = "Tags from both packages share the same datapackage_id.",
154154
"i" = "Ensure each package has distinct datapackage_id values before merging."
155155
))

R/params_to_observations.R

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ params_to_observations <- function(params) {
6262
mutate(
6363
longitude = known$known_lon[id],
6464
latitude = known$known_lat[id],
65-
observation_comments = paste0(
66-
"Automatically computed from `known$stap_id==1` ",
67-
"with `params_to_observations()`"
65+
observation_comments = glue::glue(
66+
"Automatically computed from `known$stap_id==1` with `params_to_observations()`"
6867
)
6968
)
7069
}
@@ -75,9 +74,8 @@ params_to_observations <- function(params) {
7574
mutate(
7675
longitude = known$known_lon[id],
7776
latitude = known$known_lat[id],
78-
observation_comments = paste0(
79-
"Automatically computed from `known$stap_id==-1` ",
80-
"with `params_to_observations()`"
77+
observation_comments = glue::glue(
78+
"Automatically computed from `known$stap_id==-1` with `params_to_observations()`"
8179
)
8280
)
8381
}

R/params_to_tags.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ params_to_tags <- function(params) {
115115
c(
116116
"Type mismatch when combining tags in {.code params_to_tags}:",
117117
"i" = glue::glue(
118-
"Column types: {paste(col_types, collapse = ' | ')}"
118+
"Column types: {glue::glue_collapse(col_types, sep = ' | ')}"
119119
),
120120
"x" = e$message
121121
)

R/plot.geolocatordp.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ plot_pkg_map <- function(x) {
233233
data = pid,
234234
color = color_palette(tag),
235235
weight = 2,
236-
popup = ~ paste0("Tag ID: ", tag_id, "<br>stap #", stap_id)
236+
popup = ~ glue::glue("Tag ID: {tag_id}<br>stap #{stap_id}")
237237
) |>
238238
leaflet::addCircleMarkers(
239239
lng = ~lon,
@@ -250,7 +250,7 @@ plot_pkg_map <- function(x) {
250250
(x - min_x) / (max_x - min_x) * (max_r - min_r) + min_r
251251
},
252252
fillOpacity = 0.8,
253-
popup = ~ paste0("Tag ID: ", tag_id, "<br>stap #", stap_id)
253+
popup = ~ glue::glue("Tag ID: {tag_id}<br>stap #{stap_id}")
254254
)
255255
}
256256

R/print.geolocatordp.R

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ print.geolocatordp <- function(x, ...) {
1414
# check_geolocatordp() not necessary: print only triggered for geolocatordp object
1515

1616
check_gldp(x)
17+
x <- update_gldp_order_resources(x)
1718

1819
has_value <- function(value) !is.null(value) && length(value) > 0
1920
format_creator_name <- function(name) {
@@ -58,13 +59,13 @@ print.geolocatordp <- function(x, ...) {
5859
contributors <- sapply(x_display$contributors, \(ctr) {
5960
str <- format_creator_name(ctr$title)
6061
if (has_value(ctr$email)) {
61-
str <- paste0(str, " ('", ctr$email, "')")
62+
str <- glue::glue("{str} ('{ctr$email}')")
6263
}
6364
if (has_value(ctr$roles)) {
64-
str <- paste0(str, " (", paste(ctr$roles, collapse = ", "), ")")
65+
str <- glue::glue("{str} ({glue::glue_collapse(ctr$roles, sep = ', ')})")
6566
}
6667
if (has_value(ctr$path)) {
67-
str <- paste0(str, " - {.url ", ctr$path, "}")
68+
str <- glue::glue("{str} - {{.url {ctr$path}}}")
6869
}
6970
str
7071
})
@@ -87,27 +88,27 @@ print.geolocatordp <- function(x, ...) {
8788
if (has_value(license$title)) {
8889
str <- license$title
8990
if (has_value(license$name)) {
90-
str <- paste0(str, " (", license$name, ")")
91+
str <- glue::glue("{str} ({license$name})")
9192
}
9293
} else {
9394
str <- license$name
9495
}
9596
if (has_value(license$path)) {
96-
str <- paste0(str, " - {.url ", license$path, "}")
97+
str <- glue::glue("{str} - {{.url {license$path}}}")
9798
}
9899
str
99100
})
100101
licenses <- licenses[nzchar(licenses)]
101102
if (length(licenses) > 0) {
102-
cli_bullets(c("*" = "{.field licenses}: {paste(licenses, collapse = ', ')}"))
103+
cli_bullets(c("*" = "{.field licenses}: {glue::glue_collapse(licenses, sep = ', ')}"))
103104
}
104105
}
105106

106107
if (has_value(x_display$description)) {
107108
desc <- as.character(x_display$description)[1]
108109
max_chars <- 250L
109110
if (!is.na(desc) && nchar(desc) > max_chars) {
110-
desc <- paste0(substr(desc, 1, max_chars), "...")
111+
desc <- glue::glue("{substr(desc, 1, max_chars)}...")
111112
}
112113
cli_bullets(c("*" = "{.field description}: {.val {desc}}"))
113114
}
@@ -119,9 +120,9 @@ print.geolocatordp <- function(x, ...) {
119120
toupper(ri$relatedIdentifierType %||% "") == "DOI" &&
120121
!grepl("^https?://", ri$relatedIdentifier)
121122
) {
122-
ri$relatedIdentifier <- paste0("https://doi.org/", ri$relatedIdentifier)
123+
ri$relatedIdentifier <- glue::glue("https://doi.org/{ri$relatedIdentifier}")
123124
}
124-
paste0(ri$relationType, " {.url ", ri$relatedIdentifier, "}")
125+
glue::glue("{ri$relationType} {{.url {ri$relatedIdentifier}}}")
125126
})
126127
cli_bullets(c("*" = "{.field relatedIdentifiers}:"))
127128
for (ri in ris) {

R/read_soi.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ read_soi <- function(
148148
mutate(
149149
attachment_type = {
150150
vars <- pick(everything())
151-
paste0(
151+
glue::glue_collapse(
152152
c(
153153
if ("Harness_data" %in% names(vars) && !is.na(.data$Harness_data)) {
154154
.data$Harness_data
@@ -196,7 +196,7 @@ read_soi <- function(
196196
glue::glue("BreastDiameterTail:{BreastHarnessDiameterTail}")
197197
}
198198
),
199-
collapse = "|"
199+
sep = "|"
200200
)
201201
}
202202
) |>

0 commit comments

Comments
 (0)