From 15455333627bc0d9c87b7c0e8f6ec1305909a7c1 Mon Sep 17 00:00:00 2001 From: boB Rudis Date: Thu, 25 Jul 2019 09:11:33 -0400 Subject: [PATCH] check urls --- DESCRIPTION | 12 ++++++++---- NAMESPACE | 10 +++++++++- NEWS.md | 3 +++ R/aaa.R | 4 ++++ R/check-package-urls.R | 9 +++------ R/hrbraddins-package.R | 13 +++++++++---- R/refresh-renviron.R | 4 ++-- R/run-tiny-test.R | 4 ++++ README.md | 8 ++++---- man/check_package_urls.Rd | 6 +----- man/hrbraddins.Rd | 12 ++++++++++-- man/run_tiny_test.Rd | 11 +++++++++++ 12 files changed, 68 insertions(+), 28 deletions(-) create mode 100644 R/aaa.R create mode 100644 man/run_tiny_test.Rd diff --git a/DESCRIPTION b/DESCRIPTION index ae9bea1..b852f94 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: hrbraddins Type: Package -Title: Additional Addins for RStudio -Version: 0.2.0 -Date: 2018-07-25 +Title: Moar Addins for RStudio +Version: 0.3.0 +Date: 2019-07-25 Author: Bob Rudis (bob@rud.is) Maintainer: Bob Rudis Description: Provides additional addins for RStudio. @@ -33,5 +33,9 @@ Imports: tinytest, rprojroot, memoise, - tools + tools, + httr, + janitor, + purrr, + tibble RoxygenNote: 6.1.1 diff --git a/NAMESPACE b/NAMESPACE index 73a80e6..a42cb28 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -20,13 +20,21 @@ import(rstudioapi) import(shiny) import(stringi) import(tinytest) -importFrom(dplyr,as_data_frame) +import(utils) importFrom(dplyr,bind_cols) importFrom(dplyr,bind_rows) +importFrom(dplyr,distinct) importFrom(dplyr,filter) importFrom(dplyr,full_join) importFrom(dplyr,left_join) +importFrom(dplyr,mutate) +importFrom(dplyr,progress_estimated) importFrom(gistr,gist_create) +importFrom(httr,GET) +importFrom(httr,status_code) +importFrom(memoise,memoise) +importFrom(purrr,map_dbl) +importFrom(tibble,as_tibble) importFrom(tidyr,gather) importFrom(twitteR,tweet) importFrom(utils,read.csv) diff --git a/NEWS.md b/NEWS.md index 1755157..1c8e990 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +0.3.0 +- Check package URLs + 0.2.0 * Refresh Renviron diff --git a/R/aaa.R b/R/aaa.R new file mode 100644 index 0000000..c93aa55 --- /dev/null +++ b/R/aaa.R @@ -0,0 +1,4 @@ +.pb <- NULL +utils::globalVariables(c( + ".", "URL", "env_var", "value", "new_value", ".rs.api.runScriptJob" +)) \ No newline at end of file diff --git a/R/check-package-urls.R b/R/check-package-urls.R index 67b92d0..02b67b9 100644 --- a/R/check-package-urls.R +++ b/R/check-package-urls.R @@ -1,9 +1,7 @@ #' Check package URLs #' -#' @param just_pass_or_fail if `TRUE` (default is `FALSE`) just return `TRUE` if -#' all the URL checks result in HTTP `200` status codes. #' @export -check_package_urls <- function(just_pass_or_fail = FALSE) { +check_package_urls <- function() { m_GET <- memoise::memoise(httr::GET) # avoid checking URL more than once @@ -37,8 +35,7 @@ check_package_urls <- function(just_pass_or_fail = FALSE) { tryCatch(httr::status_code(m_GET(url = .x)), error = 599) })) %>% janitor::clean_names() %>% - tibble::as_tibble() -> out - - if (just_pass_or_fail) all(out$status == 200) else print(out, nrow(out)) + tibble::as_tibble() %>% + print(nrow(.)) } diff --git a/R/hrbraddins-package.R b/R/hrbraddins-package.R index 3536ac8..239f391 100644 --- a/R/hrbraddins-package.R +++ b/R/hrbraddins-package.R @@ -1,15 +1,20 @@ -#' Additional Addins for RStudio +#' Moar Addins for RStudio #' #' @name hrbraddins #' @docType package #' @author Bob Rudis (bob@@rud.is) -#' @import rstudioapi magick pdftools rmarkdown knitr +#' @import rstudioapi magick pdftools rmarkdown knitr utils +#' @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 as_data_frame bind_cols bind_rows left_join filter full_join +#' @importFrom dplyr bind_cols bind_rows left_join filter full_join progress_estimated +#' @importFrom dplyr distinct mutate +#' @importFrom tibble as_tibble +#' @importFrom purrr map_dbl #' @importFrom tidyr gather #' @importFrom uuid UUIDgenerate #' @import tinytest rprojroot -NULL +"_PACKAGE" diff --git a/R/refresh-renviron.R b/R/refresh-renviron.R index adaf2db..a079134 100644 --- a/R/refresh-renviron.R +++ b/R/refresh-renviron.R @@ -7,11 +7,11 @@ refresh_renviron <- function() { renv <- path.expand("~/.Renviron") - curr_env <- gather(as_tibble(as.list(Sys.getenv())), env_var, value) + curr_env <- tidyr::gather(tibble::as_tibble(as.list(Sys.getenv())), env_var, value) if (file.exists(renv)) readRenviron(renv) - new_env <- gather(as_data_frame(as.list(Sys.getenv())), env_var, new_value) + new_env <- tidyr::gather(tibble::as_tibble(as.list(Sys.getenv())), env_var, new_value) both_env <- full_join(curr_env, new_env, by="env_var") diff --git a/R/run-tiny-test.R b/R/run-tiny-test.R index 8bbf627..cf929ff 100644 --- a/R/run-tiny-test.R +++ b/R/run-tiny-test.R @@ -1,3 +1,7 @@ +#' Run {tinytest} on a package +#' +#' You should really bind this to something like cmd-opt-shift-t. +#' #' @export run_tiny_test <- function() { try(tinytest::test_all(rprojroot::find_package_root_file()), silent = TRUE) diff --git a/README.md b/README.md index e687ce1..2f405f6 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.re [![Signed by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keybase.io/hrbrmstr) ![Signed commit -%](https://img.shields.io/badge/Signed_Commits-35.7%25-lightgrey.svg) +%](https://img.shields.io/badge/Signed_Commits-100%25-lightgrey.svg) [![Linux build Status](https://travis-ci.org/hrbrmstr/hrbraddins.svg?branch=master)](https://travis-ci.org/hrbrmstr/hrbraddins) [![Coverage @@ -59,12 +59,12 @@ remotes::install_github("hrbrmstr/hrbraddins") NOTE: To use the ‘remotes’ install options you will need to have the [{remotes} package](https://github.com/r-lib/remotes) installed. -## tdigest Metrics +## hrbraddins Metrics | Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) | | :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | ---: | -| R | 13 | 0.93 | 180 | 0.97 | 84 | 0.84 | 72 | 0.75 | -| Rmd | 1 | 0.07 | 5 | 0.03 | 16 | 0.16 | 24 | 0.25 | +| R | 13 | 0.93 | 180 | 0.97 | 84 | 0.85 | 72 | 0.75 | +| Rmd | 1 | 0.07 | 5 | 0.03 | 15 | 0.15 | 24 | 0.25 | ## Code of Conduct diff --git a/man/check_package_urls.Rd b/man/check_package_urls.Rd index ebe7d3c..21fe198 100644 --- a/man/check_package_urls.Rd +++ b/man/check_package_urls.Rd @@ -4,11 +4,7 @@ \alias{check_package_urls} \title{Check package URLs} \usage{ -check_package_urls(just_pass_or_fail = FALSE) -} -\arguments{ -\item{just_pass_or_fail}{if `TRUE` (default is `FALSE`) just return `TRUE` if -all the URL checks result in HTTP `200` status codes.} +check_package_urls() } \description{ Check package URLs diff --git a/man/hrbraddins.Rd b/man/hrbraddins.Rd index 0bf06f1..b245f06 100644 --- a/man/hrbraddins.Rd +++ b/man/hrbraddins.Rd @@ -4,9 +4,17 @@ \name{hrbraddins} \alias{hrbraddins} \alias{hrbraddins-package} -\title{Additional Addins for RStudio} +\title{Moar Addins for RStudio} \description{ -Additional Addins for RStudio +Provides additional addins for RStudio. +} +\seealso{ +Useful links: +\itemize{ + \item \url{https://gitlab.com/hrbrmstr/hrbraddins} + \item Report bugs at \url{https://gitlab.com/hrbrmstr/hrbraddins/issues} +} + } \author{ Bob Rudis (bob@rud.is) diff --git a/man/run_tiny_test.Rd b/man/run_tiny_test.Rd new file mode 100644 index 0000000..fc24e69 --- /dev/null +++ b/man/run_tiny_test.Rd @@ -0,0 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/run-tiny-test.R +\name{run_tiny_test} +\alias{run_tiny_test} +\title{Run {tinytest} on a package} +\usage{ +run_tiny_test() +} +\description{ +You should really bind this to something like cmd-opt-shift-t. +}