Skip to content

Commit 9b7ba6e

Browse files
VincentGuyaderYour Name
andauthored
fix: filter .R files correctly in att_from_examples (#125)
Replaced list.files call to only include files ending with .R using a pattern, ensuring case-insensitive matching and avoiding unnecessary recursion. Co-authored-by: Your Name <you@example.com>
1 parent 9c8a1f9 commit 9b7ba6e

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Package: attachment
22
Title: Deal with Dependencies
3-
Version: 0.4.3
3+
Version: 0.4.4
44
Authors@R: c(
55
person("Vincent", "Guyader", , "vincent@thinkr.fr", role = c("cre", "aut"),
66
comment = c(ORCID = "0000-0003-0671-9270")),
7-
person("Sébastien", "Rochette", , "sebastien@thinkr.fr", role = c("aut"),
7+
person("Sébastien", "Rochette", , "sebastienrochettefr@gmail.com", role = c("aut"),
88
comment = c(ORCID = "0000-0002-1565-9313", "previous maintainer")),
99
person("Murielle", "Delmotte", , "murielle@thinkr.fr", role = "aut",
1010
comment = c(ORCID = "0000-0002-1339-2424")),

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# attachment 0.4.4
2+
3+
## Patch
4+
5+
- `att_from_examples()` Fixed the selection of `.R` files in the source directory. (#124)
6+
17
# attachment 0.4.3
28

39
## New features

R/add_from_examples.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#' @export
1414
att_from_examples <- function(dir.r = "R") {
15-
rfiles <- list.files(dir.r, full.names = TRUE)
15+
rfiles <- list.files(dir.r, full.names = TRUE, pattern = "\\.r$", ignore.case = TRUE,recursive = FALSE)
1616

1717
roxy_file <- tempfile("roxy.examples", fileext = ".R")
1818

tests/testthat/test-att_from_examples.R

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,29 @@ my_length <- function(x) {
2222
c("magrittr", "fakepkg"))
2323

2424
})
25+
test_that("att_from_examples works even with sysdata.rda", {
26+
tmpdir <- tempfile("suggestexamples")
27+
28+
dir.create(file.path(tmpdir, "R"), recursive = TRUE)
29+
30+
r_file <- file.path(tmpdir, "R", "fun_manual.R")
31+
file.create(r_file)
32+
33+
writeLines(
34+
text = "#' @importFrom magrittr %>%
35+
#' @examples
36+
#' library(magrittr)
37+
#' fakepkg::fun()
38+
#' @export
39+
my_length <- function(x) {
40+
x %>% length()
41+
}",
42+
con = r_file
43+
)
44+
45+
save(iris,file = file.path(tmpdir,"R","sysdata.rda"),compress = "bzip2",version = 3,ascii = FALSE)
46+
47+
expect_equal(att_from_examples(dir.r = file.path(tmpdir, "R")),
48+
c("magrittr", "fakepkg"))
49+
50+
})

0 commit comments

Comments
 (0)