Browse Source

added note abt need for external utility for one check; made addin interacrtive

master
boB Rudis 5 years ago
parent
commit
3916222996
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 1
      DESCRIPTION
  2. 2
      NAMESPACE
  3. 26
      R/check-package-urls.R
  4. 8
      R/hrbraddins-package.R
  5. 4
      inst/rstudio/addins.dcf
  6. 5
      man/check_package_urls.Rd

1
DESCRIPTION

@ -23,6 +23,7 @@ Imports:
magick,
pdftools,
rmarkdown,
urltools,
gistr,
knitr,
twitteR,

2
NAMESPACE

@ -23,6 +23,7 @@ import(tinytest)
import(utils)
importFrom(dplyr,bind_cols)
importFrom(dplyr,bind_rows)
importFrom(dplyr,case_when)
importFrom(dplyr,distinct)
importFrom(dplyr,filter)
importFrom(dplyr,full_join)
@ -37,5 +38,6 @@ importFrom(purrr,map_dbl)
importFrom(tibble,as_tibble)
importFrom(tidyr,gather)
importFrom(twitteR,tweet)
importFrom(urltools,scheme)
importFrom(utils,read.csv)
importFrom(uuid,UUIDgenerate)

26
R/check-package-urls.R

@ -1,17 +1,20 @@
m_GET <- memoise::memoise(httr::GET) # avoid checking URL more than once
tc <- function(x, where = NULL) {
if (length(where)) message("- Looking in ", where, " files...")
tryCatch(x, error = function(e) NULL)
}
#' Check package URLs
#'
#' @note This uses non-exported functions from {tools}, one of which
#' relies on the `pdftohtml` binary being present on the
#' system running this function.
#' @export
check_package_urls <- function() {
.pb <- NULL
m_GET <- memoise::memoise(httr::GET) # avoid checking URL more than once
tc <- function(x, where = NULL) {
if (length(where)) message("- Looking in ", where, " files...")
tryCatch(x, error = function(e) NULL)
}
pkg <- tc(rprojroot::find_package_root_file())
if (is.null(pkg)) stop("Could not find package root.", call.=FALSE)
@ -34,9 +37,16 @@ check_package_urls <- function() {
. } %>%
dplyr::mutate(status = purrr::map_dbl(URL, ~{
.pb$tick()$print()
tryCatch(httr::status_code(m_GET(url = .x)), error = function(x) 599)
tryCatch(
httr::status_code(m_GET(url = .x)),
error = function(x) 599
)
})) %>%
janitor::clean_names() %>%
dplyr::mutate(is_https = dplyr::case_when(
grepl("^htt", url) ~ scheme(url) == "https",
TRUE ~ NA
)) %>%
tibble::as_tibble() %>%
print(nrow(.))

8
R/hrbraddins-package.R

@ -4,17 +4,17 @@
#' @docType package
#' @author Bob Rudis (bob@@rud.is)
#' @import rstudioapi magick pdftools rmarkdown knitr utils
#' @import shiny miniUI stringi tinytest rprojroot
#' @importFrom httr GET status_code
#' @importFrom memoise memoise
#' @importFrom gistr gist_create
#' @importFrom twitteR tweet
#' @importFrom utils read.csv
#' @import shiny miniUI stringi
#' @importFrom dplyr bind_cols bind_rows left_join filter full_join progress_estimated
#' @importFrom dplyr distinct mutate
#' @importFrom dplyr bind_cols bind_rows left_join filter full_join
#' @importFrom dplyr distinct mutate case_when progress_estimated
#' @importFrom tibble as_tibble
#' @importFrom purrr map_dbl
#' @importFrom tidyr gather
#' @importFrom uuid UUIDgenerate
#' @import tinytest rprojroot
#' @importFrom urltools scheme
"_PACKAGE"

4
inst/rstudio/addins.dcf

@ -1,12 +1,12 @@
Name: Check Package URLs
Description: Use the same methods CRAN does to validate URLs in your package
Binding: check_package_urls
Interactive: false
Interactive: true
Name: Tiny Test Package
Description: Run {tinytest} on a pkg
Binding: run_tiny_test
Interactive: false
Interactive: true
Name: Refresh .Renviron
Description: Refreshes the in-memory environment variables from ~/.Renviron without requiring a restart

5
man/check_package_urls.Rd

@ -9,3 +9,8 @@ check_package_urls()
\description{
Check package URLs
}
\note{
This uses non-exported functions from {tools}, one of which
relies on the `pdftohtml` binary being present on the
system running this function.
}

Loading…
Cancel
Save