Browse Source

check urls

master
boB Rudis 5 years ago
parent
commit
d41b66ac50
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 10
      DESCRIPTION
  2. 1
      NAMESPACE
  3. 44
      R/check-package-urls.R
  4. 2
      R/refresh-renviron.R
  5. 65
      README.Rmd
  6. 98
      README.md
  7. 5
      inst/rstudio/addins.dcf
  8. 15
      man/check_package_urls.Rd
  9. BIN
      rant.jpg

10
DESCRIPTION

@ -2,12 +2,12 @@ Package: hrbraddins
Type: Package
Title: Additional Addins for RStudio
Version: 0.2.0
Date: 2017-08-02
Date: 2018-07-25
Author: Bob Rudis (bob@rud.is)
Maintainer: Bob Rudis <bob@rud.is>
Description: Provides additional addins for RStudio.
URL: https://github.com/hrbrmstr/hrbraddins
BugReports: https://github.com/hrbrmstr/hrbraddins/issues
URL: https://gitlab.com/hrbrmstr/hrbraddins
BugReports: https://gitlab.com/hrbrmstr/hrbraddins/issues
License: MIT + file LICENSE
Suggests: testthat,
covr
@ -31,5 +31,7 @@ Imports:
tidyr,
uuid,
tinytest,
rprojroot
rprojroot,
memoise,
tools
RoxygenNote: 6.1.1

1
NAMESPACE

@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand
export(bare_combine)
export(check_package_urls)
export(cleanAndGo)
export(enslave)
export(join_rows)

44
R/check-package-urls.R

@ -0,0 +1,44 @@
#' 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) {
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)
message("Gathering URLs for {", basename(pkg), "} (this may take a bit)")
dplyr::bind_rows(
tc(tools:::url_db_from_package_HTML_files(pkg), "HTML"),
tc(tools:::url_db_from_package_metadata(pkg), "metadata"),
tc(tools:::url_db_from_package_news(pkg), "news"),
tc(tools:::url_db_from_package_NEWS_md(pkg)),
tc(tools:::url_db_from_package_Rd_db(pkg), "Rd"),
tc(tools:::url_db_from_package_README_md(pkg), "README"),
tc(tools:::url_db_from_package_sources(pkg), "source"),
tc(tools:::url_db_from_PDF_files(pkg), "PDF"),
) %>%
dplyr::distinct() %>%
{ .pb <<- dplyr::progress_estimated(nrow(.)) ;
message("\nChecking found URLs (this may also take a bit)")
. } %>%
dplyr::mutate(status = purrr::map_dbl(URL, ~{
.pb$tick()$print()
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))
}

2
R/refresh-renviron.R

@ -7,7 +7,7 @@ refresh_renviron <- function() {
renv <- path.expand("~/.Renviron")
curr_env <- gather(as_data_frame(as.list(Sys.getenv())), env_var, value)
curr_env <- gather(as_tibble(as.list(Sys.getenv())), env_var, value)
if (file.exists(renv)) readRenviron(renv)

65
README.Rmd

@ -1,9 +1,13 @@
---
output: rmarkdown::github_document
---
[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/0.1.0/active.svg)](http://www.repostatus.org/#active)
[![codecov](https://codecov.io/gh/hrbrmstr/hrbraddins/branch/master/graph/badge.svg)](https://codecov.io/gh/hrbrmstr/hrbraddins)
[![Travis-CI Build Status](https://travis-ci.org/hrbrmstr/hrbraddins.svg?branch=master)](https://travis-ci.org/hrbrmstr/hrbraddins)
```{r pkg-knitr-opts, include=FALSE}
hrbrpkghelpr::global_opts()
```
```{r badges, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::stinking_badges()
```
# hrbraddins
@ -17,52 +21,25 @@ Experiments, mostly. *Please* take the code and use it! This package will NEVER
The following functions are implemented:
- `refresh_renviron` : Refreshes in-memory R environment variables, noting changes
- `bare_combine`: Turn a selection of comma-separated bare strings into a - `base::combine`: statement
- `join_rows`: Join `cr`/`lf`-separated selected rows of text into a single space-separated row
## Examples
### Twitter RANTS!
Use the Addins menu to bring up a dialogue for Twitter Rants!
![](rant.jpg)
### Bare Combine
Similarly, the RStudio Addins menu selection "Bare Combine" will take a text selection and make it into a `c()` statement. For example:
a,b c,d,e f
or
a, b c, d, e f
will be converted to:
c("a", "b c", "d", "e f")
**NOTE**: not all double-quote edge cases are handled (yet).
### Join Rows
```{r ingredients, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::describe_ingredients()
```
Finally, unless I'm missing something, RStudio doesn't have a "join rows" option, so you can use the RStudio Addins menu selection "Join Rows" to do just that. So:
### Installation
a
b
c
d
```{r install-ex, results='asis', echo = FALSE}
hrbrpkghelpr::install_block()
```
becomes:
a b c d
## tdigest Metrics
The best way to find out if I'm wrong about that is by doing this tho since the internet will gladly tell me if I'm wrong.
```{r cloc, echo=FALSE}
cloc::cloc_pkg_md()
```
### Installation
## Code of Conduct
```{r eval=FALSE}
devtools::install_github("hrbrmstr/hrbraddins")
```
Please note that this project is released with a Contributor Code of Conduct.
By participating in this project you agree to abide by its terms.

98
README.md

@ -1,5 +1,18 @@
[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/0.1.0/active.svg)](http://www.repostatus.org/#active) [![codecov](https://codecov.io/gh/hrbrmstr/hrbraddins/branch/master/graph/badge.svg)](https://codecov.io/gh/hrbrmstr/hrbraddins) [![Travis-CI Build Status](https://travis-ci.org/hrbrmstr/hrbraddins.svg?branch=master)](https://travis-ci.org/hrbrmstr/hrbraddins)
[![Project Status: Active – The project has reached a stable, usable
state and is being actively
developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![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)
[![Linux build
Status](https://travis-ci.org/hrbrmstr/hrbraddins.svg?branch=master)](https://travis-ci.org/hrbrmstr/hrbraddins)
[![Coverage
Status](https://codecov.io/gh/hrbrmstr/hrbraddins/branch/master/graph/badge.svg)](https://codecov.io/gh/hrbrmstr/hrbraddins)
![Minimal R
Version](https://img.shields.io/badge/R%3E%3D-3.2.0-blue.svg)
![License](https://img.shields.io/badge/License-MIT-blue.svg)
# hrbraddins
@ -7,57 +20,54 @@ Additional Addins for RStudio
## Description
Experiments, mostly. *Please* take the code and use it! This package will NEVER see CRAN. I don't even need credit. If you find something useful and are willing to round out the corners, it's all yours.
Experiments, mostly. *Please* take the code and use it\! This package
will NEVER see CRAN. I don’t even need credit. If you find something
useful and are willing to round out the corners, it’s all yours.
## What's in the tin?
## Whats in the tin?
The following functions are implemented:
- `refresh_renviron` : Refreshes in-memory R environment variables, noting changes
- `bare_combine`: Turn a selection of comma-separated bare strings into a - `base::combine`: statement
- `join_rows`: Join `cr`/`lf`-separated selected rows of text into a single space-separated row
- `bare_combine`: Turn a selection of comma-separated bare strings
into a base::combine statement
- `check_package_urls`: Check package URLs
- `cleanAndGo`: Clean the environment and run the active script
- `enslave`: Run a selection as an RStudio background job
- `join_rows`: Join cr/lf-separated selected rows of text into a
single space-separated row
- `rantAddin`: Make it easier to annoy followers and reinforce one’s
entitlement.
- `refresh_renviron`: Refreshes in-memory environment variables (if it
exists)
- `tweet_share`: Share the active RStudio source tab on Twitter
- `zapGremlins`: Find R source files with non-ASCII characters
## Examples
### Twitter RANTS!
Use the Addins menu to bring up a dialogue for Twitter Rants!
![](rant.jpg)
### Bare Combine
Similarly, the RStudio Addins menu selection "Bare Combine" will take a text selection and make it into a `c()` statement. For example:
a,b c,d,e f
or
a, b c, d, e f
will be converted to:
c("a", "b c", "d", "e f")
**NOTE**: not all double-quote edge cases are handled (yet).
### Join Rows
Finally, unless I'm missing something, RStudio doesn't have a "join rows" option, so you can use the RStudio Addins menu selection "Join Rows" to do just that. So:
### Installation
a
b
c
d
``` r
remotes::install_git("https://git.rud.is/hrbrmstr/hrbraddins.git")
# or
remotes::install_git("https://git.sr.ht/~hrbrmstr/hrbraddins")
# or
remotes::install_gitlab("hrbrmstr/hrbraddins")
# or
remotes::install_bitbucket("hrbrmstr/hrbraddins")
# or
remotes::install_github("hrbrmstr/hrbraddins")
```
becomes:
NOTE: To use the ‘remotes’ install options you will need to have the
[{remotes} package](https://github.com/r-lib/remotes) installed.
a b c d
## tdigest Metrics
The best way to find out if I'm wrong about that is by doing this tho since the internet will gladly tell me if I'm wrong.
| 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 |
### Installation
## Code of Conduct
``` r
devtools::install_github("hrbrmstr/hrbraddins")
```
Please note that this project is released with a Contributor Code of
Conduct. By participating in this project you agree to abide by its
terms.

5
inst/rstudio/addins.dcf

@ -1,3 +1,8 @@
Name: Check Package URLs
Description: Use the same methods CRAN does to validate URLs in your package
Binding: check_package_urls
Interactive: false
Name: Tiny Test Package
Description: Run {tinytest} on a pkg
Binding: run_tiny_test

15
man/check_package_urls.Rd

@ -0,0 +1,15 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/check-package-urls.R
\name{check_package_urls}
\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.}
}
\description{
Check package URLs
}

BIN
rant.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

Loading…
Cancel
Save