Skip to content

Commit

Permalink
update to 'fs' in extra-stats.R for #68
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Oct 23, 2024
1 parent 5fa7007 commit 2f8f16d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 29 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: pkgstats
Title: Metrics of R Packages
Version: 0.2.0.014
Version: 0.2.0.015
Authors@R:
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265"))
Expand Down
45 changes: 18 additions & 27 deletions R/extra-stats.R
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@

get_num_vignettes <- function (path) {

nv <- 0L

if ("build" %in% list.files (path)) {
if ("build" %in% fs::dir_ls (path)) {

flist <- list.files (file.path (path, "build"),
flist <- fs::dir_ls (fs::path (path, "build"),

Check warning on line 7 in R/extra-stats.R

View check run for this annotation

Codecov / codecov/patch

R/extra-stats.R#L7

Added line #L7 was not covered by tests
full.names = TRUE
)
vfile <- grep ("vignette", flist, value = TRUE)
if (length (vfile) > 0) {
nv <- nrow (readRDS (vfile [1]))
}
} else if ("vignettes" %in% list.files (path)) {
nv <- length (list.files (
file.path (path, "vignettes"),
pattern = "\\.[rR]md$",
recursive = TRUE
} else if ("vignettes" %in% fs::dir_ls (path)) {
nv <- length (fs::dir_ls (
fs::path (path, "vignettes"),
regexp = "\\.[rR]md$"

Check warning on line 17 in R/extra-stats.R

View check run for this annotation

Codecov / codecov/patch

R/extra-stats.R#L15-L17

Added lines #L15 - L17 were not covered by tests
))
if (nv == 0L) {
nv <- length (list.files (
file.path (path, "vignettes"),
pattern = "\\.[rR]$",
recursive = TRUE
nv <- length (fs::dir_ls (
fs::path (path, "vignettes"),
regexp = "\\.[rR]$"

Check warning on line 22 in R/extra-stats.R

View check run for this annotation

Codecov / codecov/patch

R/extra-stats.R#L20-L22

Added lines #L20 - L22 were not covered by tests
))
}
}
Expand All @@ -34,9 +31,9 @@ get_num_demos <- function (path) {

nd <- 0L

if ("demo" %in% list.files (path)) {
if ("demo" %in% fs::dir_ls (path)) {

dindex <- file.path (path, "demo", "00Index")
dindex <- fs::path (path, "demo", "00Index")

Check warning on line 36 in R/extra-stats.R

View check run for this annotation

Codecov / codecov/patch

R/extra-stats.R#L36

Added line #L36 was not covered by tests
nd <- length (brio::read_lines (dindex))
}

Expand All @@ -47,19 +44,13 @@ get_data_stats <- function (path) {

nd <- c (n = 0L, total_size = 0L, median_size = 0L)

if ("data" %in% list.files (path)) {
if ("data" %in% fs::dir_ls (path)) {

flist <- list.files (file.path (path, "data"),
full.names = TRUE,
pattern = "\\.rd",
flist <- fs::dir_ls (fs::path (path, "data"),
regexp = "\\.rd",

Check warning on line 50 in R/extra-stats.R

View check run for this annotation

Codecov / codecov/patch

R/extra-stats.R#L49-L50

Added lines #L49 - L50 were not covered by tests
ignore.case = TRUE
)
sizes <- vapply (flist, function (i) {
file.info (i)$size
},
numeric (1),
USE.NAMES = FALSE
)
sizes <- fs::file_info (flist)$size

Check warning on line 53 in R/extra-stats.R

View check run for this annotation

Codecov / codecov/patch

R/extra-stats.R#L53

Added line #L53 was not covered by tests

nd [1] <- length (flist)
nd [2] <- as.integer (sum (sizes))
Expand All @@ -76,13 +67,13 @@ get_translations <- function (path) {

ll <- NA_character_

po_dir <- normalizePath (file.path (path, "po"), mustWork = FALSE)
po_dir <- fs::path_abs (fs::path (path, "po"))

if (file.exists (po_dir)) {
if (fs::dir_exists (po_dir)) {

ll <- gsub (
"^R-|\\.po$", "",
list.files (po_dir, pattern = "\\.po$")
fs::dir_ls (po_dir, regexp = "\\.po$")

Check warning on line 76 in R/extra-stats.R

View check run for this annotation

Codecov / codecov/patch

R/extra-stats.R#L76

Added line #L76 was not covered by tests
)
# pkgs may generate translations without having any, and then will only
# have '.pot' files with no usable translation fields.
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"codeRepository": "https://github.com/ropensci-review-tools/pkgstats",
"issueTracker": "https://github.com/ropensci-review-tools/pkgstats/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.2.0.014",
"version": "0.2.0.015",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down

0 comments on commit 2f8f16d

Please sign in to comment.