Skip to content
Merged

Dev #55

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
10 changes: 5 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Package: Stringendo
Title: Stringendo - string manipulation utilities
Version: 1.2.5
Authors@R:
Authors@R:
person("Abel", "Vertesy", , "av@imba.oeaw.ac.at", role = c("aut", "cre"))
Description: Stringendo is a set of R functions to parse strings from
variables and to manipulate strings.
License: GPL-3 + file LICENSE
BugReports: https://github.com/vertesy/Stringendo/issues
Depends:
Depends:
base
Imports:
Imports:
methods
Suggests:
clipr,
dplyr
Suggests:
devtools,
testthat
Encoding: UTF-8
Expand Down
4 changes: 2 additions & 2 deletions Development/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ DESCRIPTION <- list(
description = "Stringendo is a set of R functions to parse strings from variables and to manipulate strings.",

depends = "base",
imports = "dplyr, clipr",
suggests = "devtools, testthat", # removed MarkdownHelpers, MarkdownReports,
imports = "methods",
suggests = "devtools, testthat, clipr", # removed MarkdownHelpers, MarkdownReports, dplyr (no longer used)
Comment on lines +11 to +12

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bump the package version for these behavior changes

Problem: Development/config.R still declares version 1.2.5 even though this commit changes dependencies, fixes separator detection, and exports params.2.fname(). Trigger: When this package is distributed over the existing 1.2.5 release, version-based update checks can treat both builds as the same package and leave users on the old implementation. Fix: Increase the version to 1.2.6 in Development/config.R, then regenerate DESCRIPTION.

AGENTS.md reference: AGENTS.md:L44-L44

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex Please Never again try to raise the package version In any of my repositories, in any PR, ever!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex couldn't complete this request. Try again later.


author.given = "Abel",
author.family = "Vertesy",
Expand Down
3 changes: 1 addition & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,4 @@ export(toUnderscoreSeparated)
export(warnif)
export(warnifnot)
export(ww.break.lines)
importFrom(clipr,write_clip)
importFrom(dplyr,case_when)
importFrom(methods,hasArg)
45 changes: 24 additions & 21 deletions R/Stringendo.R
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,7 @@ ReplaceSpecialCharacters <- function(string = "obj@meta$alpha[[3]]", replacement
x <- gsub(x = x, pattern = " \\.", replacement = ".", perl = TRUE)
x <- gsub(x = x, pattern = "\\. ", replacement = ".", perl = TRUE)
x <- ReplaceRepeatedDots(x)
if (remove_dots) x <- gsub(x = x, pattern = "\\.", replacement = "")
x
if (remove_dots) gsub(x = x, pattern = "\\.", replacement = "") else x # This is the return line.
}


Expand Down Expand Up @@ -1001,7 +1000,6 @@ format_number_h <- function(x, digits = 1, big.mark = " ", decimal.mark = ".") {
#' countDotOrUnderscoreSeparated("add translated metadata")
#' countDotOrUnderscoreSeparated("addTranslatedMetadata")
#' }
#' @importFrom dplyr case_when
#' @export
countDotOrUnderscoreSeparated <- function(string) {
stopifnot(is.character(string), length(string) == 1)
Expand All @@ -1018,14 +1016,19 @@ countDotOrUnderscoreSeparated <- function(string) {
message(paste("Number of white spaces in the string:", ws_count))
}

# First separator that's strictly more frequent than both others wins; a tie is "undecided".
estimated_separator <- dplyr::case_when(
dot_count > max(usc_count, ws_count) ~ "dot",
usc_count > max(dot_count, ws_count) ~ "underscore",
ws_count > max(dot_count, usc_count) ~ "white space",
dot_count == 0 && usc_count == 0 && ws_count == 0 ~ "none",
dot_count == usc_count && dot_count == ws_count ~ "undecided"
)
# Any other tie among the counts (not just a three-way tie) is genuinely
# ambiguous, so it also falls back to "undecided" rather than NA.
estimated_separator <- if (dot_count > max(usc_count, ws_count)) {
"dot"
} else if (usc_count > max(dot_count, ws_count)) {
"underscore"
} else if (ws_count > max(dot_count, usc_count)) {
"white space"
} else if (dot_count == 0 && usc_count == 0 && ws_count == 0) {
"none"
} else {
"undecided"
}

message("Estimated separator: ", estimated_separator)

Expand All @@ -1051,7 +1054,6 @@ countDotOrUnderscoreSeparated <- function(string) {
#' @examples
#' toCamelCase("plot.metadata.cor.heatMap")
#' toCamelCase("plot_metadata_cor_heat_map")
#' @importFrom clipr write_clip
#'
#' @export
toCamelCase <- function(input_string,
Expand Down Expand Up @@ -1098,7 +1100,6 @@ toCamelCase <- function(input_string,
#' toUnderscoreSeparated("plot.Metadata.cor.heatMap")
#' toUnderscoreSeparated("plotMetadataCorHeatMap")
#' toUnderscoreSeparated("plot.metadataCor.heatMap")
#' @importFrom clipr write_clip
#'
#' @export
toUnderscoreSeparated <- function(input_string, toclipboard = TRUE) {
Expand Down Expand Up @@ -1135,7 +1136,6 @@ toUnderscoreSeparated <- function(input_string, toclipboard = TRUE) {
#' @examples
#' toDotSeparated("plotMetadataCorHeatMap")
#' toDotSeparated("plot_Metadata_Cor_HeatMap")
#' @importFrom clipr write_clip
#' @export

toDotSeparated <- function(input_string, toclipboard = TRUE) {
Expand Down Expand Up @@ -1234,6 +1234,7 @@ fix_special_characters_bash <- function(path) {
#' ParseFullFilePath(path = "home/user/docs/", file_name = "report@final", extension = ".txt")
#' ParseFullFilePath(file_name = "report", extension = "txt")
#'
#' @importFrom methods hasArg
#' @export
ParseFullFilePath <- function(path, file_name, extension) {
file_name <- ReplaceRepeatedDots(ReplaceSpecialCharacters(file_name)) # sanitize the file name itself
Expand Down Expand Up @@ -1427,9 +1428,10 @@ parseParamStringWNames <- function(named.vec, sep1 = ": ", sep2 = " | ") {
#' @examples
#' params.2.fname(aa = 1, cc = 2, d = NULL, sep = ".", collapse = "_")
#' # Returns "aa.1_cc.2"
#' @export
params.2.fname <- function(..., sep = ".", collapse = "_") {
x <- list(...)
nmz <- as.character(substitute(list(...))[-1])
nmz <- names(x)

# Filter out NULL values
idx.empty <- sapply(x, is.null)
Expand Down Expand Up @@ -1607,14 +1609,15 @@ parFlags2 <- function(prefix = ".",
pasteflg = TRUE,
coll.char = ".",
coll.char.intra = "_") {
stopifnot(
is.character(prefix), length(prefix) == 1,
is.logical(pasteflg), length(pasteflg) == 1,
is.character(coll.char), length(coll.char) == 1,
is.character(coll.char.intra), length(coll.char.intra) == 1
)
val <- c(...)
names(val) <- as.character(match.call(expand.dots = FALSE)[["..."]])





<- as.character(as.list(match.call())[-(1:2)])
names(val) <- namez
flg <- if (pasteflg) {
paste0(
prefix,
Expand Down
1 change: 1 addition & 0 deletions man/toCamelCase.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/toUnderscoreSeparated.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.