Skip to content

Commit 6f0498f

Browse files
authored
Merge pull request #84 from wlandau/main
Fix record_nonstandard_licenses()
2 parents c8773f0 + 5b83a27 commit 6f0498f

File tree

5 files changed

+37
-22
lines changed

5 files changed

+37
-22
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Package: multiverse.internals
22
Title: Internal Infrastructure for R-multiverse
33
Description: R-multiverse requires this internal infrastructure package to
44
automate contribution reviews and populate universes.
5-
Version: 1.0.11
5+
Version: 1.0.12
66
License: MIT + file LICENSE
77
URL:
88
https://r-multiverse.org/multiverse.internals/,

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# multiverse.internals 1.0.12
2+
3+
* Fix `record_nonstandard_licenses()` (continuation of 1.0.11).
4+
15
# multiverse.internals 1.0.11
26

37
* Use `tools::analyze_license()` for continuous license checks because `utils::available.packages(repos = "https://community.r-multiverse.org", filters = "license/FOSS")` no longer returns output.

R/record_nonstandard_licenses.R

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,22 @@
77
#' [record_nonstandard_licenses()] records packages with nonstandard
88
#' licenses.
99
#' @return `NULL` (invisibly). Called for its side effects.
10-
#' @param repo Character string, URL of the repository.
11-
#' @param path Character string, output path to write JSON data with the names
10+
#' @param path_status Character string, local path to the `status.json` file
11+
#' of the repository.
12+
#' @param path_nonstandard_licenses Character string,
13+
#' output path to write JSON data with the names
1214
#' and licenses of packages with non-standard licenses.
1315
record_nonstandard_licenses <- function(
14-
repo = "https://community.r-multiverse.org",
15-
path = "nonstandard_licenses.json"
16+
path_status = "status.json",
17+
path_nonstandard_licenses = "nonstandard_licenses.json"
1618
) {
17-
url <- utils::contrib.url(trim_url(repo), type = "source")
18-
all <- utils::available.packages(contriburl = url)
19-
foss <- utils::available.packages(contriburl = url, filters = "license/FOSS")
20-
package <- as.character(setdiff(all[, "Package"], foss[, "Package"]))
21-
license <- as.character(all[package, "License"])
19+
json_status <- jsonlite::read_json(path_status, simplifyVector = TRUE)
20+
nonstandard <- Filter(function(json) !is.null(json$license), json_status)
21+
package <- names(nonstandard)
22+
license <- as.character(lapply(nonstandard, function(json) json$license))
2223
jsonlite::write_json(
2324
x = data.frame(package = package, license = license),
24-
path = path,
25+
path = path_nonstandard_licenses,
2526
pretty = TRUE
2627
)
2728
}

man/record_nonstandard_licenses.Rd

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
test_that("record_nonstandard_licenses()", {
2-
skip_if_offline()
3-
temp <- tempfile()
4-
on.exit(unlink(temp))
1+
test_that("record_status() mocked", {
2+
status <- tempfile()
3+
nonstandard <- tempfile()
4+
record_status(
5+
versions = mock_versions(),
6+
mock = list(packages = mock_meta_packages),
7+
output = status,
8+
verbose = FALSE
9+
)
510
record_nonstandard_licenses(
6-
repo = "https://wlandau.r-universe.dev",
7-
path = temp
11+
path_nonstandard_licenses = nonstandard,
12+
path_status = status
813
)
9-
expect_true(file.exists(temp))
14+
out <- jsonlite::read_json(nonstandard, simplifyVector = TRUE)
15+
expect_equal(nrow(out), 1L)
16+
expect_equal(out$package, "INLA")
17+
expect_equal(out$license, "NOT FOUND")
1018
})

0 commit comments

Comments
 (0)