Skip to content

Commit 8e4c66b

Browse files
authored
Merge pull request #323 from ropensci-review-tools/update
add 'force_update' param to 'fn_names_on_cran' to #321
2 parents ccb0717 + 2dcdec8 commit 8e4c66b

File tree

6 files changed

+96
-38
lines changed

6 files changed

+96
-38
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: pkgcheck
22
Title: rOpenSci Package Checks
3-
Version: 0.1.2.235
3+
Version: 0.1.2.238
44
Authors@R: c(
55
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0003-2172-5265")),
@@ -47,6 +47,7 @@ Imports:
4747
Suggests:
4848
callr,
4949
httptest2,
50+
jsonlite,
5051
knitr,
5152
memoise,
5253
pkgbuild,

R/check-unique-fn-names.R

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ pkgchk_unique_fn_names <- function (checks) {
2525
#' Check whether a function name exists in any CRAN packages
2626
#'
2727
#' @param fn_name Character vector of one or more function names to check.
28+
#' @param force_update If 'TRUE', locally-cached data of all function names
29+
#' from all CRAN packages will be updated to latest version.
2830
#'
2931
#' @return A `data.frame` of three columns, "package", "version", and
3032
#' "fn_name", identifying any other packages matching specified function
@@ -35,9 +37,9 @@ pkgchk_unique_fn_names <- function (checks) {
3537
#'
3638
#' @family extra
3739
#' @export
38-
fn_names_on_cran <- function (fn_name) {
40+
fn_names_on_cran <- function (fn_name, force_update = FALSE) {
3941

40-
fn_names_cran <- read_fn_names_data ()
42+
fn_names_cran <- read_fn_names_data (force_update = force_update)
4143

4244
fn_name <- fn_name [which (fn_name %in% fn_names_cran$fn_name)]
4345

@@ -47,7 +49,7 @@ fn_names_on_cran <- function (fn_name) {
4749
return (res)
4850
}
4951

50-
read_fn_names_data <- function () {
52+
read_fn_names_data <- function (force_update = FALSE) {
5153

5254
# The cache_path is set to tempdir in tests. This tests is then switched off
5355
# to avoid downloading the database just for this test.
@@ -67,7 +69,7 @@ read_fn_names_data <- function () {
6769
f <- NULL
6870
if (!cache_is_temp) {
6971
f <- tryCatch (
70-
cache_fn_name_db (),
72+
cache_fn_name_db (force_update = force_update),
7173
error = function (e) NULL
7274
)
7375
}
@@ -82,7 +84,7 @@ read_fn_names_data <- function () {
8284
return (fn_names_cran)
8385
}
8486

85-
cache_fn_name_db <- function () {
87+
cache_fn_name_db <- function (force_update = FALSE) {
8688

8789
cache_path <- Sys.getenv ("PKGCHECK_CACHE_DIR")
8890
if (!fs::dir_exists (cache_path)) {
@@ -91,15 +93,39 @@ cache_fn_name_db <- function () {
9193

9294
f <- fs::path (cache_path, "pkgstats-fn-names.Rds")
9395

94-
if (fs::file_exists (f)) {
96+
if (fs::file_exists (f) && !force_update) {
9597
return (f)
9698
}
9799

100+
requireNamespace ("jsonlite", quietly = TRUE)
101+
98102
u <- paste0 (
99-
"https://github.com/ropensci-review-tools/pkgstats/",
100-
"releases/download/v0.1.2/pkgstats-fn-names.Rds"
103+
"https://api.github.com/repos/",
104+
"ropensci-review-tools/pkgstats/",
105+
"releases/latest"
101106
)
102-
utils::download.file (u, f, quiet = TRUE)
107+
108+
res <- curl::curl_fetch_memory (u)
109+
hdrs <- curl::parse_headers (res$headers)
110+
http_code <- as.integer (gsub (
111+
"^http\\/[0-9]\\s?|\\s+$",
112+
"",
113+
hdrs [1],
114+
ignore.case = TRUE
115+
))
116+
if (http_code != 200L) {
117+
cli::cli_abort (
118+
"Call to GitHub failed with http error code [{http_code}]"
119+
)
120+
}
121+
122+
res <- jsonlite::fromJSON (rawToChar (res$content))
123+
assets <- res$assets
124+
i <- grep ("fn\\-names", assets$name)
125+
dl_url <- assets$browser_download_url [i]
126+
f <- fs::path (cache_path, basename (dl_url))
127+
128+
curl::curl_download (url = dl_url, destfile = f, quiet = TRUE)
103129

104130
return (f)
105131
}

README.Rmd

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ project, you agree to abide by its terms.
275275

276276

277277

278+
278279
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
279280
<!-- prettier-ignore-start -->
280281
<!-- markdownlint-disable -->
@@ -305,6 +306,12 @@ All contributions to this project are gratefully acknowledged using the [`allcon
305306
<a href="https://github.com/ropensci-review-tools/pkgcheck/commits?author=assignUser">assignUser</a>
306307
</td>
307308
<td align="center">
309+
<a href="https://github.com/ateucher">
310+
<img src="https://avatars.githubusercontent.com/u/2816635?v=4" width="100px;" alt=""/>
311+
</a><br>
312+
<a href="https://github.com/ropensci-review-tools/pkgcheck/commits?author=ateucher">ateucher</a>
313+
</td>
314+
<td align="center">
308315
<a href="https://github.com/markean">
309316
<img src="https://avatars.githubusercontent.com/u/46692399?v=4" width="100px;" alt=""/>
310317
</a><br>
@@ -322,12 +329,6 @@ All contributions to this project are gratefully acknowledged using the [`allcon
322329
</a><br>
323330
<a href="https://github.com/ropensci-review-tools/pkgcheck/commits?author=n-kall">n-kall</a>
324331
</td>
325-
<td align="center">
326-
<a href="https://github.com/ateucher">
327-
<img src="https://avatars.githubusercontent.com/u/2816635?v=4" width="100px;" alt=""/>
328-
</a><br>
329-
<a href="https://github.com/ropensci-review-tools/pkgcheck/commits?author=ateucher">ateucher</a>
330-
</td>
331332
</tr>
332333

333334

@@ -339,6 +340,12 @@ All contributions to this project are gratefully acknowledged using the [`allcon
339340
<a href="https://github.com/ropensci-review-tools/pkgcheck/commits?author=kellijohnson-NOAA">kellijohnson-NOAA</a>
340341
</td>
341342
<td align="center">
343+
<a href="https://github.com/e-kotov">
344+
<img src="https://avatars.githubusercontent.com/u/8681379?v=4" width="100px;" alt=""/>
345+
</a><br>
346+
<a href="https://github.com/ropensci-review-tools/pkgcheck/commits?author=e-kotov">e-kotov</a>
347+
</td>
348+
<td align="center">
342349
<a href="https://github.com/annakrystalli">
343350
<img src="https://avatars.githubusercontent.com/u/5583057?v=4" width="100px;" alt=""/>
344351
</a><br>
@@ -402,7 +409,7 @@ All contributions to this project are gratefully acknowledged using the [`allcon
402409
<tr>
403410
<td align="center">
404411
<a href="https://github.com/Bisaloo">
405-
<img src="https://avatars.githubusercontent.com/u/10783929?u=38e3754466eaa200e20f0609709467b6331cdfbe&v=4" width="100px;" alt=""/>
412+
<img src="https://avatars.githubusercontent.com/u/10783929?u=92fdf68eafbcdcf8da283b460ab65a2cafb8c7fe&v=4" width="100px;" alt=""/>
406413
</a><br>
407414
<a href="https://github.com/ropensci-review-tools/pkgcheck/issues?q=is%3Aissue+author%3ABisaloo">Bisaloo</a>
408415
</td>
@@ -459,10 +466,10 @@ All contributions to this project are gratefully acknowledged using the [`allcon
459466
<a href="https://github.com/ropensci-review-tools/pkgcheck/issues?q=is%3Aissue+author%3Asimpar1471">simpar1471</a>
460467
</td>
461468
<td align="center">
462-
<a href="https://github.com/e-kotov">
463-
<img src="https://avatars.githubusercontent.com/u/8681379?u=c8b4c28fff87ac785df67c71d668c5fa29dde948&v=4" width="100px;" alt=""/>
469+
<a href="https://github.com/etiennebacher">
470+
<img src="https://avatars.githubusercontent.com/u/52219252?u=66331618d799d2d4567ecab2812236c9928be368&v=4" width="100px;" alt=""/>
464471
</a><br>
465-
<a href="https://github.com/ropensci-review-tools/pkgcheck/issues?q=is%3Aissue+author%3Ae-kotov">e-kotov</a>
472+
<a href="https://github.com/ropensci-review-tools/pkgcheck/issues?q=is%3Aissue+author%3Aetiennebacher">etiennebacher</a>
466473
</td>
467474
</tr>
468475

@@ -528,7 +535,7 @@ All contributions to this project are gratefully acknowledged using the [`allcon
528535
</td>
529536
<td align="center">
530537
<a href="https://github.com/b-rodrigues">
531-
<img src="https://avatars.githubusercontent.com/u/2998834?u=1067df184bd6f659befa96050717702842db557c&v=4" width="100px;" alt=""/>
538+
<img src="https://avatars.githubusercontent.com/u/2998834?u=815e6c1eedc0305ca7a62a89293efbe488583fce&v=4" width="100px;" alt=""/>
532539
</a><br>
533540
<a href="https://github.com/ropensci-review-tools/pkgcheck/issues?q=is%3Aissue+commenter%3Ab-rodrigues">b-rodrigues</a>
534541
</td>

README.md

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -295,18 +295,17 @@ project, you agree to abide by its terms.
295295

296296
## Contributors
297297

298+
298299
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
299300
<!-- prettier-ignore-start -->
300301
<!-- markdownlint-disable -->
301302

302-
All contributions to this project are gratefully acknowledged using the
303-
[`allcontributors` package](https://github.com/ropensci/allcontributors)
304-
following the [allcontributors](https://allcontributors.org)
305-
specification. Contributions of any kind are welcome!
303+
All contributions to this project are gratefully acknowledged using the [`allcontributors` package](https://github.com/ropensci/allcontributors) following the [allcontributors](https://allcontributors.org) specification. Contributions of any kind are welcome!
306304

307305
### Code
308306

309307
<table>
308+
310309
<tr>
311310
<td align="center">
312311
<a href="https://github.com/mpadge">
@@ -327,6 +326,12 @@ specification. Contributions of any kind are welcome!
327326
<a href="https://github.com/ropensci-review-tools/pkgcheck/commits?author=assignUser">assignUser</a>
328327
</td>
329328
<td align="center">
329+
<a href="https://github.com/ateucher">
330+
<img src="https://avatars.githubusercontent.com/u/2816635?v=4" width="100px;" alt=""/>
331+
</a><br>
332+
<a href="https://github.com/ropensci-review-tools/pkgcheck/commits?author=ateucher">ateucher</a>
333+
</td>
334+
<td align="center">
330335
<a href="https://github.com/markean">
331336
<img src="https://avatars.githubusercontent.com/u/46692399?v=4" width="100px;" alt=""/>
332337
</a><br>
@@ -344,13 +349,9 @@ specification. Contributions of any kind are welcome!
344349
</a><br>
345350
<a href="https://github.com/ropensci-review-tools/pkgcheck/commits?author=n-kall">n-kall</a>
346351
</td>
347-
<td align="center">
348-
<a href="https://github.com/ateucher">
349-
<img src="https://avatars.githubusercontent.com/u/2816635?v=4" width="100px;" alt=""/>
350-
</a><br>
351-
<a href="https://github.com/ropensci-review-tools/pkgcheck/commits?author=ateucher">ateucher</a>
352-
</td>
353352
</tr>
353+
354+
354355
<tr>
355356
<td align="center">
356357
<a href="https://github.com/kellijohnson-NOAA">
@@ -359,17 +360,26 @@ specification. Contributions of any kind are welcome!
359360
<a href="https://github.com/ropensci-review-tools/pkgcheck/commits?author=kellijohnson-NOAA">kellijohnson-NOAA</a>
360361
</td>
361362
<td align="center">
363+
<a href="https://github.com/e-kotov">
364+
<img src="https://avatars.githubusercontent.com/u/8681379?v=4" width="100px;" alt=""/>
365+
</a><br>
366+
<a href="https://github.com/ropensci-review-tools/pkgcheck/commits?author=e-kotov">e-kotov</a>
367+
</td>
368+
<td align="center">
362369
<a href="https://github.com/annakrystalli">
363370
<img src="https://avatars.githubusercontent.com/u/5583057?v=4" width="100px;" alt=""/>
364371
</a><br>
365372
<a href="https://github.com/ropensci-review-tools/pkgcheck/commits?author=annakrystalli">annakrystalli</a>
366373
</td>
367374
</tr>
375+
368376
</table>
369377

378+
370379
### Issue Authors
371380

372381
<table>
382+
373383
<tr>
374384
<td align="center">
375385
<a href="https://github.com/karthik">
@@ -414,10 +424,12 @@ specification. Contributions of any kind are welcome!
414424
<a href="https://github.com/ropensci-review-tools/pkgcheck/issues?q=is%3Aissue+author%3As3alfisc">s3alfisc</a>
415425
</td>
416426
</tr>
427+
428+
417429
<tr>
418430
<td align="center">
419431
<a href="https://github.com/Bisaloo">
420-
<img src="https://avatars.githubusercontent.com/u/10783929?u=38e3754466eaa200e20f0609709467b6331cdfbe&v=4" width="100px;" alt=""/>
432+
<img src="https://avatars.githubusercontent.com/u/10783929?u=92fdf68eafbcdcf8da283b460ab65a2cafb8c7fe&v=4" width="100px;" alt=""/>
421433
</a><br>
422434
<a href="https://github.com/ropensci-review-tools/pkgcheck/issues?q=is%3Aissue+author%3ABisaloo">Bisaloo</a>
423435
</td>
@@ -458,6 +470,8 @@ specification. Contributions of any kind are welcome!
458470
<a href="https://github.com/ropensci-review-tools/pkgcheck/issues?q=is%3Aissue+author%3Asjentsch">sjentsch</a>
459471
</td>
460472
</tr>
473+
474+
461475
<tr>
462476
<td align="center">
463477
<a href="https://github.com/willgearty">
@@ -472,17 +486,20 @@ specification. Contributions of any kind are welcome!
472486
<a href="https://github.com/ropensci-review-tools/pkgcheck/issues?q=is%3Aissue+author%3Asimpar1471">simpar1471</a>
473487
</td>
474488
<td align="center">
475-
<a href="https://github.com/e-kotov">
476-
<img src="https://avatars.githubusercontent.com/u/8681379?u=c8b4c28fff87ac785df67c71d668c5fa29dde948&v=4" width="100px;" alt=""/>
489+
<a href="https://github.com/etiennebacher">
490+
<img src="https://avatars.githubusercontent.com/u/52219252?u=66331618d799d2d4567ecab2812236c9928be368&v=4" width="100px;" alt=""/>
477491
</a><br>
478-
<a href="https://github.com/ropensci-review-tools/pkgcheck/issues?q=is%3Aissue+author%3Ae-kotov">e-kotov</a>
492+
<a href="https://github.com/ropensci-review-tools/pkgcheck/issues?q=is%3Aissue+author%3Aetiennebacher">etiennebacher</a>
479493
</td>
480494
</tr>
495+
481496
</table>
482497

498+
483499
### Issue Contributors
484500

485501
<table>
502+
486503
<tr>
487504
<td align="center">
488505
<a href="https://github.com/ddbortoli">
@@ -527,6 +544,8 @@ specification. Contributions of any kind are welcome!
527544
<a href="https://github.com/ropensci-review-tools/pkgcheck/issues?q=is%3Aissue+commenter%3Abnicenboim">bnicenboim</a>
528545
</td>
529546
</tr>
547+
548+
530549
<tr>
531550
<td align="center">
532551
<a href="https://github.com/laijasmine">
@@ -536,7 +555,7 @@ specification. Contributions of any kind are welcome!
536555
</td>
537556
<td align="center">
538557
<a href="https://github.com/b-rodrigues">
539-
<img src="https://avatars.githubusercontent.com/u/2998834?u=1067df184bd6f659befa96050717702842db557c&v=4" width="100px;" alt=""/>
558+
<img src="https://avatars.githubusercontent.com/u/2998834?u=815e6c1eedc0305ca7a62a89293efbe488583fce&v=4" width="100px;" alt=""/>
540559
</a><br>
541560
<a href="https://github.com/ropensci-review-tools/pkgcheck/issues?q=is%3Aissue+commenter%3Ab-rodrigues">b-rodrigues</a>
542561
</td>
@@ -559,7 +578,9 @@ specification. Contributions of any kind are welcome!
559578
<a href="https://github.com/ropensci-review-tools/pkgcheck/issues?q=is%3Aissue+commenter%3ATimTaylor">TimTaylor</a>
560579
</td>
561580
</tr>
581+
562582
</table>
583+
563584
<!-- markdownlint-enable -->
564585
<!-- prettier-ignore-end -->
565586
<!-- ALL-CONTRIBUTORS-LIST:END -->

codemeta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"codeRepository": "https://github.com/ropensci-review-tools/pkgcheck",
99
"issueTracker": "https://github.com/ropensci-review-tools/pkgcheck/issues",
1010
"license": "https://spdx.org/licenses/GPL-3.0",
11-
"version": "0.1.2.235",
11+
"version": "0.1.2.238",
1212
"programmingLanguage": {
1313
"@type": "ComputerLanguage",
1414
"name": "R",

man/fn_names_on_cran.Rd

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)