Skip to content

Commit

Permalink
separate 'get_all_file_names' fn
Browse files Browse the repository at this point in the history
To use in 'get_all_msgs' and 'get_stds_from_code'
  • Loading branch information
mpadge committed Mar 13, 2024
1 parent 646983e commit c88fefd
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
@@ -1,6 +1,6 @@
Package: srr
Title: 'rOpenSci' Review Roclets
Version: 0.1.0.001
Version: 0.1.1
Authors@R:
person("Mark", "Padgham", , "mark@ropensci.org", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265"))
Expand Down
18 changes: 1 addition & 17 deletions R/pre-submit.R
Expand Up @@ -61,23 +61,7 @@ srr_stats_pre_submit <- function (path = ".", quiet = FALSE) {

get_stds_from_code <- function (path) {

if (!dir.exists (file.path (path, "R"))) {
warning ("Directory [", path, "] does not appear to be an R package")
return (NULL)
}

dirs <- c (".", "R", "vignettes", "tests")
sfxs <- c ("\\.(R|r)md$", "\\.(R|r)$", "\\.(R|r)md$", "\\.(R|r)$")
rec <- c (FALSE, FALSE, TRUE, TRUE)

flist <- lapply (seq_along (dirs), function (i) {
list.files (file.path (path, dirs [i]),
full.names = TRUE,
recursive = rec [i],
pattern = sfxs [i]
)
})
flist <- normalizePath (unlist (flist))
flist <- get_all_file_names (path)

suppressWarnings ({
blocks <- lapply (flist, function (i) {
Expand Down
6 changes: 1 addition & 5 deletions R/report.R
@@ -1,4 +1,3 @@

#' Generate report from `ssr` tags.
#'
#' @param path Path to package for which report is to be generated
Expand Down Expand Up @@ -205,10 +204,7 @@ srr_report <- function (path = ".", branch = "", view = TRUE) {

get_all_msgs <- function (path = ".") {

flist <- normalizePath (list.files (file.path (path, "R"),
full.names = TRUE,
pattern = "\\.(r|R|q|s|S)$"
))
flist <- get_all_file_names (path)

pkg_name <- paste0 ("package:", pkg_name_from_desc (path))
if (!pkg_name %in% search ()) {
Expand Down
24 changes: 23 additions & 1 deletion R/utils.R
@@ -1,6 +1,28 @@

pkg_name_from_desc <- function (path) {

desc <- file.path (path, "DESCRIPTION")
as.character (read.dcf (desc, "Package"))
}

get_all_file_names <- function (path) {

if (!dir.exists (file.path (path, "R"))) {
warning ("Directory [", path, "] does not appear to be an R package")
return (NULL)
}

dirs <- c (".", "R", "vignettes", "tests")
sfxs <- c ("\\.(R|r)md$", "\\.(R|r)$", "\\.(R|r)md$", "\\.(R|r)$")
rec <- c (FALSE, FALSE, TRUE, TRUE)

flist <- lapply (seq_along (dirs), function (i) {
list.files (file.path (path, dirs [i]),
full.names = TRUE,
recursive = rec [i],
pattern = sfxs [i]
)
})
flist <- normalizePath (unlist (flist))

return (flist)
}
2 changes: 1 addition & 1 deletion codemeta.json
Expand Up @@ -8,7 +8,7 @@
"codeRepository": "https://github.com/ropensci-review-tools/srr",
"issueTracker": "https://github.com/ropensci-review-tools/srr/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "0.1.0.001",
"version": "0.1.0.002",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down

0 comments on commit c88fefd

Please sign in to comment.