Skip to content

Commit

Permalink
feat: Rename package to {rprofile.setup}
Browse files Browse the repository at this point in the history
  • Loading branch information
csgillespie committed Oct 14, 2023
1 parent 1c5e3df commit bc6c510
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: rprofile
Package: rprofile.setup
Title: My Rprofile in a Handy R Package
Version: 0.1.14
Version: 0.2.0
Authors@R:
person(given = "Colin",
family = "Gillespie",
Expand Down
9 changes: 7 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# rprofile.setup 0.2.0 _2023-07-19_
* feat: Rename package as there is now an {rprofile} package on CRAN
* refactor: `get_r_sessions()` remove `greps` using `str_detect()`
* refactor: `stripspace()` only update if the file has changed

# rprofile 0.1.14 _2023-07-19_
* refactor: Remove importFrom where possible
* feat: Use tibbles for lsos

# rprofile 0.1.13 _2023-06-05_
* fix: Use prompts from {prompt} to avoid odd terminal resizing.
* fix: Use prompts from {prompt} to avoid odd terminal resizing.

# rprofile 0.1.12 _2022-11-08_
* Add `stripspace()` function for cleaning files
* Remove `check.bounds` option - too noisy
Expand Down
12 changes: 8 additions & 4 deletions R/set-startup-info.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,16 @@ get_internet = function() {
return(con_str)
}

remove_greps = function(r_sessions) {
stringr::str_detect()
}

get_r_sessions = function() {
if (Sys.info()[["sysname"]] %in% c("Linux", "Darwin")) {
r_sessions = system2("ps", args = c("aux", "|", "grep", "rsession"), stdout = TRUE)
no_sessions = length(r_sessions) - 2
r_sessions = system2("ps", args = c("aux", "|", "grep", "exec/R"), stdout = TRUE)
return(no_sessions + length(r_sessions) - 2)
r_sessions = c(system2("ps", args = c("aux", "|", "grep", "rsession"), stdout = TRUE),
system2("ps", args = c("aux", "|", "grep", "exec/R"), stdout = TRUE))
no_of_sessions = sum(stringr::str_detect(r_sessions, "grep", negate = TRUE))
return(no_of_sessions)
}
return("Unknown system")
}
Expand Down
8 changes: 6 additions & 2 deletions R/stripspace.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ stripspace = function() {
fnames = list.files(pattern = "\\.R$|\\.qmd$|\\.Rmd$|\\.md$", full.names = TRUE, recursive = TRUE)
tmp = tempfile()
for (fname in fnames) {
cli::cli_alert("Updating {fname}")
hash1 = rlang::hash_file(fname)
system2("git", c("stripspace", "<", fname, ">", tmp))
system2("cat", c(tmp, ">", fname))
hash2 = rlang::hash_file(tmp)
if (hash1 != hash2) {
cli::cli_alert("Updating {fname}")
system2("cat", c(tmp, ">", fname))
}
}
return(invisible(NULL))
}

0 comments on commit bc6c510

Please sign in to comment.