├── .Rbuildignore ├── .codecov.yml ├── .gitignore ├── .travis.yml ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── NEWS.md ├── R ├── aaa.R ├── bare-space-combine.R ├── bare_combine.r ├── check-package-urls.R ├── cleanAndGo.R ├── enslave.R ├── hrbraddins-package.R ├── join_rows.r ├── path-split.R ├── rant.r ├── refresh-renviron.R ├── run-tiny-test.R ├── tweet-share.r └── zap-gremlins.R ├── README.Rmd ├── README.md ├── codecov.yml ├── hrbraddins.Rproj ├── inst └── rstudio │ └── addins.dcf ├── man ├── bare_combine.Rd ├── bare_space_combine.Rd ├── check_package_urls.Rd ├── cleanAndGo.Rd ├── enslave.Rd ├── hrbraddins.Rd ├── join_rows.Rd ├── pathSplit.Rd ├── rantAddin.Rd ├── refresh_renviron.Rd ├── run_tiny_test.Rd ├── tweet_share.Rd └── zapGremlins.Rd └── tests ├── test-all.R └── testthat └── test-hrbraddins.R /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^\.travis\.yml$ 4 | ^README\.*Rmd$ 5 | ^README\.*html$ 6 | ^NOTES\.*Rmd$ 7 | ^NOTES\.*html$ 8 | ^\.codecov\.yml$ 9 | ^README_files$ 10 | ^doc$ 11 | ^codecov\.yml$ 12 | ^\.httr-oauth$ 13 | ^rant\.jpg$ -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .Rproj.user 3 | .Rhistory 4 | .RData 5 | .Rproj 6 | src/*.o 7 | src/*.so 8 | src/*.dll 9 | .httr-oauth 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: R 2 | sudo: false 3 | cache: packages 4 | 5 | after_success: 6 | - Rscript -e 'covr::codecov()' -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: hrbraddins 2 | Type: Package 3 | Title: Moar Addins for RStudio 4 | Version: 0.4.0 5 | Date: 2019-07-29 6 | Author: Bob Rudis (bob@rud.is) 7 | Maintainer: Bob Rudis 8 | Description: Provides additional addins for RStudio. 9 | URL: https://gitlab.com/hrbrmstr/hrbraddins 10 | BugReports: https://gitlab.com/hrbrmstr/hrbraddins/issues 11 | License: MIT + file LICENSE 12 | Suggests: testthat, 13 | covr 14 | Encoding: UTF-8 15 | Depends: 16 | R (>= 3.2.0) 17 | Imports: 18 | rstudioapi (>= 0.5), 19 | shiny (>= 0.13), 20 | miniUI (>= 0.1.1), 21 | stringi, 22 | utils, 23 | magick, 24 | pdftools, 25 | rmarkdown, 26 | urltools, 27 | gistr, 28 | knitr, 29 | twitteR, 30 | rtweet, 31 | fs, 32 | dplyr, 33 | tidyr, 34 | uuid, 35 | tinytest, 36 | rprojroot, 37 | memoise, 38 | tools, 39 | httr, 40 | janitor, 41 | purrr, 42 | tibble 43 | RoxygenNote: 6.1.1 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2017 2 | COPYRIGHT HOLDER: Bob Rudis 3 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(bare_combine) 4 | export(bare_space_combine) 5 | export(check_package_urls) 6 | export(cleanAndGo) 7 | export(enslave) 8 | export(join_rows) 9 | export(pathSplit) 10 | export(rantAddin) 11 | export(refresh_renviron) 12 | export(run_tiny_test) 13 | export(tweet_share) 14 | export(zapGremlins) 15 | import(knitr) 16 | import(magick) 17 | import(miniUI) 18 | import(pdftools) 19 | import(rmarkdown) 20 | import(rprojroot) 21 | import(rstudioapi) 22 | import(shiny) 23 | import(stringi) 24 | import(tinytest) 25 | import(utils) 26 | importFrom(dplyr,bind_cols) 27 | importFrom(dplyr,bind_rows) 28 | importFrom(dplyr,case_when) 29 | importFrom(dplyr,distinct) 30 | importFrom(dplyr,filter) 31 | importFrom(dplyr,full_join) 32 | importFrom(dplyr,left_join) 33 | importFrom(dplyr,mutate) 34 | importFrom(dplyr,progress_estimated) 35 | importFrom(fs,path_split) 36 | importFrom(gistr,gist_create) 37 | importFrom(httr,GET) 38 | importFrom(httr,status_code) 39 | importFrom(memoise,memoise) 40 | importFrom(purrr,map_dbl) 41 | importFrom(tibble,as_tibble) 42 | importFrom(tidyr,gather) 43 | importFrom(twitteR,tweet) 44 | importFrom(urltools,scheme) 45 | importFrom(utils,read.csv) 46 | importFrom(uuid,UUIDgenerate) 47 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | 0.3.0 2 | - Check package URLs 3 | 4 | 0.2.0 5 | * Refresh Renviron 6 | 7 | 0.1.0 8 | * Initial release 9 | -------------------------------------------------------------------------------- /R/aaa.R: -------------------------------------------------------------------------------- 1 | # global variables 2 | utils::globalVariables(c( 3 | ".", "URL", "env_var", "value", "new_value", ".rs.api.runScriptJob", 4 | "status", "parent", "url" 5 | )) 6 | -------------------------------------------------------------------------------- /R/bare-space-combine.R: -------------------------------------------------------------------------------- 1 | #' Turn a selection of space-separated bare strings into a base::combine statement 2 | #' 3 | #' Turns \cr\cr 4 | #' \code{a b c d e f}\cr\cr 5 | #' into\cr\cr 6 | #' \code{c("a", "b", "c", "d", "e", "f")} 7 | #' 8 | #' If the option `hrbraddins_uspace` is set TRUE, underscores will be 9 | #' converted to spaces before the final combine statement is created. 10 | #' 11 | #' @export 12 | bare_space_combine <- function() { 13 | 14 | ctx <- rstudioapi::getActiveDocumentContext() 15 | 16 | if (!is.null(ctx)) { 17 | 18 | if (ctx$selection[[1]]$text != "") { 19 | 20 | bits <- stri_trim_both(ctx$selection[[1]]$text) 21 | bits <- stri_split_regex(bits, "[[:space:]]+") 22 | bits <- unlist(bits, use.names = FALSE) 23 | 24 | qu <- options("useFancyQuotes") 25 | options(useFancyQuotes = FALSE) 26 | 27 | uspace <- as.logical(getOption("hrbraddins_uspace", FALSE)) 28 | if (uspace) bits <- stri_replace_all_fixed(bits, "_", " ") 29 | 30 | bits <- sapply(bits, dQuote) 31 | 32 | options(qu) 33 | 34 | bits <- paste0(bits, collapse = ", ") 35 | bits <- sprintf("c(%s)", bits) 36 | 37 | rstudioapi::modifyRange(ctx$selection[[1]]$range, bits) 38 | 39 | } 40 | 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /R/bare_combine.r: -------------------------------------------------------------------------------- 1 | #' Turn a selection of comma-separated bare strings into a base::combine statement 2 | #' 3 | #' Turns \cr\cr 4 | #' \code{a,b c,d,e f}\cr\cr 5 | #' or\cr\cr 6 | #' \code{a, b c, d, e f}\cr\cr 7 | #' into\cr\cr 8 | #' \code{c("a", "b c", "d", "e f")} 9 | #' 10 | #' @export 11 | bare_combine <- function() { 12 | 13 | ctx <- rstudioapi::getActiveDocumentContext() 14 | 15 | if (!is.null(ctx)) { 16 | 17 | if (ctx$selection[[1]]$text != "") { 18 | 19 | bits <- utils::read.csv(text = ctx$selection[[1]]$text, 20 | stringsAsFactors = FALSE, 21 | header = FALSE) 22 | 23 | bits <- unlist(bits, use.names = FALSE) 24 | 25 | op <- options("useFancyQuotes") 26 | options(useFancyQuotes = FALSE) 27 | 28 | bits <- sapply(bits, trimws) 29 | bits <- sapply(bits, dQuote) 30 | 31 | options(op) 32 | 33 | bits <- paste0(bits, collapse = ", ") 34 | bits <- sprintf("c(%s)", bits) 35 | 36 | rstudioapi::modifyRange(ctx$selection[[1]]$range, bits) 37 | 38 | } 39 | 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /R/check-package-urls.R: -------------------------------------------------------------------------------- 1 | m_GET <- memoise::memoise(httr::GET) # avoid checking URL more than once 2 | 3 | tc <- function(x, where = NULL) { 4 | if (length(where)) message("- Looking in ", where, " files...") 5 | tryCatch(x, error = function(e) NULL) 6 | } 7 | 8 | #' Check package URLs 9 | #' 10 | #' @note This uses non-exported functions from {tools}, one of which 11 | #' relies on the `pdftohtml` binary being present on the 12 | #' system running this function. 13 | #' @references [A deliberately bad URL](https://a.deliberately.bad.uurl/) 14 | #' @export 15 | check_package_urls <- function() { 16 | 17 | .pb <- NULL 18 | 19 | pkg <- tc(rprojroot::find_package_root_file()) 20 | 21 | if (is.null(pkg)) stop("Could not find package root.", call.=FALSE) 22 | 23 | message("Gathering URLs for {", basename(pkg), "} (this may take a bit)") 24 | 25 | dplyr::bind_rows( 26 | tc(tools:::url_db_from_package_HTML_files(pkg), "HTML"), 27 | tc(tools:::url_db_from_package_metadata(pkg), "metadata"), 28 | tc(tools:::url_db_from_package_news(pkg), "news"), 29 | tc(tools:::url_db_from_package_NEWS_md(pkg)), 30 | tc(tools:::url_db_from_package_Rd_db(pkg), "Rd"), 31 | tc(tools:::url_db_from_package_README_md(pkg), "README"), 32 | tc(tools:::url_db_from_package_sources(pkg), "source"), 33 | tc(tools:::url_db_from_PDF_files(pkg), "PDF"), 34 | ) %>% 35 | dplyr::distinct() %>% 36 | { .pb <<- dplyr::progress_estimated(nrow(.)) ; 37 | message("\nChecking found URLs (this may also take a bit)") 38 | . } %>% 39 | dplyr::mutate(status = purrr::map_dbl(URL, ~{ 40 | .pb$tick()$print() 41 | tryCatch( 42 | httr::status_code(m_GET(url = .x)), 43 | error = function(x) 599 44 | ) 45 | })) %>% 46 | janitor::clean_names() %>% 47 | dplyr::mutate(is_https = dplyr::case_when( 48 | grepl("^htt", url) ~ scheme(url) == "https", 49 | TRUE ~ NA 50 | )) %>% 51 | tibble::as_tibble() %>% 52 | dplyr::arrange(dplyr::desc(status), parent, url) %>% 53 | print(nrow(.)) 54 | 55 | } 56 | -------------------------------------------------------------------------------- /R/cleanAndGo.R: -------------------------------------------------------------------------------- 1 | #' Clean the environment and run the active script 2 | #' 3 | #' @export 4 | cleanAndGo <- function() { 5 | 6 | ctx <- rstudioapi::getActiveDocumentContext() 7 | 8 | if (!is.null(ctx)) { 9 | 10 | do.call(rm, as.list(ls(all.names = TRUE, envir = .GlobalEnv)), envir = .GlobalEnv) 11 | 12 | tf <- tempfile(fileext = ".R") 13 | writeLines(ctx$contents, con = tf) 14 | 15 | source(tf, local = FALSE) 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /R/enslave.R: -------------------------------------------------------------------------------- 1 | #' Run a selection as an RStudio background job 2 | #' 3 | #' @export 4 | enslave <- function() { 5 | 6 | ctx <- rstudioapi::getActiveDocumentContext() 7 | 8 | if (!is.null(ctx)) { 9 | 10 | if (ctx$selection[[1]]$text != "") { 11 | 12 | bits <- ctx$selection[[1]]$text 13 | 14 | tf <- tempfile(fileext = ".R") 15 | writeLines(bits, con = tf) 16 | 17 | nm <- sprintf("enslaved_%s", gsub("\\-", "", uuid::UUIDgenerate())) 18 | 19 | .rs.api.runScriptJob( 20 | path = tf, 21 | workingDir = getwd(), 22 | importEnv = TRUE, 23 | exportEnv = nm 24 | ) 25 | 26 | message("Job started. Results will be in ", nm) 27 | 28 | } 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /R/hrbraddins-package.R: -------------------------------------------------------------------------------- 1 | #' Moar Addins for RStudio 2 | #' 3 | #' @name hrbraddins 4 | #' @docType package 5 | #' @author Bob Rudis (bob@@rud.is) 6 | #' @import rstudioapi magick pdftools rmarkdown knitr utils 7 | #' @import shiny miniUI stringi tinytest rprojroot 8 | #' @importFrom httr GET status_code 9 | #' @importFrom memoise memoise 10 | #' @importFrom gistr gist_create 11 | #' @importFrom twitteR tweet 12 | #' @importFrom utils read.csv 13 | #' @importFrom dplyr bind_cols bind_rows left_join filter full_join 14 | #' @importFrom dplyr distinct mutate case_when progress_estimated 15 | #' @importFrom tibble as_tibble 16 | #' @importFrom purrr map_dbl 17 | #' @importFrom tidyr gather 18 | #' @importFrom uuid UUIDgenerate 19 | #' @importFrom urltools scheme 20 | #' @importFrom fs path_split 21 | "_PACKAGE" 22 | -------------------------------------------------------------------------------- /R/join_rows.r: -------------------------------------------------------------------------------- 1 | #' Join cr/lf-separated selected rows of text into a single space-separated row 2 | #' 3 | #' Turns 4 | #' \preformatted{ 5 | #' a 6 | #' b 7 | #' c 8 | #' d 9 | #' } 10 | #' into\cr\cr 11 | #' \code{a b c d} 12 | #' 13 | #' @export 14 | join_rows <- function() { 15 | 16 | ctx <- rstudioapi::getActiveDocumentContext() 17 | 18 | if (!is.null(ctx)) { 19 | 20 | if (ctx$selection[[1]]$text != "") { 21 | 22 | bits <- ctx$selection[[1]]$text 23 | bits <- gsub("[\r\n]+", " ", bits) 24 | bits <- paste0(bits, collapse="") 25 | 26 | rstudioapi::modifyRange(ctx$selection[[1]]$range, bits) 27 | 28 | } 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /R/path-split.R: -------------------------------------------------------------------------------- 1 | #' Path Split 2 | #' 3 | #' @export 4 | pathSplit <- function() { 5 | 6 | ctx <- rstudioapi::getActiveDocumentContext() 7 | 8 | print(str(ctx$selection)) 9 | 10 | if (!is.null(ctx)) { 11 | 12 | if (ctx$selection[[1]]$text != "") { 13 | 14 | found <- stri_match_first_regex(ctx$selection[[1]]$text, '"([^"]*)"') 15 | 16 | repl <- paste0(sprintf('"%s"', unlist(fs::path_split(found[2]))), collapse = ", ") 17 | 18 | rstudioapi::modifyRange( 19 | ctx$selection[[1]]$range, 20 | stri_replace_first_fixed(ctx$selection[[1]]$text, found[1], repl) 21 | ) 22 | 23 | } 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /R/rant.r: -------------------------------------------------------------------------------- 1 | #' Make it easier to annoy followers and reinforce one's entitlement. 2 | #' 3 | #' @export 4 | rantAddin <- function() { 5 | 6 | # Get the document context. 7 | context <- rstudioapi::getActiveDocumentContext() 8 | 9 | # Set the default data to use based on the selection. 10 | text <- context$selection[[1]]$text 11 | defaultData <- text 12 | 13 | # Generate UI for the gadget. 14 | ui <- miniPage( 15 | gadgetTitleBar("Twitter Rant!"), 16 | miniContentPanel( 17 | textAreaInput("storm", "Twitter Rant", cols = 120, rows = 10), 18 | htmlOutput("output") 19 | ) 20 | ) 21 | 22 | 23 | # Server code for the gadget. 24 | server <- function(input, output, session) { 25 | 26 | reactiveData <- reactive({ 27 | dataString <- input$storm 28 | dataString 29 | }) 30 | 31 | output$output <- renderText({ 32 | data <- reactiveData() 33 | if (nzchar(data) > 0) { 34 | tweet_base <- stringi::stri_wrap(data, 134, whitespace_only = TRUE) 35 | paste0(sprintf("%s %d/%d", tweet_base, 1:length(tweet_base), length(tweet_base)), collapse="
\n
\n") 36 | } else { 37 | "" 38 | } 39 | }) 40 | 41 | # Listen for 'done'. 42 | observeEvent(input$done, { 43 | invisible(stopApp()) 44 | }) 45 | } 46 | 47 | # Use a modal dialog as a viewr. 48 | viewer <- dialogViewer("Twitter Rant!", width = 1000, height = 800) 49 | runGadget(ui, server, viewer = viewer) 50 | 51 | } -------------------------------------------------------------------------------- /R/refresh-renviron.R: -------------------------------------------------------------------------------- 1 | #' Refreshes in-memory environment variables (if it exists) 2 | #' 3 | #' Equivanent to: `readRenviron("~/.Renviron")` 4 | #' 5 | #' @export 6 | refresh_renviron <- function() { 7 | 8 | renv <- path.expand("~/.Renviron") 9 | 10 | curr_env <- tidyr::gather(tibble::as_tibble(as.list(Sys.getenv())), env_var, value) 11 | 12 | if (file.exists(renv)) readRenviron(renv) 13 | 14 | new_env <- tidyr::gather(tibble::as_tibble(as.list(Sys.getenv())), env_var, new_value) 15 | 16 | both_env <- full_join(curr_env, new_env, by="env_var") 17 | 18 | changed <- filter(both_env, value != new_value) 19 | if (nrow(changed) > 0) { 20 | cat(sprintf("The following environment variables were changed:\n%s", 21 | sprintf(" - %s\n", changed$env_var))) 22 | } 23 | 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /R/run-tiny-test.R: -------------------------------------------------------------------------------- 1 | #' Run {tinytest} on a package 2 | #' 3 | #' You should really bind this to something like cmd-opt-shift-t. 4 | #' 5 | #' @export 6 | run_tiny_test <- function() { 7 | try(tinytest::test_all(rprojroot::find_package_root_file()), silent = TRUE) 8 | } -------------------------------------------------------------------------------- /R/tweet-share.r: -------------------------------------------------------------------------------- 1 | #' Share the active RStudio source tab on Twitter 2 | #' 3 | #' TODO tempdir/tempfile; error checking 4 | #' 5 | #' @export 6 | tweet_share <- function() { 7 | 8 | ctx <- rstudioapi::getSourceEditorContext() 9 | 10 | writeLines(ctx$contents, "/tmp/a.r") 11 | g <- gistr::gist_create("/tmp/a.r", browse=FALSE) 12 | 13 | fil <- file("/tmp/a.rmd", open = "w") 14 | writeLines(c( 15 | "---", 16 | "output: pdf_document", 17 | "---", 18 | "\\pagenumbering{gobble}", 19 | "```{r eval=FALSE}", 20 | ctx$contents, 21 | "```", 22 | sprintf("gist: [%s](%s)", g$url, g$url)), 23 | fil) 24 | close(fil) 25 | 26 | rmarkdown::render("/tmp/a.rmd", rmarkdown::pdf_document(), "/tmp/a.pdf") 27 | 28 | code_raster <- pdftools::pdf_render_page("/tmp/a.pdf", dpi=144) 29 | 30 | img <- magick::image_read(code_raster) 31 | img <- magick::image_trim(img) 32 | 33 | magick::image_write(img, "/tmp/a.png") 34 | 35 | #magick::image_browse(img) 36 | 37 | twitteR::tweet(sprintf("R code: %s", g$url), mediaPath = "/tmp/a.png") 38 | 39 | } 40 | -------------------------------------------------------------------------------- /R/zap-gremlins.R: -------------------------------------------------------------------------------- 1 | #' Find R source files with non-ASCII characters 2 | #' 3 | #' @export 4 | zapGremlins <- function() { 5 | 6 | d <- selectDirectory() 7 | 8 | sapply( 9 | list.files(d, pattern = "[.][Rr]$", full.names = TRUE), 10 | function(.x) { 11 | res <- capture.output(tools::showNonASCIIfile(.x), type = "message") 12 | if (length(res)) { 13 | res <- paste0(c(sprintf("# %s -----------\n", .x), res), collapse="\n") 14 | } 15 | } 16 | ) -> out 17 | 18 | out <- paste0(out, collapse = "\n\n") 19 | 20 | rstudioapi::documentNew(out) 21 | 22 | } 23 | 24 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: rmarkdown::github_document 3 | --- 4 | ```{r pkg-knitr-opts, include=FALSE} 5 | hrbrpkghelpr::global_opts() 6 | ``` 7 | 8 | ```{r badges, results='asis', echo=FALSE, cache=FALSE} 9 | hrbrpkghelpr::stinking_badges() 10 | ``` 11 | 12 | # hrbraddins 13 | 14 | Moar Addins for RStudio 15 | 16 | ## Description 17 | 18 | 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. 19 | 20 | ## What's in the tin? 21 | 22 | The following functions are implemented: 23 | 24 | ```{r ingredients, results='asis', echo=FALSE, cache=FALSE} 25 | hrbrpkghelpr::describe_ingredients() 26 | ``` 27 | 28 | ### Installation 29 | 30 | ```{r install-ex, results='asis', echo = FALSE} 31 | hrbrpkghelpr::install_block() 32 | ``` 33 | 34 | ## hrbraddins Metrics 35 | 36 | ```{r cloc, echo=FALSE} 37 | cloc::cloc_pkg_md() 38 | ``` 39 | 40 | ## Code of Conduct 41 | 42 | Please note that this project is released with a Contributor Code of Conduct. 43 | By participating in this project you agree to abide by its terms. 44 | 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | [![Project Status: Active – The project has reached a stable, usable 3 | state and is being actively 4 | developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) 5 | [![Signed 6 | by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keybase.io/hrbrmstr) 7 | ![Signed commit 8 | %](https://img.shields.io/badge/Signed_Commits-100%25-lightgrey.svg) 9 | [![Linux build 10 | Status](https://travis-ci.org/hrbrmstr/hrbraddins.svg?branch=master)](https://travis-ci.org/hrbrmstr/hrbraddins) 11 | [![Coverage 12 | Status](https://codecov.io/gh/hrbrmstr/hrbraddins/branch/master/graph/badge.svg)](https://codecov.io/gh/hrbrmstr/hrbraddins) 13 | ![Minimal R 14 | Version](https://img.shields.io/badge/R%3E%3D-3.2.0-blue.svg) 15 | ![License](https://img.shields.io/badge/License-MIT-blue.svg) 16 | 17 | # hrbraddins 18 | 19 | Moar Addins for RStudio 20 | 21 | ## Description 22 | 23 | Experiments, mostly. *Please* take the code and use it\! This package 24 | will NEVER see CRAN. I don’t even need credit. If you find something 25 | useful and are willing to round out the corners, it’s all yours. 26 | 27 | ## What’s in the tin? 28 | 29 | The following functions are implemented: 30 | 31 | - `bare_combine`: Turn a selection of comma-separated bare strings 32 | into a base::combine statement 33 | - `bare_space_combine`: Turn a selection of space-separated bare 34 | strings into a base::combine statement 35 | - `check_package_urls`: Check package URLs 36 | - `cleanAndGo`: Clean the environment and run the active script 37 | - `enslave`: Run a selection as an RStudio background job 38 | - `join_rows`: Join cr/lf-separated selected rows of text into a 39 | single space-separated row 40 | - `rantAddin`: Make it easier to annoy followers and reinforce one’s 41 | entitlement. 42 | - `refresh_renviron`: Refreshes in-memory environment variables (if it 43 | exists) 44 | - `run_tiny_test`: Run tinytest on a package 45 | - `tweet_share`: Share the active RStudio source tab on Twitter 46 | - `zapGremlins`: Find R source files with non-ASCII characters 47 | 48 | ### Installation 49 | 50 | ``` r 51 | install.packages("hrbraddins", repos = "https://cinc.rud.is") 52 | # or 53 | remotes::install_git("https://git.rud.is/hrbrmstr/hrbraddins.git") 54 | # or 55 | remotes::install_git("https://git.sr.ht/~hrbrmstr/hrbraddins") 56 | # or 57 | remotes::install_gitlab("hrbrmstr/hrbraddins") 58 | # or 59 | remotes::install_bitbucket("hrbrmstr/hrbraddins") 60 | # or 61 | remotes::install_github("hrbrmstr/hrbraddins") 62 | ``` 63 | 64 | NOTE: To use the ‘remotes’ install options you will need to have the 65 | [{remotes} package](https://github.com/r-lib/remotes) installed. 66 | 67 | ## hrbraddins Metrics 68 | 69 | | Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) | 70 | | :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | --: | 71 | | R | 15 | 0.94 | 212 | 0.98 | 97 | 0.87 | 95 | 0.8 | 72 | | Rmd | 1 | 0.06 | 5 | 0.02 | 15 | 0.13 | 24 | 0.2 | 73 | 74 | ## Code of Conduct 75 | 76 | Please note that this project is released with a Contributor Code of 77 | Conduct. By participating in this project you agree to abide by its 78 | terms. 79 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | -------------------------------------------------------------------------------- /hrbraddins.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | StripTrailingWhitespace: Yes 16 | 17 | BuildType: Package 18 | PackageUseDevtools: Yes 19 | PackageInstallArgs: --no-multiarch --with-keep.source 20 | PackageBuildArgs: --resave-data 21 | PackageRoxygenize: rd,collate,namespace 22 | -------------------------------------------------------------------------------- /inst/rstudio/addins.dcf: -------------------------------------------------------------------------------- 1 | Name: Check Package URLs 2 | Description: Use the same methods CRAN does to validate URLs in your package 3 | Binding: check_package_urls 4 | Interactive: true 5 | 6 | Name: Tiny Test Package 7 | Description: Run {tinytest} on a pkg 8 | Binding: run_tiny_test 9 | Interactive: true 10 | 11 | Name: Refresh .Renviron 12 | Description: Refreshes the in-memory environment variables from ~/.Renviron without requiring a restart 13 | Binding: refresh_renviron 14 | Interactive: false 15 | 16 | Name: Bare Space Combine 17 | Description: Turns a selected space-separated list of strings into a base::c() statement 18 | Binding: bare_space_combine 19 | Interactive: false 20 | 21 | Name: Bare Combine 22 | Description: Turns a selected comma-separated list of strings into a base::c() statement 23 | Binding: bare_combine 24 | Interactive: false 25 | 26 | Name: Join Rows 27 | Description: Join a selected set of rows into one line 28 | Binding: join_rows 29 | Interactive: false 30 | 31 | Name: Tweet Share 32 | Description: Share the active RStudio source tab on Twitter 33 | Binding: tweet_share 34 | Interactive: false 35 | 36 | Name: Twitter Rant! 37 | Description: Make it easier to annoy followers and reinforce one's entitlement. 38 | Binding: rantAddin 39 | Interactive: true 40 | 41 | Name: Enslave 42 | Description: Run a code selection as an RStudio background job task 43 | Binding: enslave 44 | Interactive: false 45 | 46 | Name: CleanAndGo 47 | Description: Cleanse the environment and execute the script 48 | Binding: cleanAndGo 49 | Interactive: false 50 | 51 | Name: Zap Gremlins 52 | Description: Find R source files with non-ASCII characters 53 | Binding: zapGremlins 54 | Interactive: false 55 | 56 | Name: Path Split 57 | Description: Split a / path to quoted commas 58 | Binding: pathSplit 59 | Interactive: false -------------------------------------------------------------------------------- /man/bare_combine.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/bare_combine.r 3 | \name{bare_combine} 4 | \alias{bare_combine} 5 | \title{Turn a selection of comma-separated bare strings into a base::combine statement} 6 | \usage{ 7 | bare_combine() 8 | } 9 | \description{ 10 | Turns \cr\cr 11 | \code{a,b c,d,e f}\cr\cr 12 | or\cr\cr 13 | \code{a, b c, d, e f}\cr\cr 14 | into\cr\cr 15 | \code{c("a", "b c", "d", "e f")} 16 | } 17 | -------------------------------------------------------------------------------- /man/bare_space_combine.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/bare-space-combine.R 3 | \name{bare_space_combine} 4 | \alias{bare_space_combine} 5 | \title{Turn a selection of space-separated bare strings into a base::combine statement} 6 | \usage{ 7 | bare_space_combine() 8 | } 9 | \description{ 10 | Turns \cr\cr 11 | \code{a b c d e f}\cr\cr 12 | into\cr\cr 13 | \code{c("a", "b", "c", "d", "e", "f")} 14 | } 15 | \details{ 16 | If the option `hrbraddins_uspace` is set TRUE, underscores will be 17 | converted to spaces before the final combine statement is created. 18 | } 19 | -------------------------------------------------------------------------------- /man/check_package_urls.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/check-package-urls.R 3 | \name{check_package_urls} 4 | \alias{check_package_urls} 5 | \title{Check package URLs} 6 | \usage{ 7 | check_package_urls() 8 | } 9 | \description{ 10 | Check package URLs 11 | } 12 | \note{ 13 | This uses non-exported functions from {tools}, one of which 14 | relies on the `pdftohtml` binary being present on the 15 | system running this function. 16 | } 17 | \references{ 18 | [A deliberately bad URL](https://a.deliberately.bad.uurl/) 19 | } 20 | -------------------------------------------------------------------------------- /man/cleanAndGo.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cleanAndGo.R 3 | \name{cleanAndGo} 4 | \alias{cleanAndGo} 5 | \title{Clean the environment and run the active script} 6 | \usage{ 7 | cleanAndGo() 8 | } 9 | \description{ 10 | Clean the environment and run the active script 11 | } 12 | -------------------------------------------------------------------------------- /man/enslave.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/enslave.R 3 | \name{enslave} 4 | \alias{enslave} 5 | \title{Run a selection as an RStudio background job} 6 | \usage{ 7 | enslave() 8 | } 9 | \description{ 10 | Run a selection as an RStudio background job 11 | } 12 | -------------------------------------------------------------------------------- /man/hrbraddins.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/hrbraddins-package.R 3 | \docType{package} 4 | \name{hrbraddins} 5 | \alias{hrbraddins} 6 | \alias{hrbraddins-package} 7 | \title{Moar Addins for RStudio} 8 | \description{ 9 | Provides additional addins for RStudio. 10 | } 11 | \seealso{ 12 | Useful links: 13 | \itemize{ 14 | \item \url{https://gitlab.com/hrbrmstr/hrbraddins} 15 | \item Report bugs at \url{https://gitlab.com/hrbrmstr/hrbraddins/issues} 16 | } 17 | 18 | } 19 | \author{ 20 | Bob Rudis (bob@rud.is) 21 | } 22 | -------------------------------------------------------------------------------- /man/join_rows.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/join_rows.r 3 | \name{join_rows} 4 | \alias{join_rows} 5 | \title{Join cr/lf-separated selected rows of text into a single space-separated row} 6 | \usage{ 7 | join_rows() 8 | } 9 | \description{ 10 | Turns 11 | \preformatted{ 12 | a 13 | b 14 | c 15 | d 16 | } 17 | into\cr\cr 18 | \code{a b c d} 19 | } 20 | -------------------------------------------------------------------------------- /man/pathSplit.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/path-split.R 3 | \name{pathSplit} 4 | \alias{pathSplit} 5 | \title{Path Split} 6 | \usage{ 7 | pathSplit() 8 | } 9 | \description{ 10 | Path Split 11 | } 12 | -------------------------------------------------------------------------------- /man/rantAddin.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rant.r 3 | \name{rantAddin} 4 | \alias{rantAddin} 5 | \title{Make it easier to annoy followers and reinforce one's entitlement.} 6 | \usage{ 7 | rantAddin() 8 | } 9 | \description{ 10 | Make it easier to annoy followers and reinforce one's entitlement. 11 | } 12 | -------------------------------------------------------------------------------- /man/refresh_renviron.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/refresh-renviron.R 3 | \name{refresh_renviron} 4 | \alias{refresh_renviron} 5 | \title{Refreshes in-memory environment variables (if it exists)} 6 | \usage{ 7 | refresh_renviron() 8 | } 9 | \description{ 10 | Equivanent to: `readRenviron("~/.Renviron")` 11 | } 12 | -------------------------------------------------------------------------------- /man/run_tiny_test.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/run-tiny-test.R 3 | \name{run_tiny_test} 4 | \alias{run_tiny_test} 5 | \title{Run {tinytest} on a package} 6 | \usage{ 7 | run_tiny_test() 8 | } 9 | \description{ 10 | You should really bind this to something like cmd-opt-shift-t. 11 | } 12 | -------------------------------------------------------------------------------- /man/tweet_share.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tweet-share.r 3 | \name{tweet_share} 4 | \alias{tweet_share} 5 | \title{Share the active RStudio source tab on Twitter} 6 | \usage{ 7 | tweet_share() 8 | } 9 | \description{ 10 | TODO tempdir/tempfile; error checking 11 | } 12 | -------------------------------------------------------------------------------- /man/zapGremlins.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/zap-gremlins.R 3 | \name{zapGremlins} 4 | \alias{zapGremlins} 5 | \title{Find R source files with non-ASCII characters} 6 | \usage{ 7 | zapGremlins() 8 | } 9 | \description{ 10 | Find R source files with non-ASCII characters 11 | } 12 | -------------------------------------------------------------------------------- /tests/test-all.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | test_check("hrbraddins") 3 | -------------------------------------------------------------------------------- /tests/testthat/test-hrbraddins.R: -------------------------------------------------------------------------------- 1 | context("basic functionality") 2 | test_that("we can do something", { 3 | 4 | expect_error(bare_combine()) 5 | expect_error(join_rows()) 6 | 7 | }) 8 | --------------------------------------------------------------------------------