Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single #356

Merged
merged 3 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ NAMESPACE: R/*
README.md: README.Rmd
Rscript -e "knitr::knit('README.Rmd')"

R/sysdata.rda: data-raw/single.json
Rscript data-raw/convert.R
README.html: README.md
pandoc -o README.html README.md

../$(pkg)*.tar.gz: DESCRIPTION NAMESPACE README.md R/* man/* tests/testthat/* po/R-rio.pot
../$(pkg)*.tar.gz: DESCRIPTION NAMESPACE README.md R/* man/* tests/testthat/* po/R-rio.pot R/sysdata.rda
cd ../ && R CMD build $(pkg)

build: ../$(pkg)*.tar.gz
Expand Down
25 changes: 13 additions & 12 deletions R/suggestions.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ install_formats <- function(...) {
if (length(to_install)) {
utils::install.packages(to_install, ...)
}
return(TRUE)
invisible(TRUE)
}

uninstalled_formats <- function() {
Expand All @@ -28,11 +28,12 @@ uninstalled_formats <- function() {
# 1.2.0)`) suggested in the `DESCRIPTION` file. However, this seems a bit
# recursive, as `devtools` or `remotes` are often also in the `Suggests`
# field.
suggestions <- read.dcf(system.file("DESCRIPTION", package = utils::packageName(), mustWork = TRUE), fields = "Suggests")
suggestions <- parse_suggestions(suggestions)
common_suggestions <- c("bit64", "datasets", "devtools", "knitr", "magrittr", "testthat")
suggestions <- setdiff(suggestions, common_suggestions)

## suggestions <- read.dcf(system.file("DESCRIPTION", package = utils::packageName(), mustWork = TRUE), fields = "Suggests")
## suggestions <- parse_suggestions(suggestions)
## common_suggestions <- c("bit64", "datasets", "devtools", "knitr", "magrittr", "testthat")
## suggestions <- setdiff(suggestions, common_suggestions)
all_functions <- unlist(rio_formats[rio_formats$type == "suggest", c("import_function", "export_function")], use.names = FALSE)
suggestions <- unique(stats::na.omit(stringi::stri_extract_first(all_functions, regex = "[a-zA-Z0-9\\.]+")))
# which are not installed
unlist(lapply(suggestions, function(x) {
if (length(find.package(x, quiet = TRUE))) {
Expand All @@ -43,9 +44,9 @@ uninstalled_formats <- function() {
}))
}

parse_suggestions <- function(suggestions) {
suggestions <- unlist(strsplit(suggestions, split = ",|, |\n"))
suggestions <- gsub("\\s*\\(.*\\)", "", suggestions)
suggestions <- sort(suggestions[suggestions != ""])
suggestions
}
## parse_suggestions <- function(suggestions) {
## suggestions <- unlist(strsplit(suggestions, split = ",|, |\n"))
## suggestions <- gsub("\\s*\\(.*\\)", "", suggestions)
## suggestions <- sort(suggestions[suggestions != ""])
## suggestions
## }
11 changes: 11 additions & 0 deletions data-raw/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

Please edit the json file if you have made change related to formats.

`convert.R` will prettify the json file as well as regenerate the internal data (`R/sysdata.rda`)

If you prefer, you can also use the `Makefile`

```R
make R/sysdata.rda
```

62 changes: 0 additions & 62 deletions tests/testdata/example-DESCRIPTION

This file was deleted.

9 changes: 0 additions & 9 deletions tests/testthat/test_install_formats.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,3 @@ test_that("uninstalled_formats()", {
expect_type(formats, "character")
}
})

test_that("install_formats()", {
suggestions <- read.dcf("../testdata/example-DESCRIPTION",
fields = "Suggests")
suggestions <- parse_suggestions(suggestions)
expect_true("NANTUCKET" %in% suggestions)
expect_true("readODS" %in% suggestions)
expect_false("devtools" %in% suggestions)
})